Skip to content

Commit 5d03525

Browse files
ychinchrisbra
authored andcommitted
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 <[email protected]> Co-authored-by: Yee Cheng Chin <[email protected]>
1 parent de3295d commit 5d03525

File tree

3 files changed

+45
-39
lines changed

3 files changed

+45
-39
lines changed

src/Makefile

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,12 +2053,12 @@ CCC = $(CCC_NF) $(ALL_CFLAGS)
20532053

20542054
# Link the target for normal use or debugging.
20552055
# A shell script is used to try linking without unnecessary libraries.
2056-
$(VIMTARGET): auto/config.mk objects $(OBJ) version.c version.h
2057-
$(CCC) version.c -o objects/version.o
2056+
$(VIMTARGET): auto/config.mk $(OBJ) objects/version.o
20582057
@$(BUILD_DATE_MSG)
20592058
@LINK="$(PURIFY) $(SHRPENV) $(CClink) $(ALL_LIB_DIRS) $(LDFLAGS) \
20602059
-o $(VIMTARGET) $(OBJ) $(ALL_LIBS)" \
20612060
MAKE="$(MAKE)" LINK_AS_NEEDED=$(LINK_AS_NEEDED) \
2061+
PROG="vim" \
20622062
sh $(srcdir)/link.sh
20632063

20642064
xxd/xxd$(EXEEXT): xxd/xxd.c
@@ -2267,32 +2267,32 @@ testclean:
22672267

22682268
# Unittests
22692269
# It's build just like Vim to satisfy all dependencies.
2270-
$(JSON_TEST_TARGET): auto/config.mk objects $(JSON_TEST_OBJ)
2271-
$(CCC) version.c -o objects/version.o
2270+
$(JSON_TEST_TARGET): auto/config.mk $(JSON_TEST_OBJ) objects/version.o
22722271
@LINK="$(PURIFY) $(SHRPENV) $(CClink) $(ALL_LIB_DIRS) $(LDFLAGS) \
22732272
-o $(JSON_TEST_TARGET) $(JSON_TEST_OBJ) $(ALL_LIBS)" \
22742273
MAKE="$(MAKE)" LINK_AS_NEEDED=$(LINK_AS_NEEDED) \
2274+
PROG="json_test" \
22752275
sh $(srcdir)/link.sh
22762276

2277-
$(KWORD_TEST_TARGET): auto/config.mk objects $(KWORD_TEST_OBJ)
2278-
$(CCC) version.c -o objects/version.o
2277+
$(KWORD_TEST_TARGET): auto/config.mk $(KWORD_TEST_OBJ) objects/version.o
22792278
@LINK="$(PURIFY) $(SHRPENV) $(CClink) $(ALL_LIB_DIRS) $(LDFLAGS) \
22802279
-o $(KWORD_TEST_TARGET) $(KWORD_TEST_OBJ) $(ALL_LIBS)" \
22812280
MAKE="$(MAKE)" LINK_AS_NEEDED=$(LINK_AS_NEEDED) \
2281+
PROG="kword_test" \
22822282
sh $(srcdir)/link.sh
22832283

2284-
$(MEMFILE_TEST_TARGET): auto/config.mk objects $(MEMFILE_TEST_OBJ)
2285-
$(CCC) version.c -o objects/version.o
2284+
$(MEMFILE_TEST_TARGET): auto/config.mk $(MEMFILE_TEST_OBJ) objects/version.o
22862285
@LINK="$(PURIFY) $(SHRPENV) $(CClink) $(ALL_LIB_DIRS) $(LDFLAGS) \
22872286
-o $(MEMFILE_TEST_TARGET) $(MEMFILE_TEST_OBJ) $(ALL_LIBS)" \
22882287
MAKE="$(MAKE)" LINK_AS_NEEDED=$(LINK_AS_NEEDED) \
2288+
PROG="memfile_test" \
22892289
sh $(srcdir)/link.sh
22902290

2291-
$(MESSAGE_TEST_TARGET): auto/config.mk objects $(MESSAGE_TEST_OBJ)
2292-
$(CCC) version.c -o objects/version.o
2291+
$(MESSAGE_TEST_TARGET): auto/config.mk $(MESSAGE_TEST_OBJ) objects/version.o
22932292
@LINK="$(PURIFY) $(SHRPENV) $(CClink) $(ALL_LIB_DIRS) $(LDFLAGS) \
22942293
-o $(MESSAGE_TEST_TARGET) $(MESSAGE_TEST_OBJ) $(ALL_LIBS)" \
22952294
MAKE="$(MAKE)" LINK_AS_NEEDED=$(LINK_AS_NEEDED) \
2295+
PROG="message_test" \
22962296
sh $(srcdir)/link.sh
22972297

22982298
# install targets
@@ -3503,6 +3503,9 @@ objects/usercmd.o: usercmd.c
35033503
objects/userfunc.o: userfunc.c
35043504
$(CCC) -o $@ userfunc.c
35053505

3506+
objects/version.o: version.c
3507+
$(CCC) -o $@ version.c
3508+
35063509
objects/vim9class.o: vim9class.c
35073510
$(CCC) -o $@ vim9class.c
35083511

src/link.sh

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
# Otherwise this script is fail-safe, falling back to the original full link
1414
# command if anything fails.
1515

16-
echo "$LINK " >link.cmd
16+
echo "$LINK " >link_$PROG.cmd
1717
exit_value=0
1818

