1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
To: vim_dev@googlegroups.com
Subject: Patch 7.3.050
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------
Patch 7.3.050
Problem: The link script is clumsy.
Solution: Use the --as-needed linker option if available. (Kirill A.
Shutemov)
Files: src/Makefile, src/auto/configure, src/config.mk.in,
src/configure.in, src/link.sh
*** ../vim-7.3.049/src/Makefile 2010-10-27 16:49:41.000000000 +0200
--- src/Makefile 2010-11-03 22:26:45.000000000 +0100
***************
*** 1700,1706 ****
$(CCC) version.c -o objects/version.o
@LINK="$(PURIFY) $(SHRPENV) $(CClink) $(ALL_LIB_DIRS) $(LDFLAGS) \
-o $(VIMTARGET) $(OBJ) objects/version.o $(ALL_LIBS)" \
! MAKE="$(MAKE)" sh $(srcdir)/link.sh
xxd/xxd$(EXEEXT): xxd/xxd.c
cd xxd; CC="$(CC)" CFLAGS="$(CPPFLAGS) $(CFLAGS)" \
--- 1700,1707 ----
$(CCC) version.c -o objects/version.o
@LINK="$(PURIFY) $(SHRPENV) $(CClink) $(ALL_LIB_DIRS) $(LDFLAGS) \
-o $(VIMTARGET) $(OBJ) objects/version.o $(ALL_LIBS)" \
! MAKE="$(MAKE)" LINK_AS_NEEDED=$(LINK_AS_NEEDED) \
! sh $(srcdir)/link.sh
xxd/xxd$(EXEEXT): xxd/xxd.c
cd xxd; CC="$(CC)" CFLAGS="$(CPPFLAGS) $(CFLAGS)" \
*** ../vim-7.3.049/src/auto/configure 2010-11-03 21:59:23.000000000 +0100
--- src/auto/configure 2010-11-03 22:28:03.000000000 +0100
***************
*** 593,598 ****
--- 593,599 ----
ac_subst_vars='LTLIBOBJS
LIBOBJS
+ LINK_AS_NEEDED
DEPEND_CFLAGS_FILTER
MAKEMO
MSGFMT
***************
*** 12404,12409 ****
--- 12405,12427 ----
fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker --as-needed support" >&5
+ $as_echo_n "checking linker --as-needed support... " >&6; }
+ LINK_AS_NEEDED=
+ # Check if linker supports --as-needed and --no-as-needed options
+ if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
+ LDFLAGS="$LDFLAGS -Wl,--as-needed"
+ LINK_AS_NEEDED=yes
+ fi
+ if test "$LINK_AS_NEEDED" = yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+ $as_echo "yes" >&6; }
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+ $as_echo "no" >&6; }
+ fi
+
+
ac_config_files="$ac_config_files auto/config.mk:config.mk.in"
cat >confcache <<\_ACEOF
*** ../vim-7.3.049/src/config.mk.in 2010-08-15 21:57:28.000000000 +0200
--- src/config.mk.in 2010-11-03 22:26:24.000000000 +0100
***************
*** 30,35 ****
--- 30,36 ----
CPP = @CPP@
CPP_MM = @CPP_MM@
DEPEND_CFLAGS_FILTER = @DEPEND_CFLAGS_FILTER@
+ LINK_AS_NEEDED = @LINK_AS_NEEDED@
X_CFLAGS = @X_CFLAGS@
X_LIBS_DIR = @X_LIBS@
X_PRE_LIBS = @X_PRE_LIBS@
*** ../vim-7.3.049/src/configure.in 2010-11-03 21:59:23.000000000 +0100
--- src/configure.in 2010-11-03 22:26:16.000000000 +0100
***************
*** 3527,3532 ****
--- 3527,3549 ----
fi
AC_SUBST(DEPEND_CFLAGS_FILTER)
+ dnl link.sh tries to avoid overlinking in a hackish way.
+ dnl At least GNU ld supports --as-needed which provides the same functionality
+ dnl at linker level. Let's use it.
+ AC_MSG_CHECKING(linker --as-needed support)
+ LINK_AS_NEEDED=
+ # Check if linker supports --as-needed and --no-as-needed options
+ if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
+ LDFLAGS="$LDFLAGS -Wl,--as-needed"
+ LINK_AS_NEEDED=yes
+ fi
+ if test "$LINK_AS_NEEDED" = yes; then
+ AC_MSG_RESULT(yes)
+ else
+ AC_MSG_RESULT(no)
+ fi
+ AC_SUBST(LINK_AS_NEEDED)
+
dnl write output files
AC_OUTPUT(auto/config.mk:config.mk.in)
*** ../vim-7.3.049/src/link.sh 2010-08-15 21:57:25.000000000 +0200
--- src/link.sh 2010-11-03 22:26:08.000000000 +0100
***************
*** 5,11 ****
# libraries when they exist, but this doesn't mean they are needed for Vim.
#
# Author: Bram Moolenaar
! # Last change: 2006 Sep 26
# License: Public domain
#
# Warning: This fails miserably if the linker doesn't return an error code!
--- 5,11 ----
# libraries when they exist, but this doesn't mean they are needed for Vim.
#
# Author: Bram Moolenaar
! # Last change: 2010 Nov 03
# License: Public domain
#
# Warning: This fails miserably if the linker doesn't return an error code!
***************
*** 16,26 ****
echo "$LINK " >link.cmd
exit_value=0
#
# If auto/link.sed already exists, use it. We assume a previous run of
# link.sh has found the correct set of libraries.
#
- if test -f auto/link.sed; then
echo "link.sh: The file 'auto/link.sed' exists, which is going to be used now."
echo "link.sh: If linking fails, try deleting the auto/link.sed file."
echo "link.sh: If this fails too, try creating an empty auto/link.sed file."
--- 16,38 ----
echo "$LINK " >link.cmd
exit_value=0
+ if test "$LINK_AS_NEEDED" = yes; then
+ echo "link.sh: \$LINK_AS_NEEDED set to 'yes': invoking linker directly."
+ cat link.cmd
+ if sh link.cmd; then
+ exit_value=0
+ echo "link.sh: Linked fine"
+ else
+ exit_value=$?
+ echo "link.sh: Linking failed"
+ fi
+ else
+ if test -f auto/link.sed; then
+
#
# If auto/link.sed already exists, use it. We assume a previous run of
# link.sh has found the correct set of libraries.
#
echo "link.sh: The file 'auto/link.sed' exists, which is going to be used now."
echo "link.sh: If linking fails, try deleting the auto/link.sed file."
echo "link.sh: If this fails too, try creating an empty auto/link.sed file."
***************
*** 124,129 ****
--- 136,143 ----
fi
fi
+ fi
+
#
# cleanup
#
*** ../vim-7.3.049/src/version.c 2010-11-03 21:59:23.000000000 +0100
--- src/version.c 2010-11-03 22:30:17.000000000 +0100
***************
*** 716,717 ****
--- 716,719 ----
{ /* Add new patch number below this line */
+ /**/
+ 50,
/**/
--
Save the plankton - eat a whale.
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|