0
0
mirror of https://github.com/vim/vim.git synced 2025-09-03 21:23:48 -04:00

patch 9.0.2028: confusing build dependencies

Problem:  confusing build dependencies
Solution: clean them up, make them parallelizable

Separate vim binary and unittest dependencies, make them parallelizable

Clean up make dependencies so Vim and unit test binaries only depend on
the object files they need. This fixes an existing issue where after
running unit tests, the Vim binary would be invalidated, which results
in it having to be linked again when running script tests, even though
Vim was already previously built.

Make link.sh (script we use to link those binaries) generate namespaced
temporary files for each app to avoid them colliding with each other.
This allows `unittesttargets` to be built in parallel.

These fixes are useful when using link-time-optimization as the link
phase could now take minutes rather than a few seconds.

closes: #13344

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
This commit is contained in:
Yee Cheng Chin 2023-10-15 09:50:53 +02:00 committed by Christian Brabandt
parent de3295dd0c
commit 5d03525cde
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
3 changed files with 45 additions and 39 deletions

View File

@ -2053,12 +2053,12 @@ CCC = $(CCC_NF) $(ALL_CFLAGS)
# Link the target for normal use or debugging. # Link the target for normal use or debugging.
# A shell script is used to try linking without unnecessary libraries. # A shell script is used to try linking without unnecessary libraries.
$(VIMTARGET): auto/config.mk objects $(OBJ) version.c version.h $(VIMTARGET): auto/config.mk $(OBJ) objects/version.o
$(CCC) version.c -o objects/version.o
@$(BUILD_DATE_MSG) @$(BUILD_DATE_MSG)
@LINK="$(PURIFY) $(SHRPENV) $(CClink) $(ALL_LIB_DIRS) $(LDFLAGS) \ @LINK="$(PURIFY) $(SHRPENV) $(CClink) $(ALL_LIB_DIRS) $(LDFLAGS) \
-o $(VIMTARGET) $(OBJ) $(ALL_LIBS)" \ -o $(VIMTARGET) $(OBJ) $(ALL_LIBS)" \
MAKE="$(MAKE)" LINK_AS_NEEDED=$(LINK_AS_NEEDED) \ MAKE="$(MAKE)" LINK_AS_NEEDED=$(LINK_AS_NEEDED) \
PROG="vim" \
sh $(srcdir)/link.sh sh $(srcdir)/link.sh
xxd/xxd$(EXEEXT): xxd/xxd.c xxd/xxd$(EXEEXT): xxd/xxd.c
@ -2267,32 +2267,32 @@ testclean:
# Unittests # Unittests
# It's build just like Vim to satisfy all dependencies. # It's build just like Vim to satisfy all dependencies.
$(JSON_TEST_TARGET): auto/config.mk objects $(JSON_TEST_OBJ) $(JSON_TEST_TARGET): auto/config.mk $(JSON_TEST_OBJ) objects/version.o
$(CCC) version.c -o objects/version.o
@LINK="$(PURIFY) $(SHRPENV) $(CClink) $(ALL_LIB_DIRS) $(LDFLAGS) \ @LINK="$(PURIFY) $(SHRPENV) $(CClink) $(ALL_LIB_DIRS) $(LDFLAGS) \
-o $(JSON_TEST_TARGET) $(JSON_TEST_OBJ) $(ALL_LIBS)" \ -o $(JSON_TEST_TARGET) $(JSON_TEST_OBJ) $(ALL_LIBS)" \
MAKE="$(MAKE)" LINK_AS_NEEDED=$(LINK_AS_NEEDED) \ MAKE="$(MAKE)" LINK_AS_NEEDED=$(LINK_AS_NEEDED) \
PROG="json_test" \
sh $(srcdir)/link.sh sh $(srcdir)/link.sh
$(KWORD_TEST_TARGET): auto/config.mk objects $(KWORD_TEST_OBJ) $(KWORD_TEST_TARGET): auto/config.mk $(KWORD_TEST_OBJ) objects/version.o
$(CCC) version.c -o objects/version.o
@LINK="$(PURIFY) $(SHRPENV) $(CClink) $(ALL_LIB_DIRS) $(LDFLAGS) \ @LINK="$(PURIFY) $(SHRPENV) $(CClink) $(ALL_LIB_DIRS) $(LDFLAGS) \
-o $(KWORD_TEST_TARGET) $(KWORD_TEST_OBJ) $(ALL_LIBS)" \ -o $(KWORD_TEST_TARGET) $(KWORD_TEST_OBJ) $(ALL_LIBS)" \
MAKE="$(MAKE)" LINK_AS_NEEDED=$(LINK_AS_NEEDED) \ MAKE="$(MAKE)" LINK_AS_NEEDED=$(LINK_AS_NEEDED) \
PROG="kword_test" \
sh $(srcdir)/link.sh sh $(srcdir)/link.sh
$(MEMFILE_TEST_TARGET): auto/config.mk objects $(MEMFILE_TEST_OBJ) $(MEMFILE_TEST_TARGET): auto/config.mk $(MEMFILE_TEST_OBJ) objects/version.o
$(CCC) version.c -o objects/version.o
@LINK="$(PURIFY) $(SHRPENV) $(CClink) $(ALL_LIB_DIRS) $(LDFLAGS) \ @LINK="$(PURIFY) $(SHRPENV) $(CClink) $(ALL_LIB_DIRS) $(LDFLAGS) \
-o $(MEMFILE_TEST_TARGET) $(MEMFILE_TEST_OBJ) $(ALL_LIBS)" \ -o $(MEMFILE_TEST_TARGET) $(MEMFILE_TEST_OBJ) $(ALL_LIBS)" \
MAKE="$(MAKE)" LINK_AS_NEEDED=$(LINK_AS_NEEDED) \ MAKE="$(MAKE)" LINK_AS_NEEDED=$(LINK_AS_NEEDED) \
PROG="memfile_test" \
sh $(srcdir)/link.sh sh $(srcdir)/link.sh
$(MESSAGE_TEST_TARGET): auto/config.mk objects $(MESSAGE_TEST_OBJ) $(MESSAGE_TEST_TARGET): auto/config.mk $(MESSAGE_TEST_OBJ) objects/version.o
$(CCC) version.c -o objects/version.o
@LINK="$(PURIFY) $(SHRPENV) $(CClink) $(ALL_LIB_DIRS) $(LDFLAGS) \ @LINK="$(PURIFY) $(SHRPENV) $(CClink) $(ALL_LIB_DIRS) $(LDFLAGS) \
-o $(MESSAGE_TEST_TARGET) $(MESSAGE_TEST_OBJ) $(ALL_LIBS)" \ -o $(MESSAGE_TEST_TARGET) $(MESSAGE_TEST_OBJ) $(ALL_LIBS)" \
MAKE="$(MAKE)" LINK_AS_NEEDED=$(LINK_AS_NEEDED) \ MAKE="$(MAKE)" LINK_AS_NEEDED=$(LINK_AS_NEEDED) \
PROG="message_test" \
sh $(srcdir)/link.sh sh $(srcdir)/link.sh
# install targets # install targets
@ -3503,6 +3503,9 @@ objects/usercmd.o: usercmd.c
objects/userfunc.o: userfunc.c objects/userfunc.o: userfunc.c
$(CCC) -o $@ userfunc.c $(CCC) -o $@ userfunc.c
objects/version.o: version.c
$(CCC) -o $@ version.c
objects/vim9class.o: vim9class.c objects/vim9class.o: vim9class.c
$(CCC) -o $@ vim9class.c $(CCC) -o $@ vim9class.c