1919
if test "$LINK_AS_NEEDED" = yes; then
2020
echo "link.sh: \$LINK_AS_NEEDED set to 'yes': invoking linker directly."
21-
cat link.cmd
22-
if sh link.cmd; then
21+
cat link_$PROG.cmd
22+
if sh link_$PROG.cmd; then
2323
exit_value=0
2424
echo "link.sh: Linked fine"
2525
else
@@ -49,53 +49,53 @@ else
4949
# - Don't remove the last -lm: On HP-UX Vim links OK but crashes when the GTK
5050
# GUI is started, because the "floor" symbol could not be resolved.
5151
#
52-
cat link.cmd
53-
if sh link.cmd; then
52+
cat link_$PROG.cmd
53+
if sh link_$PROG.cmd; then
5454
touch auto/link.sed
55-
cp link.cmd linkit.sh
55+
cp link_$PROG.cmd linkit_$PROG.sh
5656
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
5757
cont=yes
5858
while test -n "$cont"; do
59-
if grep "l$libname " linkit.sh >/dev/null; then
60-
if test ! -f link1.sed; then
59+
if grep "l$libname " linkit_$PROG.sh >/dev/null; then
60+
if test ! -f link1_$PROG.sed; then
6161
echo "link.sh: OK, linking works, let's try omitting a few libraries."
6262
echo "link.sh: See auto/link.log for details."
6363
rm -f auto/link.log
6464
fi
65-
echo "s/-l$libname *//" >link1.sed
66-
sed -f auto/link.sed <link.cmd >linkit2.sh
67-
sed -f link1.sed <linkit2.sh >linkit.sh
65+
echo "s/-l$libname *//" >link1_$PROG.sed
66+
sed -f auto/link.sed <link_$PROG.cmd >linkit2_$PROG.sh
67+
sed -f link1_$PROG.sed <linkit2_$PROG.sh >linkit_$PROG.sh
6868
# keep the last -lm
69-
if test $libname != "m" || grep "lm " linkit.sh >/dev/null; then
69+
if test $libname != "m" || grep "lm " linkit_$PROG.sh >/dev/null; then
7070
echo "link.sh: Trying to omit the $libname library..."
71-
cat linkit.sh >>auto/link.log
71+
cat linkit_$PROG.sh >>auto/link.log
7272
# Redirect this link output, it may contain error messages which
7373
# should be ignored.
74-
if sh linkit.sh >>auto/link.log 2>&1; then
74+
if sh linkit_$PROG.sh >>auto/link.log 2>&1; then
7575
echo "link.sh: Vim doesn't need the $libname library!"
76-
cat link1.sed >>auto/link.sed
76+
cat link1_$PROG.sed >>auto/link.sed
7777
rm -f auto/pathdef.c
7878
else
7979
echo "link.sh: Vim DOES need the $libname library."
8080
cont=
81-
cp link.cmd linkit.sh
81+
cp link_$PROG.cmd linkit_$PROG.sh
8282
fi
8383
else
8484
cont=
85-
cp link.cmd linkit.sh
85+
cp link_$PROG.cmd linkit_$PROG.sh
8686
fi
8787
else
8888
cont=
89-
cp link.cmd linkit.sh
89+
cp link_$PROG.cmd linkit_$PROG.sh
9090
fi
9191
done
9292
done
9393
if test ! -f auto/pathdef.c; then
9494
$MAKE objects/pathdef.o
9595
fi
96-
if test ! -f link1.sed; then
96+
if test ! -f link1_$PROG.sed; then
9797
echo "link.sh: Linked fine, no libraries can be omitted"
98-
touch link3.sed
98+
touch link3_$PROG.sed
9999
fi
100100
else
101101
exit_value=$?
@@ -107,29 +107,29 @@ fi
107107
#
108108
if test -s auto/link.sed; then
109109
echo "link.sh: Using auto/link.sed file to omit a few libraries"
110-
sed -f auto/link.sed <link.cmd >linkit.sh
111-
cat linkit.sh
112-
if sh linkit.sh; then
110+
sed -f auto/link.sed <link_$PROG.cmd >linkit_$PROG.sh
111+
cat linkit_$PROG.sh
112+
if sh linkit_$PROG.sh; then
113113
exit_value=0
114114
echo "link.sh: Linked fine with a few libraries omitted"
115115
else
116116
exit_value=$?
117117
echo "link.sh: Linking failed, making auto/link.sed empty and trying again"
118-
mv -f auto/link.sed link2.sed
118+
mv -f auto/link.sed link2_$PROG.sed
119119
touch auto/link.sed
120120
rm -f auto/pathdef.c
121121
$MAKE objects/pathdef.o
122122
fi
123123
fi
124-
if test -f auto/link.sed -a ! -s auto/link.sed -a ! -f link3.sed; then
124+
if test -f auto/link.sed -a ! -s auto/link.sed -a ! -f link3_$PROG.sed; then
125125
echo "link.sh: Using unmodified link command"
126-
cat link.cmd
127-
if sh link.cmd; then
126+
cat link_$PROG.cmd
127+
if sh link_$PROG.cmd; then
128128
exit_value=0
129129
echo "link.sh: Linked OK"
130130
else
131131
exit_value=$?
132-
if test -f link2.sed; then
132+
if test -f link2_$PROG.sed; then
133133
echo "link.sh: Linking doesn't work at all, removing auto/link.sed"
134134
rm -f auto/link.sed
135135
fi
@@ -141,7 +141,8 @@ fi
141141
#
142142
# cleanup
143143
#
144-
rm -f link.cmd linkit.sh link1.sed link2.sed link3.sed linkit2.sh
144+
rm -f link_$PROG.cmd linkit_$PROG.sh link1_$PROG.sed link2_$PROG.sed \
145+
link3_$PROG.sed linkit2_$PROG.sh
145146

146147
#
147148
# return an error code if something went wrong

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
2028,
707709
/**/
708710
2027,
709711
/**/

0 commit comments

Comments
 (0)