1 To: vim_dev@googlegroups.com
4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: The link script is clumsy.
12 Solution: Use the --as-needed linker option if available. (Kirill A.
14 Files: src/Makefile, src/auto/configure, src/config.mk.in,
15 src/configure.in, src/link.sh
18 *** ../vim-7.3.049/src/Makefile 2010-10-27 16:49:41.000000000 +0200
19 --- src/Makefile 2010-11-03 22:26:45.000000000 +0100
22 $(CCC) version.c -o objects/version.o
23 @LINK="$(PURIFY) $(SHRPENV) $(CClink) $(ALL_LIB_DIRS) $(LDFLAGS) \
24 -o $(VIMTARGET) $(OBJ) objects/version.o $(ALL_LIBS)" \
25 ! MAKE="$(MAKE)" sh $(srcdir)/link.sh
27 xxd/xxd$(EXEEXT): xxd/xxd.c
28 cd xxd; CC="$(CC)" CFLAGS="$(CPPFLAGS) $(CFLAGS)" \
30 $(CCC) version.c -o objects/version.o
31 @LINK="$(PURIFY) $(SHRPENV) $(CClink) $(ALL_LIB_DIRS) $(LDFLAGS) \
32 -o $(VIMTARGET) $(OBJ) objects/version.o $(ALL_LIBS)" \
33 ! MAKE="$(MAKE)" LINK_AS_NEEDED=$(LINK_AS_NEEDED) \
34 ! sh $(srcdir)/link.sh
36 xxd/xxd$(EXEEXT): xxd/xxd.c
37 cd xxd; CC="$(CC)" CFLAGS="$(CPPFLAGS) $(CFLAGS)" \
38 *** ../vim-7.3.049/src/auto/configure 2010-11-03 21:59:23.000000000 +0100
39 --- src/auto/configure 2010-11-03 22:28:03.000000000 +0100
44 ac_subst_vars='LTLIBOBJS
56 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker --as-needed support" >&5
57 + $as_echo_n "checking linker --as-needed support... " >&6; }
59 + # Check if linker supports --as-needed and --no-as-needed options
60 + if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
61 + LDFLAGS="$LDFLAGS -Wl,--as-needed"
64 + if test "$LINK_AS_NEEDED" = yes; then
65 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
66 + $as_echo "yes" >&6; }
68 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
69 + $as_echo "no" >&6; }
73 ac_config_files="$ac_config_files auto/config.mk:config.mk.in"
75 cat >confcache <<\_ACEOF
76 *** ../vim-7.3.049/src/config.mk.in 2010-08-15 21:57:28.000000000 +0200
77 --- src/config.mk.in 2010-11-03 22:26:24.000000000 +0100
83 DEPEND_CFLAGS_FILTER = @DEPEND_CFLAGS_FILTER@
84 + LINK_AS_NEEDED = @LINK_AS_NEEDED@
87 X_PRE_LIBS = @X_PRE_LIBS@
88 *** ../vim-7.3.049/src/configure.in 2010-11-03 21:59:23.000000000 +0100
89 --- src/configure.in 2010-11-03 22:26:16.000000000 +0100
94 AC_SUBST(DEPEND_CFLAGS_FILTER)
96 + dnl link.sh tries to avoid overlinking in a hackish way.
97 + dnl At least GNU ld supports --as-needed which provides the same functionality
98 + dnl at linker level. Let's use it.
99 + AC_MSG_CHECKING(linker --as-needed support)
101 + # Check if linker supports --as-needed and --no-as-needed options
102 + if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
103 + LDFLAGS="$LDFLAGS -Wl,--as-needed"
106 + if test "$LINK_AS_NEEDED" = yes; then
111 + AC_SUBST(LINK_AS_NEEDED)
113 dnl write output files
114 AC_OUTPUT(auto/config.mk:config.mk.in)
116 *** ../vim-7.3.049/src/link.sh 2010-08-15 21:57:25.000000000 +0200
117 --- src/link.sh 2010-11-03 22:26:08.000000000 +0100
120 # libraries when they exist, but this doesn't mean they are needed for Vim.
122 # Author: Bram Moolenaar
123 ! # Last change: 2006 Sep 26
124 # License: Public domain
126 # Warning: This fails miserably if the linker doesn't return an error code!
128 # libraries when they exist, but this doesn't mean they are needed for Vim.
130 # Author: Bram Moolenaar
131 ! # Last change: 2010 Nov 03
132 # License: Public domain
134 # Warning: This fails miserably if the linker doesn't return an error code!
137 echo "$LINK " >link.cmd
141 # If auto/link.sed already exists, use it. We assume a previous run of
142 # link.sh has found the correct set of libraries.
144 - if test -f auto/link.sed; then
145 echo "link.sh: The file 'auto/link.sed' exists, which is going to be used now."
146 echo "link.sh: If linking fails, try deleting the auto/link.sed file."
147 echo "link.sh: If this fails too, try creating an empty auto/link.sed file."
149 echo "$LINK " >link.cmd
152 + if test "$LINK_AS_NEEDED" = yes; then
153 + echo "link.sh: \$LINK_AS_NEEDED set to 'yes': invoking linker directly."
155 + if sh link.cmd; then
157 + echo "link.sh: Linked fine"
160 + echo "link.sh: Linking failed"
163 + if test -f auto/link.sed; then
166 # If auto/link.sed already exists, use it. We assume a previous run of
167 # link.sh has found the correct set of libraries.
169 echo "link.sh: The file 'auto/link.sed' exists, which is going to be used now."
170 echo "link.sh: If linking fails, try deleting the auto/link.sed file."
171 echo "link.sh: If this fails too, try creating an empty auto/link.sed file."
183 *** ../vim-7.3.049/src/version.c 2010-11-03 21:59:23.000000000 +0100
184 --- src/version.c 2010-11-03 22:30:17.000000000 +0100
188 { /* Add new patch number below this line */
194 Save the plankton - eat a whale.
196 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
197 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
198 \\\ download, build and distribute -- http://www.A-A-P.org ///
199 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///