View File

@ -13,13 +13,13 @@
# Otherwise this script is fail-safe, falling back to the original full link # Otherwise this script is fail-safe, falling back to the original full link
# command if anything fails. # command if anything fails.
echo "$LINK " >link.cmd echo "$LINK " >link_$PROG.cmd
exit_value=0 exit_value=0
if test "$LINK_AS_NEEDED" = yes; then if test "$LINK_AS_NEEDED" = yes; then
echo "link.sh: \$LINK_AS_NEEDED set to 'yes': invoking linker directly." echo "link.sh: \$LINK_AS_NEEDED set to 'yes': invoking linker directly."
cat link.cmd cat link_$PROG.cmd
if sh link.cmd; then if sh link_$PROG.cmd; then
exit_value=0 exit_value=0
echo "link.sh: Linked fine" echo "link.sh: Linked fine"
else else
@ -49,53 +49,53 @@ else
# - Don't remove the last -lm: On HP-UX Vim links OK but crashes when the GTK # - Don't remove the last -lm: On HP-UX Vim links OK but crashes when the GTK
# GUI is started, because the "floor" symbol could not be resolved. # GUI is started, because the "floor" symbol could not be resolved.
# #
cat link.cmd cat link_$PROG.cmd
if sh link.cmd; then if sh link_$PROG.cmd; then
touch auto/link.sed touch auto/link.sed
cp link.cmd linkit.sh cp link_$PROG.cmd linkit_$PROG.sh
for libname in SM ICE nsl dnet dnet_stub inet socket dir elf iconv Xt Xmu Xp Xpm X11 Xdmcp x w perl dl pthread thread readline m crypt attr; do for libname in SM ICE nsl dnet dnet_stub inet socket dir elf iconv Xt Xmu Xp Xpm X11 Xdmcp x w perl dl pthread thread readline m crypt attr; do
cont=yes cont=yes
while test -n "$cont"; do while test -n "$cont"; do
if grep "l$libname " linkit.sh >/dev/null; then if grep "l$libname " linkit_$PROG.sh >/dev/null; then
if test ! -f link1.sed; then if test ! -f link1_$PROG.sed; then
echo "link.sh: OK, linking works, let's try omitting a few libraries." echo "link.sh: OK, linking works, let's try omitting a few libraries."
echo "link.sh: See auto/link.log for details." echo "link.sh: See auto/link.log for details."
rm -f auto/link.log rm -f auto/link.log
fi fi
echo "s/-l$libname *//" >link1.sed echo "s/-l$libname *//" >link1_$PROG.sed
sed -f auto/link.sed <link.cmd >linkit2.sh sed -f auto/link.sed <link_$PROG.cmd >linkit2_$PROG.sh
sed -f link1.sed <linkit2.sh >linkit.sh sed -f link1_$PROG.sed <linkit2_$PROG.sh >linkit_$PROG.sh
# keep the last -lm # keep the last -lm
if test $libname != "m" || grep "lm " linkit.sh >/dev/null; then if test $libname != "m" || grep "lm " linkit_$PROG.sh >/dev/null; then
echo "link.sh: Trying to omit the $libname library..." echo "link.sh: Trying to omit the $libname library..."
cat linkit.sh >>auto/link.log cat linkit_$PROG.sh >>auto/link.log
# Redirect this link output, it may contain error messages which # Redirect this link output, it may contain error messages which
# should be ignored. # should be ignored.
if sh linkit.sh >>auto/link.log 2>&1; then if sh linkit_$PROG.sh >>auto/link.log 2>&1; then
echo "link.sh: Vim doesn't need the $libname library!" echo "link.sh: Vim doesn't need the $libname library!"
cat link1.sed >>auto/link.sed cat link1_$PROG.sed >>auto/link.sed
rm -f auto/pathdef.c rm -f auto/pathdef.c
else else
echo "link.sh: Vim DOES need the $libname library." echo "link.sh: Vim DOES need the $libname library."
cont= cont=
cp link.cmd linkit.sh cp link_$PROG.cmd linkit_$PROG.sh
fi fi
else else
cont= cont=
cp link.cmd linkit.sh cp link_$PROG.cmd linkit_$PROG.sh
fi fi
else else
cont= cont=
cp link.cmd linkit.sh cp link_$PROG.cmd linkit_$PROG.sh
fi fi
done done
done done
if test ! -f auto/pathdef.c; then if test ! -f auto/pathdef.c; then
$MAKE objects/pathdef.o $MAKE objects/pathdef.o
fi fi
if test ! -f link1.sed; then if test ! -f link1_$PROG.sed; then
echo "link.sh: Linked fine, no libraries can be omitted" echo "link.sh: Linked fine, no libraries can be omitted"
touch link3.sed touch link3_$PROG.sed
fi fi
else else
exit_value=$? exit_value=$?
@ -107,29 +107,29 @@ fi
# #
if test -s auto/link.sed; then if test -s auto/link.sed; then
echo "link.sh: Using auto/link.sed file to omit a few libraries" echo "link.sh: Using auto/link.sed file to omit a few libraries"
sed -f auto/link.sed <link.cmd >linkit.sh sed -f auto/link.sed <link_$PROG.cmd >linkit_$PROG.sh
cat linkit.sh cat linkit_$PROG.sh
if sh linkit.sh; then if sh linkit_$PROG.sh; then
exit_value=0 exit_value=0
echo "link.sh: Linked fine with a few libraries omitted" echo "link.sh: Linked fine with a few libraries omitted"
else else
exit_value=$? exit_value=$?
echo "link.sh: Linking failed, making auto/link.sed empty and trying again" echo "link.sh: Linking failed, making auto/link.sed empty and trying again"
mv -f auto/link.sed link2.sed mv -f auto/link.sed link2_$PROG.sed
touch auto/link.sed touch auto/link.sed
rm -f auto/pathdef.c rm -f auto/pathdef.c
$MAKE objects/pathdef.o $MAKE objects/pathdef.o
fi fi
fi fi
if test -f auto/link.sed -a ! -s auto/link.sed -a ! -f link3.sed; then if test -f auto/link.sed -a ! -s auto/link.sed -a ! -f link3_$PROG.sed; then
echo "link.sh: Using unmodified link command" echo "link.sh: Using unmodified link command"
cat link.cmd cat link_$PROG.cmd
if sh link.cmd; then if sh link_$PROG.cmd; then
exit_value=0 exit_value=0
echo "link.sh: Linked OK" echo "link.sh: Linked OK"
else else
exit_value=$? exit_value=$?
if test -f link2.sed; then if test -f link2_$PROG.sed; then
echo "link.sh: Linking doesn't work at all, removing auto/link.sed" echo "link.sh: Linking doesn't work at all, removing auto/link.sed"
rm -f auto/link.sed rm -f auto/link.sed
fi fi
@ -141,7 +141,8 @@ fi
# #
# cleanup # cleanup
# #
rm -f link.cmd linkit.sh link1.sed link2.sed link3.sed linkit2.sh rm -f link_$PROG.cmd linkit_$PROG.sh link1_$PROG.sed link2_$PROG.sed \
link3_$PROG.sed linkit2_$PROG.sh
# #
# return an error code if something went wrong # return an error code if something went wrong

View File

@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
2028,
/**/ /**/
2027, 2027,
/**/ /**/