wok-next view gcc/stuff/patches/005_all_default-as-needed.patch @ rev 21688

updated glu (9.0.0 -> 9.0.1)
author Hans-G?nter Theisgen
date Mon Jun 29 17:17:08 2020 +0100 (2020-06-29)
parents
children
line source
1 # DP: On linux targets pass --as-needed by default to the linker, but always
2 # DP: link the sanitizer libraries with --no-as-needed.
4 Index: b/gcc/gcc.c
5 ===================================================================
6 --- a/gcc/gcc.c
7 +++ b/gcc/gcc.c
8 @@ -692,8 +692,11 @@ proper position among the other output f
9 #ifdef LIBASAN_EARLY_SPEC
10 #define LIBASAN_SPEC STATIC_LIBASAN_LIBS
11 #elif defined(HAVE_LD_STATIC_DYNAMIC)
12 -#define LIBASAN_SPEC "%{static-libasan:" LD_STATIC_OPTION \
13 - "} -lasan %{static-libasan:" LD_DYNAMIC_OPTION "}" \
14 +#define LIBASAN_SPEC "%{static-libasan:" LD_STATIC_OPTION "}" \
15 + " %{!static-libasan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \
16 + " -lasan " \
17 + " %{static-libasan:" LD_DYNAMIC_OPTION "}" \
18 + " %{!static-libasan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \
19 STATIC_LIBASAN_LIBS
20 #else
21 #define LIBASAN_SPEC "-lasan" STATIC_LIBASAN_LIBS
22 @@ -710,8 +713,11 @@ proper position among the other output f
23 #ifdef LIBTSAN_EARLY_SPEC
24 #define LIBTSAN_SPEC STATIC_LIBTSAN_LIBS
25 #elif defined(HAVE_LD_STATIC_DYNAMIC)
26 -#define LIBTSAN_SPEC "%{static-libtsan:" LD_STATIC_OPTION \
27 - "} -ltsan %{static-libtsan:" LD_DYNAMIC_OPTION "}" \
28 +#define LIBTSAN_SPEC "%{static-libtsan:" LD_STATIC_OPTION "}" \
29 + " %{!static-libtsan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \
30 + " -ltsan " \
31 + " %{static-libtsan:" LD_DYNAMIC_OPTION "}" \
32 + " %{!static-libtsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \
33 STATIC_LIBTSAN_LIBS
34 #else
35 #define LIBTSAN_SPEC "-ltsan" STATIC_LIBTSAN_LIBS
36 @@ -728,8 +734,11 @@ proper position among the other output f
37 #ifdef LIBLSAN_EARLY_SPEC
38 #define LIBLSAN_SPEC STATIC_LIBLSAN_LIBS
39 #elif defined(HAVE_LD_STATIC_DYNAMIC)
40 -#define LIBLSAN_SPEC "%{static-liblsan:" LD_STATIC_OPTION \
41 - "} -llsan %{static-liblsan:" LD_DYNAMIC_OPTION "}" \
42 +#define LIBLSAN_SPEC "%{static-liblsan:" LD_STATIC_OPTION "}" \
43 + " %{!static-liblsan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \
44 + " -llsan " \
45 + " %{static-liblsan:" LD_DYNAMIC_OPTION "}" \
46 + " %{!static-liblsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \
47 STATIC_LIBLSAN_LIBS
48 #else
49 #define LIBLSAN_SPEC "-llsan" STATIC_LIBLSAN_LIBS
50 @@ -744,8 +753,11 @@ proper position among the other output f
51 #define STATIC_LIBUBSAN_LIBS \
52 " %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}"
53 #ifdef HAVE_LD_STATIC_DYNAMIC
54 -#define LIBUBSAN_SPEC "%{static-libubsan:" LD_STATIC_OPTION \
55 - "} -lubsan %{static-libubsan:" LD_DYNAMIC_OPTION "}" \
56 +#define LIBUBSAN_SPEC "%{static-libubsan:" LD_STATIC_OPTION "}" \
57 + " %{!static-libubsan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \
58 + " -lubsan " \
59 + " %{static-libubsan:" LD_DYNAMIC_OPTION "}" \
60 + " %{!static-libubsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \
61 STATIC_LIBUBSAN_LIBS
62 #else
63 #define LIBUBSAN_SPEC "-lubsan" STATIC_LIBUBSAN_LIBS
64 Index: b/gcc/config/gnu-user.h
65 ===================================================================
66 --- a/gcc/config/gnu-user.h
67 +++ b/gcc/config/gnu-user.h
68 @@ -161,15 +161,15 @@ see the files COPYING3 and COPYING.RUNTI
69 #define LIBASAN_EARLY_SPEC "%{!shared:libasan_preinit%O%s} " \
70 "%{static-libasan:%{!shared:" \
71 LD_STATIC_OPTION " --whole-archive -lasan --no-whole-archive " \
72 - LD_DYNAMIC_OPTION "}}%{!static-libasan:-lasan}"
73 + LD_DYNAMIC_OPTION "}}%{!static-libasan:%{!fuse-ld=gold:--push-state} --no-as-needed -lasan %{fuse-ld=gold:--as-needed;:--pop-state}}"
74 #undef LIBTSAN_EARLY_SPEC
75 #define LIBTSAN_EARLY_SPEC "%{!shared:libtsan_preinit%O%s} " \
76 "%{static-libtsan:%{!shared:" \
77 LD_STATIC_OPTION " --whole-archive -ltsan --no-whole-archive " \
78 - LD_DYNAMIC_OPTION "}}%{!static-libtsan:-ltsan}"
79 + LD_DYNAMIC_OPTION "}}%{!static-libtsan:%{!fuse-ld=gold:--push-state} --no-as-needed -ltsan %{fuse-ld=gold:--as-needed;:--pop-state}}"
80 #undef LIBLSAN_EARLY_SPEC
81 #define LIBLSAN_EARLY_SPEC "%{!shared:liblsan_preinit%O%s} " \
82 "%{static-liblsan:%{!shared:" \
83 LD_STATIC_OPTION " --whole-archive -llsan --no-whole-archive " \
84 - LD_DYNAMIC_OPTION "}}%{!static-liblsan:-llsan}"
85 + LD_DYNAMIC_OPTION "}}%{!static-liblsan:%{!fuse-ld=gold:--push-state} --no-as-needed -llsan %{fuse-ld=gold:--as-needed;:--pop-state}}"
86 #endif
87 Index: b/gcc/config/aarch64/aarch64-linux.h
88 ===================================================================
89 --- a/gcc/config/aarch64/aarch64-linux.h
90 +++ b/gcc/config/aarch64/aarch64-linux.h
91 @@ -35,6 +35,7 @@
92 #define CPP_SPEC "%{pthread:-D_REENTRANT}"
94 #define LINUX_TARGET_LINK_SPEC "%{h*} \
95 + --as-needed \
96 %{static:-Bstatic} \
97 %{shared:-shared} \
98 %{symbolic:-Bsymbolic} \
99 Index: b/gcc/config/ia64/linux.h
100 ===================================================================
101 --- a/gcc/config/ia64/linux.h
102 +++ b/gcc/config/ia64/linux.h
103 @@ -58,7 +58,7 @@ do { \
104 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-ia64.so.2"
106 #undef LINK_SPEC
107 -#define LINK_SPEC "\
108 +#define LINK_SPEC " --as-needed \
109 %{shared:-shared} \
110 %{!shared: \
111 %{!static: \
112 Index: b/gcc/config/sparc/linux.h
113 ===================================================================
114 --- a/gcc/config/sparc/linux.h
115 +++ b/gcc/config/sparc/linux.h
116 @@ -86,7 +86,7 @@ extern const char *host_detect_local_cpu
117 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
119 #undef LINK_SPEC
120 -#define LINK_SPEC "-m elf32_sparc %{shared:-shared} \
121 +#define LINK_SPEC "-m elf32_sparc --as-needed %{shared:-shared} \
122 %{!mno-relax:%{!r:-relax}} \
123 %{!shared: \
124 %{!static: \
125 Index: b/gcc/config/s390/linux.h
126 ===================================================================
127 --- a/gcc/config/s390/linux.h
128 +++ b/gcc/config/s390/linux.h
129 @@ -78,7 +78,7 @@ along with GCC; see the file COPYING3.
131 #undef LINK_SPEC
132 #define LINK_SPEC \
133 - "%{m31:-m elf_s390}%{m64:-m elf64_s390} \
134 + "%{m31:-m elf_s390}%{m64:-m elf64_s390} --as-needed \
135 %{shared:-shared} \
136 %{!shared: \
137 %{static:-static} \
138 Index: b/gcc/config/rs6000/linux64.h
139 ===================================================================
140 --- a/gcc/config/rs6000/linux64.h
141 +++ b/gcc/config/rs6000/linux64.h
142 @@ -490,13 +490,13 @@ extern int dot_symbols;
143 " -m elf64ppc")
144 #endif
146 -#define LINK_OS_LINUX_SPEC32 LINK_OS_LINUX_EMUL32 " %{!shared: %{!static: \
147 +#define LINK_OS_LINUX_SPEC32 LINK_OS_LINUX_EMUL32 " --as-needed %{!shared: %{!static: \
148 %{!static-pie: \
149 %{rdynamic:-export-dynamic} \
150 -dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "}}} \
151 %(link_os_extra_spec32)"
153 -#define LINK_OS_LINUX_SPEC64 LINK_OS_LINUX_EMUL64 " %{!shared: %{!static: \
154 +#define LINK_OS_LINUX_SPEC64 LINK_OS_LINUX_EMUL64 " --as-needed %{!shared: %{!static: \
155 %{!static-pie: \
156 %{rdynamic:-export-dynamic} \
157 -dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "}}} \
158 Index: b/gcc/config/rs6000/sysv4.h
159 ===================================================================
160 --- a/gcc/config/rs6000/sysv4.h
161 +++ b/gcc/config/rs6000/sysv4.h
162 @@ -811,7 +811,7 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
163 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \
164 MUSL_DYNAMIC_LINKER)
166 -#define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \
167 +#define LINK_OS_LINUX_SPEC "-m elf32ppclinux --as-needed %{!shared: %{!static: \
168 %{rdynamic:-export-dynamic} \
169 -dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}"
171 Index: b/gcc/config/i386/gnu-user64.h
172 ===================================================================
173 --- a/gcc/config/i386/gnu-user64.h
174 +++ b/gcc/config/i386/gnu-user64.h
175 @@ -56,6 +56,7 @@
176 "%{" SPEC_64 ":-m " GNU_USER_LINK_EMULATION64 "} \
177 %{" SPEC_32 ":-m " GNU_USER_LINK_EMULATION32 "} \
178 %{" SPEC_X32 ":-m " GNU_USER_LINK_EMULATIONX32 "} \
179 + --as-needed \
180 %{shared:-shared} \
181 %{!shared: \
182 %{!static: \
183 Index: b/gcc/config/i386/gnu-user.h
184 ===================================================================
185 --- a/gcc/config/i386/gnu-user.h
186 +++ b/gcc/config/i386/gnu-user.h
187 @@ -74,7 +74,7 @@ along with GCC; see the file COPYING3.
188 { "link_emulation", GNU_USER_LINK_EMULATION },\
189 { "dynamic_linker", GNU_USER_DYNAMIC_LINKER }
191 -#define GNU_USER_TARGET_LINK_SPEC "-m %(link_emulation) %{shared:-shared} \
192 +#define GNU_USER_TARGET_LINK_SPEC "-m %(link_emulation) --as-needed %{shared:-shared} \
193 %{!shared: \
194 %{!static: \
195 %{!static-pie: \
196 Index: b/gcc/config/alpha/linux-elf.h
197 ===================================================================
198 --- a/gcc/config/alpha/linux-elf.h
199 +++ b/gcc/config/alpha/linux-elf.h
200 @@ -37,7 +37,7 @@ along with GCC; see the file COPYING3.
202 #define ELF_DYNAMIC_LINKER GNU_USER_DYNAMIC_LINKER
204 -#define LINK_SPEC "-m elf64alpha %{G*} %{relax:-relax} \
205 +#define LINK_SPEC "-m elf64alpha --as-needed %{G*} %{relax:-relax} \
206 %{O*:-O3} %{!O*:-O1} \
207 %{shared:-shared} \
208 %{!shared: \
209 Index: b/gcc/config/arm/linux-elf.h
210 ===================================================================
211 --- a/gcc/config/arm/linux-elf.h
212 +++ b/gcc/config/arm/linux-elf.h
213 @@ -70,6 +70,7 @@
214 %{rdynamic:-export-dynamic} \
215 %{!shared:-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}} \
216 -X \
217 + --as-needed \
218 %{mbig-endian:-EB} %{mlittle-endian:-EL}" \
219 SUBTARGET_EXTRA_LINK_SPEC
221 Index: b/gcc/config/mips/gnu-user.h
222 ===================================================================
223 --- a/gcc/config/mips/gnu-user.h
224 +++ b/gcc/config/mips/gnu-user.h
225 @@ -55,6 +55,7 @@ along with GCC; see the file COPYING3.
226 #undef GNU_USER_TARGET_LINK_SPEC
227 #define GNU_USER_TARGET_LINK_SPEC "\
228 %{G*} %{EB} %{EL} %{mips*} %{shared} \
229 + -as-needed \
230 %{!shared: \
231 %{!static: \
232 %{rdynamic:-export-dynamic} \
233 Index: b/gcc/config/riscv/linux.h
234 ===================================================================
235 --- a/gcc/config/riscv/linux.h
236 +++ b/gcc/config/riscv/linux.h
237 @@ -50,6 +50,7 @@
238 #define CPP_SPEC "%{pthread:-D_REENTRANT}"
240 #define LINK_SPEC "\
241 +-as-needed \
242 -melf" XLEN_SPEC "lriscv \
243 %{mno-relax:--no-relax} \
244 %{shared} \