comparison src/link.sh @ 33566:e1e3805fcd96 v9.0.2028

patch 9.0.2028: confusing build dependencies Commit: https://github.com/vim/vim/commit/5d03525cdef5db1b1cedfa26c6f8a21aaa207ec0 Author: Yee Cheng Chin <ychin.git@gmail.com> Date: Sun Oct 15 09:50:53 2023 +0200 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>
author Christian Brabandt <cb@256bit.org>
date Sun, 15 Oct 2023 10:00:03 +0200
parents 1ccc1ace9e5b
children
comparison
equal deleted inserted replaced
33565:6c04aed4cf31 33566:e1e3805fcd96
11 # Warning: This fails miserably if the linker doesn't return an error code! 11 # Warning: This fails miserably if the linker doesn't return an error code!
12 # 12 #
13 # Otherwise this script is fail-safe, falling back to the original full link 13 # Otherwise this script is fail-safe, falling back to the original full link
14 # command if anything fails. 14 # command if anything fails.
15 15
16 echo "$LINK " >link.cmd 16 echo "$LINK " >link_$PROG.cmd
17 exit_value=0 17 exit_value=0
18 18
19 if test "$LINK_AS_NEEDED" = yes; then 19 if test "$LINK_AS_NEEDED" = yes; then
20 echo "link.sh: \$LINK_AS_NEEDED set to 'yes': invoking linker directly." 20 echo "link.sh: \$LINK_AS_NEEDED set to 'yes': invoking linker directly."
21 cat link.cmd 21 cat link_$PROG.cmd
22 if sh link.cmd; then 22 if sh link_$PROG.cmd; then
23 exit_value=0 23 exit_value=0
24 echo "link.sh: Linked fine" 24 echo "link.sh: Linked fine"
25 else 25 else
26 exit_value=$? 26 exit_value=$?
27 echo "link.sh: Linking failed" 27 echo "link.sh: Linking failed"
47 # - Can't remove Xext; It links fine but will give an error when running gvim 47 # - Can't remove Xext; It links fine but will give an error when running gvim
48 # with Motif. 48 # with Motif.
49 # - Don't remove the last -lm: On HP-UX Vim links OK but crashes when the GTK 49 # - Don't remove the last -lm: On HP-UX Vim links OK but crashes when the GTK
50 # GUI is started, because the "floor" symbol could not be resolved. 50 # GUI is started, because the "floor" symbol could not be resolved.
51 # 51 #
52 cat link.cmd 52 cat link_$PROG.cmd
53 if sh link.cmd; then 53 if sh link_$PROG.cmd; then
54 touch auto/link.sed 54 touch auto/link.sed
55 cp link.cmd linkit.sh 55 cp link_$PROG.cmd linkit_$PROG.sh
56 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 56 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
57 cont=yes 57 cont=yes
58 while test -n "$cont"; do 58 while test -n "$cont"; do
59 if grep "l$libname " linkit.sh >/dev/null; then 59 if grep "l$libname " linkit_$PROG.sh >/dev/null; then
60 if test ! -f link1.sed; then 60 if test ! -f link1_$PROG.sed; then
61 echo "link.sh: OK, linking works, let's try omitting a few libraries." 61 echo "link.sh: OK, linking works, let's try omitting a few libraries."
62 echo "link.sh: See auto/link.log for details." 62 echo "link.sh: See auto/link.log for details."
63 rm -f auto/link.log 63 rm -f auto/link.log
64 fi 64 fi
65 echo "s/-l$libname *//" >link1.sed 65 echo "s/-l$libname *//" >link1_$PROG.sed
66 sed -f auto/link.sed <link.cmd >linkit2.sh 66 sed -f auto/link.sed <link_$PROG.cmd >linkit2_$PROG.sh
67 sed -f link1.sed <linkit2.sh >linkit.sh 67 sed -f link1_$PROG.sed <linkit2_$PROG.sh >linkit_$PROG.sh
68 # keep the last -lm 68 # 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
70 echo "link.sh: Trying to omit the $libname library..." 70 echo "link.sh: Trying to omit the $libname library..."
71 cat linkit.sh >>auto/link.log 71 cat linkit_$PROG.sh >>auto/link.log
72 # Redirect this link output, it may contain error messages which 72 # Redirect this link output, it may contain error messages which
73 # should be ignored. 73 # 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
75 echo "link.sh: Vim doesn't need the $libname library!" 75 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
77 rm -f auto/pathdef.c 77 rm -f auto/pathdef.c
78 else 78 else
79 echo "link.sh: Vim DOES need the $libname library." 79 echo "link.sh: Vim DOES need the $libname library."
80 cont= 80 cont=
81 cp link.cmd linkit.sh 81 cp link_$PROG.cmd linkit_$PROG.sh
82 fi 82 fi
83 else 83 else
84 cont= 84 cont=
85 cp link.cmd linkit.sh 85 cp link_$PROG.cmd linkit_$PROG.sh
86 fi 86 fi
87 else 87 else
88 cont= 88 cont=
89 cp link.cmd linkit.sh 89 cp link_$PROG.cmd linkit_$PROG.sh
90 fi 90 fi
91 done 91 done
92 done 92 done
93 if test ! -f auto/pathdef.c; then 93 if test ! -f auto/pathdef.c; then
94 $MAKE objects/pathdef.o 94 $MAKE objects/pathdef.o
95 fi 95 fi
96 if test ! -f link1.sed; then 96 if test ! -f link1_$PROG.sed; then
97 echo "link.sh: Linked fine, no libraries can be omitted" 97 echo "link.sh: Linked fine, no libraries can be omitted"
98 touch link3.sed 98 touch link3_$PROG.sed
99 fi 99 fi
100 else 100 else
101 exit_value=$? 101 exit_value=$?
102 fi 102 fi
103 fi 103 fi
105 # 105 #
106 # Now do the real linking. 106 # Now do the real linking.
107 # 107 #
108 if test -s auto/link.sed; then 108 if test -s auto/link.sed; then
109 echo "link.sh: Using auto/link.sed file to omit a few libraries" 109 echo "link.sh: Using auto/link.sed file to omit a few libraries"
110 sed -f auto/link.sed <link.cmd >linkit.sh 110 sed -f auto/link.sed <link_$PROG.cmd >linkit_$PROG.sh
111 cat linkit.sh 111 cat linkit_$PROG.sh
112 if sh linkit.sh; then 112 if sh linkit_$PROG.sh; then
113 exit_value=0 113 exit_value=0
114 echo "link.sh: Linked fine with a few libraries omitted" 114 echo "link.sh: Linked fine with a few libraries omitted"
115 else 115 else
116 exit_value=$? 116 exit_value=$?
117 echo "link.sh: Linking failed, making auto/link.sed empty and trying again" 117 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
119 touch auto/link.sed 119 touch auto/link.sed
120 rm -f auto/pathdef.c 120 rm -f auto/pathdef.c
121 $MAKE objects/pathdef.o 121 $MAKE objects/pathdef.o
122 fi 122 fi
123 fi 123 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
125 echo "link.sh: Using unmodified link command" 125 echo "link.sh: Using unmodified link command"
126 cat link.cmd 126 cat link_$PROG.cmd
127 if sh link.cmd; then 127 if sh link_$PROG.cmd; then
128 exit_value=0 128 exit_value=0
129 echo "link.sh: Linked OK" 129 echo "link.sh: Linked OK"
130 else 130 else
131 exit_value=$? 131 exit_value=$?
132 if test -f link2.sed; then 132 if test -f link2_$PROG.sed; then
133 echo "link.sh: Linking doesn't work at all, removing auto/link.sed" 133 echo "link.sh: Linking doesn't work at all, removing auto/link.sed"
134 rm -f auto/link.sed 134 rm -f auto/link.sed
135 fi 135 fi
136 fi 136 fi
137 fi 137 fi
139 fi 139 fi
140 140
141 # 141 #
142 # cleanup 142 # cleanup
143 # 143 #
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
145 146
146 # 147 #
147 # return an error code if something went wrong 148 # return an error code if something went wrong
148 # 149 #
149 exit $exit_value 150 exit $exit_value