Add ability to change linker warning messages into errors when reporting executable...
[binutils-gdb.git] / ld / testsuite / ld-plugin / lto.exp
blobe71cf36ad62dc9eba6c2ba9517faad18dd610182
1 # Expect script for ld-plugin LTO tests
2 # Copyright (C) 2011-2023 Free Software Foundation, Inc.
4 # This file is part of the GNU Binutils.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 # MA 02110-1301, USA.
21 # Check to see if the C and C++ compilers work
22 if { ![check_compiler_available] || [which $CXX_FOR_TARGET] == 0 } {
23 return
26 # These tests require plugin and LTO.
27 if { ![check_plugin_api_available]
28 || ![check_lto_available] } {
29 return
32 set saved_CFLAGS "$CFLAGS_FOR_TARGET"
33 set saved_CXXFLAGS "$CXXFLAGS_FOR_TARGET"
34 regsub -all "(\\-Wp,)?-D_FORTIFY_SOURCE=\[0-9\]+" $CFLAGS_FOR_TARGET "" CFLAGS_FOR_TARGET
35 regsub -all "(\\-Wp,)?-D_FORTIFY_SOURCE=\[0-9\]+" $CXXFLAGS_FOR_TARGET "" CXXFLAGS_FOR_TARGET
37 proc restore_notify { } {
38 global saved_CFLAGS
39 global saved_CXXFLAGS
40 global CFLAGS_FOR_TARGET
41 global CXXFLAGS_FOR_TARGET
42 set CFLAGS_FOR_TARGET "$saved_CFLAGS"
43 set CXXFLAGS_FOR_TARGET "$saved_CXXFLAGS"
46 set lto_fat ""
47 set lto_no_fat ""
48 if { [check_lto_fat_available] } {
49 set lto_fat "-ffat-lto-objects"
50 set lto_no_fat "-fno-fat-lto-objects"
51 set no_lto "-fno-lto"
54 # Simple LTO tests and generate input files for complex LTO tests.
55 set lto_link_tests [list \
56 [list "LTO 1" \
57 "-O2 -flto -fuse-linker-plugin" "-flto -fuse-linker-plugin" \
58 {lto-1a.c lto-1b.c} {} "lto-1.exe"] \
59 [list "Compile 2" \
60 "" "-O2 -flto -fuse-linker-plugin $NOSANITIZE_CFLAGS" \
61 {lto-2.c} {} ""] \
62 [list "LTO 2" \
63 "-static -O2 -flto -fuse-linker-plugin tmpdir/lto-2.o -lm" \
64 "$NOSANITIZE_CFLAGS" \
65 {dummy.c} {} "lto-2.exe"] \
66 [list "Compile 3a" \
67 "" "-flto" \
68 {lto-3a.c} {} ""] \
69 [list "Compile 3c" \
70 "" "-O2" \
71 {lto-3c.c} {} ""] \
72 [list "Build liblto-3.a" \
73 "" "-flto $lto_fat" \
74 {lto-3b.c} {} "liblto-3.a"] \
75 [list "Compile 5a" \
76 "" "-flto $lto_fat" \
77 {lto-5a.c} {} ""] \
78 [list "Compile 5b" \
79 "" "-flto $lto_fat" \
80 {lto-5b.c} {} ""] \
81 [list "Compile PR ld/12365" \
82 "" "-flto -O2 $lto_fat -finline" \
83 {pr12365a.c pr12365b.c pr12365c.c} {} ""] \
84 [list "Compile 9" \
85 "" "-O2 -finline -flto" \
86 {lto-9.cc} {} "" "c++"] \
87 [list "Compile 11a" \
88 "" "-O -flto" \
89 {lto-11a.c} {} ""] \
90 [list "Compile 11b" \
91 "" "-O -flto" \
92 {lto-11b.c} {} ""] \
93 [list "Compile 11c" \
94 "" "-O" \
95 {lto-11c.c} {} ""] \
96 [list "Build liblto-12.a" \
97 "$plug_opt" "-O2 -flto" \
98 {lto-12c.c} {} "liblto-12.a"] \
99 [list "Compile 12" \
100 "" "-O2 -flto" \
101 {lto-12a.c lto-12b.c} {} ""] \
102 [list "Compile 13" \
103 "" "-O2 -flto" \
104 {lto-13a.c lto-13b.c} {} ""] \
105 [list "Build liblto-13.a" \
106 "" "-O2" \
107 {lto-13c.c} {} "liblto-13.a"] \
108 [list "Compile 14a" \
109 "" "-flto" \
110 {lto-14a.c lto-14b.c} {} ""] \
111 [list "Build liblto-14.a" \
112 "$plug_opt" "-flto" \
113 {lto-14c.c} {} "liblto-14.a"] \
114 [list "Compile 15a" \
115 "" "-flto" \
116 {lto-15a.c} {} ""] \
117 [list "Build liblto-15.a" \
118 "$plug_opt" "-flto" \
119 {lto-15b.c} {} "liblto-15.a"] \
120 [list "PR ld/12696" \
121 "-O2 -flto -fuse-linker-plugin -r -nostdlib" "-O2 -flto" \
122 {pr12696-1.cc} {} "pr12696-1r.o" "c++"] \
123 [list "Compile PR ld/12758" \
124 "" "" \
125 {pr12758a.s} {} ""] \
126 [list "Build libpr12758.a" \
127 "" "-flto -O2 $lto_fat $NOSANITIZE_CFLAGS" \
128 {pr12758b.c} {} "libpr12758.a"] \
129 [list "PR ld/12758" \
130 "$NOPIE_LDFLAGS $NOSANITIZE_CFLAGS -O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin tmpdir/pr12758a.o -Wl,--start-group tmpdir/libpr12758.a -Wl,--end-group -Wl,--no-error-execstack" \
131 "$NOSANITIZE_CFLAGS" \
132 {dummy.c} {} "pr12758.exe"] \
133 [list "Build libpr13183.a" \
134 "-T" "-flto -O2 $lto_fat -finline" \
135 {pr13183a.c} {} "libpr13183.a"] \
136 [list "Compile PR ld/13183" \
137 "" "-flto -O2 -finline" \
138 {pr13183b.c} {} ""] \
139 [list "Compile PR ld/13201" \
140 "" "-flto -O2" \
141 {pr13201.c} {} ""] \
142 [list "PR ld/13287" \
143 "-flto -fuse-linker-plugin -Wl,--as-needed" "-flto" \
144 {pr13287.cc} {} "pr13287.exe" "c++"] \
145 [list "PR ld/15323 (1)" \
146 "" "-O2" \
147 {pr15323a.c} {} "" "c"] \
148 [list "PR ld/15323 (2)" \
149 "-O2 -flto -r -nostdlib" "-O2 -flto" \
150 {pr15323a.c} {} "pr15323a-r.o" "c"] \
151 [list "Compile(1) PR ld/pr16846" \
152 "" "-flto" \
153 {pr16846a.c pr16846b.c} {} ""] \
154 [list "Compile(2) PR ld/pr16846" \
155 "" "" \
156 {pr16846c.c} {} ""] \
157 [list "PR ld/pr16846(1)" \
158 "-flto -fuse-linker-plugin tmpdir/pr16846a.o tmpdir/pr16846b.o tmpdir/pr16846c.o" "" \
159 {dummy.c} {} "pr16846a.exe"] \
160 [list "PR ld/pr16846(2)" \
161 "-flto -fuse-linker-plugin tmpdir/pr16846a.o tmpdir/pr16846c.o tmpdir/pr16846b.o" "" \
162 {dummy.c} {} "pr16846b.exe"] \
163 [list "PR ld/19317 (1)" \
164 "$plug_opt" "-flto $lto_no_fat" \
165 {pr19317.c} {} "libpr19317.a"] \
166 [list "Build pr20276a.o" \
167 "" "-fno-lto -fcommon" \
168 {pr20276a.c}] \
169 [list "Build pr20276b.o" \
170 "$plug_opt" "-flto $lto_no_fat -fcommon" \
171 {pr20276b.c}] \
172 [list "Build pr20267a.o" \
173 "" "-fcommon" \
174 {pr20267a.c}] \
175 [list "Build libpr20267a.a" \
176 "$plug_opt" "-flto $lto_fat -fcommon" \
177 {pr20267b.c} {} "libpr20267a.a"] \
178 [list "Build libpr20267b.a" \
179 "$plug_opt" "-flto $lto_no_fat -fcommon" \
180 {pr20267b.c} {} "libpr20267b.a"] \
181 [list "Build pr20321" \
182 "-flto -Wl,-plugin,$plug_so" "-flto" \
183 {pr20321.c} {{warning ".*: duplicated plugin"}} \
184 "pr20321" "c"] \
185 [list "Build pr22502a.o" \
186 "" "" \
187 {pr22502a.c}] \
188 [list "Build pr22502b.o" \
189 "$plug_opt" "-flto $lto_no_fat" \
190 {pr22502b.c}] \
191 [list "Build pr22751.a" \
192 "$plug_opt" "-flto $lto_no_fat $INT128_CFLAGS" \
193 {pr22751.c} {} "pr22751.a"] \
194 [list "Build pr24406-2b.o" \
195 "" "-O2 -fno-lto" \
196 {pr24406-2b.c}] \
197 [list "Build pr26163a.o" \
198 "" "-O2 -fno-lto" \
199 {pr26163a.c}] \
200 [list "Build pr26262b.o" \
201 "" "-O2" \
202 {pr26262b.c} {} "" "c"] \
203 [list "Build pr26262c.o" \
204 "" "-O2" \
205 {pr26262c.c} {} "" "c"] \
206 [list "Build pr26267a.o" \
207 "" "-O2 -flto $lto_no_fat" \
208 {pr26267a.c} {} "" "c"] \
209 [list "Build pr26267b.o" \
210 "" "-O2" \
211 {pr26267b.c} {} "" "c"] \
212 [list "Build pr26267c.o" \
213 "" "-O2" \
214 {pr26267c.c} {} "" "c"] \
215 [list "Build pr26267a" \
216 "" "-O2" \
217 {pr26267a.c} {} "" "c"] \
218 [list "Build pr26267a" \
219 "-flto tmpdir/pr26267a.o tmpdir/pr26267b.o tmpdir/pr26267c.o" \
220 "-flto $lto_no_fat" \
221 {dummy.c} \
222 {{error_output "pr26267.err"}} \
223 "pr26267a"] \
224 [list "Build pr26267b" \
225 "-flto tmpdir/pr26267b.o tmpdir/pr26267c.o tmpdir/pr26267a.o" \
226 "-flto $lto_no_fat" \
227 {dummy.c} \
228 {{error_output "pr26267.err"}} \
229 "pr26267b"] \
230 [list "Build pr26389.o" \
231 "$plug_opt" "-flto $lto_no_fat -fcommon" \
232 {pr26389.c} \
233 [list [list "nm" "$plug_opt" "pr26389.d"]]] \
236 if { [at_least_gcc_version 10 0] && [check_lto_shared_available] } {
237 set lto_link_tests [concat $lto_link_tests [list \
238 [list "pr25355.o" \
239 "" \
240 "-flto -fno-common $lto_no_fat" \
241 {pr25355.c} \
242 [list [list "nm" "$plug_opt" "pr25355.d"]]] \
243 [list "pr28264.so" \
244 "-shared -Wl,--version-script=pr28264.ver" \
245 "-flto $lto_no_fat -fPIC" \
246 {pr28264.c} \
247 {{readelf {--dyn-syms --wide} pr28264-1.d} \
248 {readelf {--dyn-syms --wide} pr28264-2.d} \
249 {readelf {--dyn-syms --wide} pr28264-3.d} \
250 {readelf {--dyn-syms --wide} pr28264-4.d}} \
251 {pr28264.so}] \
255 if { [at_least_gcc_version 4 7] } {
256 set lto_link_tests [concat $lto_link_tests [list \
257 [list "Compile PR ld/12942 (1)" \
258 "" "-flto -O2" \
259 {pr12942a.cc pr12942c.cc} {} "" "c++"] \
260 [list "Compile PR ld/12942 (2)" \
261 "" "-O0" \
262 {pr12942b.cc} {} "" "c++"] \
266 set lto_compile_elf_tests [list \
267 [list "Compile 7" \
268 "" "-flto -O2" \
269 {lto-7a.c lto-7b.c lto-7c.c} {} ""] \
270 [list "Compile 8a" \
271 "" "-O2" \
272 {lto-8a.c} {} ""] \
273 [list "Compile 8b" \
274 "" "-flto -O2" \
275 {lto-8b.c} {} ""] \
276 [list "PR ld/23309" \
277 "-O2 -flto -fuse-linker-plugin -fvisibility=hidden -ffunction-sections -Wl,--gc-sections,-u,KeepMe" \
278 "-O2 -flto -fuse-linker-plugin -fvisibility=hidden -ffunction-sections" \
279 {pr23309.c} {{"nm" {} "pr23309.d"}} "pr23309.exe" "c"] \
282 # Generate input files for complex LTO tests for ELF.
283 set lto_link_elf_tests [list \
284 [list "LTO 6" \
285 "-O2 -flto -fuse-linker-plugin" "" \
286 {lto-6.c} {} "lto-6.exe" "c"] \
287 [list "Build liblto-7.so" \
288 "-shared" "-O2 -fpic" \
289 {lto-7d.c} {} "liblto-7.so" "c"] \
290 [list "Build liblto-17a.so" \
291 "-shared -O2 -fpic -flto -fuse-linker-plugin" "-O2 -fpic -flto -finline" \
292 {lto-17a.c} {{"nm" {} "lto-17a.d"}} "liblto-17a.so" "c"] \
293 [list "Build liblto-17b.so 1" \
294 "-shared -O2 -fpic -flto -fuse-linker-plugin tmpdir/lto-17a.o" "-O2 -fpic -flto -finline" \
295 {lto-17b.c} {{"nm" {} "lto-17b-1.d"}} "liblto-17b.so"] \
296 [list "Build liblto-17b.so 2" \
297 "-shared -O2 -fpic -flto -fuse-linker-plugin tmpdir/lto-17a.o" "-O2 -fpic -flto" \
298 {lto-17b.c} {{"nm" {} "lto-17b-2.d"}} "liblto-17b.so"] \
299 [list "Compile PR ld/12760" \
300 "" "-g -O0" \
301 {pr12760a.c} {} ""] \
302 [list "Build libpr12760.a" \
303 "" "-flto -O2 $lto_fat" \
304 {pr12760b.c} {} "libpr12760.a"] \
305 [list "PR ld/12760" \
306 "-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin tmpdir/pr12760a.o -Wl,--start-group tmpdir/libpr12760.a -Wl,--end-group" "" \
307 {dummy.c} {{warning {pr12760a.c:6:\(.*\): warning: Bad \.?bar}}} \
308 "pr12760.exe" "c"] \
309 [list "PR ld/12975" \
310 "-shared -O2 -fPIC -flto -fuse-linker-plugin -nostdlib -Wl,-version-script,pr12975.t" "-O2 -flto" \
311 {pr12975.c} {{"readelf" {-s --wide} "pr12975.d"}} "pr12975.so" "c"] \
312 [list "PR ld/13229" \
313 "-shared -O2 -fPIC -flto -fuse-linker-plugin -nostdlib" "-O2 -finline -fno-early-inlining -flto" \
314 {pr13229.cc} {{"readelf" {-s --wide} "pr13229.d"}} "pr13229.so" "c++"] \
315 [list "PR ld/13244" \
316 "-shared -O2 -fPIC -flto -fuse-linker-plugin -nostdlib" "-O2 -fno-early-inlining -flto" \
317 {pr13244.c} {{"readelf" {-s --wide} "pr13244.d"}} "pr13244.so" "c"] \
318 [list "Build libpr15146a.a" \
319 "$plug_opt" "-flto -O2" \
320 {pr15146a.c} {} "lib15146a.a"] \
321 [list "Build pr15146b.so" \
322 "-shared" "-O2 -fpic" \
323 {pr15146b.c} {} "pr15146b.so" "c"] \
324 [list "Build pr15146c.so" \
325 "-shared -Wl,--no-as-needed tmpdir/pr15146b.so" "-O2 -fpic $no_lto" \
326 {pr15146c.c} {} "pr15146c.so" "c"] \
327 [list "PR ld/15146 (1)" \
328 "-O2 -flto -fuse-linker-plugin -Wl,-rpath-link,. -Wl,--no-copy-dt-needed-entries -Wl,--no-as-needed tmpdir/pr15146a.o tmpdir/pr15146c.so" "" \
329 {dummy.c} {{"readelf" {-d} "pr15146.d"}} "pr15146a.exe"] \
330 [list "Build libpr15146d.a" \
331 "$plug_opt" "-flto -O2" \
332 {pr15146d.c} {} "lib15146d.a"] \
333 [list "Build libpr16746a.a" \
334 "" "" \
335 {pr16746a.c pr16746b.c} {} "lib15146a.a"] \
336 [list "Build libpr16746b.a" \
337 "$plug_opt" "-O2 -flto" \
338 {pr16746c.c pr16746d.c} {} "lib15146b.a"] \
339 [list "PR ld/16746 (1)" \
340 "-O2 -flto -fuse-linker-plugin tmpdir/pr16746a.o tmpdir/pr16746c.o" "-O2 -flto" \
341 {dummy.c} {} "pr16746a.exe"] \
342 [list "PR ld/16746 (2)" \
343 "-O2 -flto -fuse-linker-plugin tmpdir/pr16746c.o tmpdir/pr16746a.o" "-O2 -flto" \
344 {dummy.c} {} "pr16746b.exe"] \
345 [list "Build pr21382a.o" \
346 "" "-O2 -flto" \
347 {pr21382a.c} {} "" "c"] \
348 [list "Build pr21382.so" \
349 "-shared" "-O2 -fpic" \
350 {pr21382b.c} {} "pr21382.so" "c"] \
351 [list {Build pr22220lib.so} \
352 {-shared -Wl,--version-script=pr22220lib.ver} {-fPIC} \
353 {pr22220lib.cc} {} {pr22220lib.so} {c++}] \
354 [list {Build pr22220main.o} \
355 {} {-flto} \
356 {pr22220main.cc} {} {} {c++}] \
357 [list "Build libpr23818.so" \
358 "-shared -flto -g -Wl,-version-script,pr23818.t" \
359 "-g -flto $lto_fat" \
360 {pr23818a.c pr23818b.c} \
361 {{"readelf" {-s --wide} "pr23818.d"}} \
362 "libpr23818.so"] \
363 [list "Build libpr23958.so" \
364 "-shared -flto -Wl,-version-script,pr23958.t" \
365 "-g -flto $lto_fat" \
366 {pr23958.c} \
367 "" \
368 "libpr23958.so"] \
369 [list "Build pr24486a.o" \
370 "$plug_opt" "-flto -O2" \
371 {pr24486a.c} {} "" "c"] \
372 [list "Build pr24486b.so" \
373 "-shared" "-O2 -fpic" \
374 {pr24486b.c} {} "pr24486b.so" "c"] \
375 [list "Build pr24486c.so" \
376 "-shared -Wl,--no-as-needed tmpdir/pr24486b.so" "-O2 -fpic" \
377 {pr24486c.c} {} "pr24486c.so" "c"] \
378 [list "PR ld/24486" \
379 "-O2 -flto tmpdir/pr24486a.o tmpdir/pr24486c.so -Wl,--as-needed tmpdir/pr24486b.so" "" \
380 {dummy.c} {} "pr24486.exe"] \
381 [list "Build pr25593a-1.o" \
382 "$plug_opt" "-flto -O2" \
383 {pr25593a-1.c} {} "" "c"] \
384 [list "Build pr25593a-2.o" \
385 "" "-O2" \
386 {pr25593a-2.c} {} "" "c"] \
387 [list "Build pr25593b.o" \
388 "" "-O2" \
389 {pr25593b.c} {} "" "c"] \
390 [list "Build pr25593c.so" \
391 "-shared" "-O2 -fpic" \
392 {pr25593c.c} {} "pr25593c.so" "c"] \
393 [list "Build pr25593d.so" \
394 "-shared" "-O2 -fpic" \
395 {pr25593d.c} {} "pr25593d.so" "c"] \
396 [list "Build pr25593e.so" \
397 "-shared" "-O2 -fpic" \
398 {pr25593e.c} {} "pr25593e.so" "c"] \
399 [list "PR ld/r25593 (LTO)" \
400 "-O2 -flto -Wl,--as-needed tmpdir/pr25593a-1.o tmpdir/pr25593b.o \
401 tmpdir/pr25593c.so tmpdir/pr25593d.so tmpdir/pr25593e.so" "" \
402 {dummy.c} {{readelf {-d --wide} pr25593.d}} "pr25593a.exe"] \
403 [list "PR ld/r25593" \
404 "-O2 -flto -Wl,--as-needed tmpdir/pr25593a-2.o tmpdir/pr25593b.o \
405 tmpdir/pr25593c.so tmpdir/pr25593d.so tmpdir/pr25593e.so" "" \
406 {dummy.c} {{readelf {-d --wide} pr25593.d}} "pr25593b.exe"] \
407 [list "Build pr25618a.o" \
408 "$plug_opt" "-O2 -flto -fpic" \
409 {pr25618a.cc} {} "" "c++"] \
410 [list "Build pr25618.a" \
411 "$plug_opt" "-O2 -flto -fpic" \
412 {pr25618b.cc} {} "pr25618.a" "c++"] \
413 [list "Build pr25618.so" \
414 "-shared -Wl,--exclude-libs,ALL tmpdir/pr25618a.o tmpdir/pr25618.a" \
415 "-fpic" \
416 {dummy.c} {{readelf {--dyn-syms --wide} pr25618.d}} "pr25618.so" "c++"] \
417 [list {liblto-18b.so} \
418 {-shared} {-O2 -fpic} \
419 {lto-18b.c} {} {liblto-18b.so}] \
420 [list {liblto-18b.a} \
421 "$plug_opt" {-flto -O2} \
422 {lto-18b.c} {} {liblto-18b.a}] \
423 [list {liblto-18c.so} \
424 {-shared} {-O2 -fpic} \
425 {lto-18c.c} {} {liblto-18c.so}] \
426 [list {liblto-18c.a} \
427 "$plug_opt" {-flto -O2} \
428 {lto-18c.c} {} {liblto-18c.a}] \
429 [list {lto-18d.o} \
430 {} {-flto -O2} \
431 {lto-18d.c} {} {}] \
432 [list {liblto-19.a} \
433 "$plug_opt" {-flto -O2 -fPIC} \
434 {lto-19a.c} {} {liblto-19.a}] \
435 [list {compile lto-19b.c} \
436 "$plug_opt" {-flto -O2 -fPIC} \
437 {lto-19b.c} {} {} {c}] \
438 [list {liblto-19.so} \
439 {-shared tmpdir/lto-19b.o tmpdir/liblto-19.a} {-O2 -fPIC} \
440 {dummy.c} {} {liblto-19.so}] \
441 [list {pr26806.so} \
442 {-shared} {-fpic -O2 -flto} \
443 {pr26806.c} {{nm {-D} pr26806.d}} {pr26806.so}] \
444 [list {pr27311a.so} \
445 {-shared -Wl,--version-script=pr27311.ver} {-fPIC} \
446 {pr27311a.c} {} {pr27311a.so}] \
447 [list {pr27311b.so} \
448 {-shared -Wl,--no-as-needed tmpdir/pr27311a.so} {-fPIC} \
449 {pr27311b.c} {} {pr27311b.so}] \
450 [list {pr27311c.o} \
451 {} {-flto} \
452 {pr27311c.c} {} {} {c}] \
453 [list {pr27311d.o} \
454 {} {-flto} \
455 {pr27311d.c} {} {} {c}] \
456 [list {pr27311-1} \
457 {tmpdir/pr27311c.o -Wl,--no-as-needed,--rpath-link=. tmpdir/pr27311b.so} {} \
458 {dummy.c} {{readelf {--dyn-syms --wide} pr27311.d}} {pr27311-1}] \
459 [list {pr27311-2} \
460 {tmpdir/pr27311d.o -Wl,--no-as-needed,--rpath-link=. tmpdir/pr27311b.so} {} \
461 {dummy.c} {{readelf {--dyn-syms --wide} pr27311.d}} {pr27311-2}] \
462 [list {pr27441a.so} \
463 {-shared} {-fPIC} \
464 {pr27441a.c} {} {pr27441a.so}] \
465 [list {pr27441b.so} \
466 {-shared} {-fPIC} \
467 {pr27441b.c} {} {pr27441b.so}] \
468 [list {pr27441c.o} \
469 {} {-fPIC -flto} \
470 {pr27441c.c} {} {}] \
471 [list {pr27441c.so} \
472 {-shared -fPIC -Wl,--as-needed tmpdir/pr27441c.o tmpdir/pr27441b.so tmpdir/pr27441a.so} {-fPIC} \
473 {dummy.c} {{readelf {-dW} pr27441c.d}} {pr27441c.so}] \
474 [list \
475 "Build libpr28879a.so" \
476 "-shared" \
477 "-O0 -fpic" \
478 {pr28879a.cc} \
479 {} \
480 "libpr28879a.so" \
481 "c++" \
483 [list \
484 "Build libpr28879b.so" \
485 "-shared -Wl,--no-as-needed tmpdir/libpr28879a.so" \
486 "-O2 -fpic" \
487 {dummy.c} \
488 {} \
489 "libpr28879b.so" \
491 [list \
492 "Build pr28879" \
493 "-Wl,--no-as-needed tmpdir/libpr28879b.so -Wl,-rpath-link,." \
494 "-O0 -flto -D_GLIBCXX_ASSERTIONS" \
495 {pr28879b.cc} \
496 {} \
497 "pr28879" \
498 "c++" \
500 [list \
501 "Build libpr28849a.so" \
502 "-shared" \
503 "-fPIC" \
504 {pr28849a.c} \
505 "" \
506 "libpr28849a.so" \
508 [list \
509 "Build libpr28849b.so" \
510 "-shared -Wl,--no-as-needed,tmpdir/libpr28849a.so" \
511 "" \
512 {dummy.c} \
513 "" \
514 "libpr28849b.so" \
516 [list \
517 "Build pr28849" \
518 "-Wl,--no-as-needed,--copy-dt-needed-entries,-rpath-link,. \
519 tmpdir/libpr28849b.so" \
520 "-O2 -flto" \
521 {pr28849b.c} \
522 {{"nm" {-D} "pr28849.d"}} \
523 "pr28849" \
525 [list \
526 "PR ld/pr29086" \
527 "-Wl,--wrap=foo" \
528 "-O0 -flto" \
529 {pr29086.c} \
530 {} \
531 "pr29086" \
533 [list \
534 "Build pr30281.so" \
535 "-shared -Wl,--version-script,pr30281.t \
536 -O2 -fPIC -flto-partition=max -flto=2" \
537 "-O2 -fPIC -flto-partition=max -flto=2" \
538 {pr30281.c} \
539 "" \
540 "pr30281.so" \
544 # PR 14918 checks that libgcc is not spuriously included in a shared link of
545 # an empty program. The ARM crt1.o startup code however calls __libc_csu_init
546 # in /usr/lib/libc_nonshared.a(elf-init.oS). This in turn needs
547 # __aeabi_unwind_cpp_pr0@@GCC_3.5 which is provided by libgcc_s.so.1, so the
548 # test fails. Hence this code to skip the test.
549 if { ! [istarget "arm*-*-*"] } {
550 lappend lto_link_elf_tests \
551 [list "PR ld/14918" \
552 "-flto" "-flto" \
553 {pr14918.c} {{"readelf" {-d --wide} "pr14918.d"}} "pr14918.exe" "c"]
556 # PR 12982 checks that an executable stack is not created by default
557 # when using the LTO plugin. The HPPA target however requires an
558 # executable stack for syscall restarts and signal returns, so we
559 # skip this test for that target.
560 if { ! [istarget "hppa*-*-*"] } {
561 lappend lto_link_elf_tests \
562 [list "PR ld/12982" \
563 "-O2 -flto -fuse-linker-plugin" "-O2 -flto" \
564 {pr12982.c} {{"readelf" {-l --wide} "pr12982.d"}} "pr12982.exe"]
567 # Check final symbols in executables.
568 set lto_link_symbol_tests [list \
569 [list "LTO 3 symbol" \
570 "-O2 -flto -fuse-linker-plugin tmpdir/lto-3a.o tmpdir/lto-3c.o tmpdir/liblto-3.a" "" \
571 {dummy.c} {{"nm" {} "lto-3.d"}} "lto-3.exe" "c"] \
572 [list "LTO 5 symbol" \
573 "-O2 -flto -fuse-linker-plugin tmpdir/lto-5.o" "" \
574 {dummy.c} {{"nm" {} "lto-5.d"}} "lto-5.exe" "c"] \
575 [list "LTO 9 symbol" \
576 "-O2 -flto -fuse-linker-plugin tmpdir/lto-9.o" "" \
577 {dummy.c} {{"nm" {-C} "lto-9.d"}} "lto-9.exe" "c++"] \
578 [list "LTO 16a symbol" \
579 "-O2 $NOSANITIZE_CFLAGS -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin" \
580 "-flto $NOSANITIZE_CFLAGS" \
581 {lto-16a.c} {{"nm" {} "lto-16a.d"}} "lto-16.exe" "c"] \
582 [list "LTO 16b symbol" \
583 "-O2 $NOSANITIZE_CFLAGS -Wl,-e,foo -u bar -nostdlib -flto -fuse-linker-plugin" \
584 "-flto $NOSANITIZE_CFLAGS" \
585 {lto-16a.c lto-16b.c} {{"nm" {} "lto-16b.d"}} "lto-16b.exe" "c"] \
586 [list "PR ld/13183" \
587 "-O2 -flto -fuse-linker-plugin tmpdir/pr13183b.o tmpdir/libpr13183.a" "" \
588 {dummy.c} {{"nm" {} "pr13183.d"}} "pr13183.exe" "c"] \
591 # LTO run-time tests.
592 set lto_run_tests [list \
593 [list "LTO 3a" \
594 "-O2 -flto -fuse-linker-plugin tmpdir/lto-3a.o tmpdir/lto-3c.o tmpdir/liblto-3.a" "" \
595 {dummy.c} "lto-3b.exe" "lto-3.out" "" "c"] \
596 [list "LTO 3b" \
597 "-O2 -flto -fuse-linker-plugin tmpdir/lto-3a.o tmpdir/lto-3c.o tmpdir/lto-3.o" "" \
598 {dummy.c} "lto-3c.exe" "lto-3.out" "" "c"] \
599 [list "LTO 3c" \
600 "-O2 -flto -fuse-linker-plugin tmpdir/lto-3a.o tmpdir/lto-3c.o -Wl,--whole-archive tmpdir/liblto-3.a -Wl,--no-whole-archive tmpdir/liblto-3.a" "" \
601 {dummy.c} "lto-3d.exe" "lto-3.out" "" "c"] \
602 [list "LTO 5" \
603 "-O2 -flto -fuse-linker-plugin tmpdir/lto-5.o" "" \
604 {dummy.c} "lto-5.exe" "lto-5.out" "" "c"] \
605 [list "LTO 11" \
606 "-O -flto -fuse-linker-plugin tmpdir/liblto-11.a" "" \
607 {dummy.c} "lto-11.exe" "lto-11.out" "" "c"] \
608 [list "LTO 12a" \
609 "-O -flto -fuse-linker-plugin tmpdir/lto-12a.o tmpdir/liblto-12.a tmpdir/lto-12b.o" "" \
610 {dummy.c} "lto-12a.exe" "lto-12.out" "" "c"] \
611 [list "LTO 12b" \
612 "-O -flto -fuse-linker-plugin tmpdir/lto-12a.o tmpdir/lto-12b.o tmpdir/liblto-12.a" "" \
613 {dummy.c} "lto-12b.exe" "lto-12.out" "" "c"] \
614 [list "LTO 13" \
615 "-O -flto -fuse-linker-plugin tmpdir/lto-13a.o tmpdir/liblto-13.a tmpdir/lto-13b.o" "" \
616 {dummy.c} "lto-13.exe" "lto-13.out" "" "c"] \
617 [list "LTO 14" \
618 "-O2 -flto -fuse-linker-plugin tmpdir/lto-14a.o -Wl,--whole-archive tmpdir/liblto-14.a -Wl,--no-whole-archive tmpdir/lto-14b.o" "" \
619 {dummy.c} "lto-14.exe" "lto-14.out" "" "c"] \
620 [list "LTO 15" \
621 "-O2 -flto -fuse-linker-plugin -Wl,--start-group tmpdir/liblto-15.a tmpdir/lto-15a.o -Wl,--end-group" "" \
622 {dummy.c} "lto-15.exe" "lto-15.out" "" "c"] \
623 [list "PR ld/13066" \
624 "-O2 -flto -fuse-linker-plugin" "" \
625 {pr13066.cc} "pr13066.exe" "pr13066.out" "" "c++"] \
626 [list "PR ld/13201" \
627 "-O2 -flto -fuse-linker-plugin -Wl,--as-needed tmpdir/pr13201.o -lm" "" \
628 {dummy.c} "pr13201.exe" "pr13201.out" "" "c"] \
629 [list "PR ld/15323 (3)" \
630 "-O2 -flto -fuse-linker-plugin tmpdir/pr15323a.o" "" \
631 {pr15323b.c} "pr15323.exe" "pr15323.out" "-flto -O2" "c"] \
632 [list "PR ld/15323 (4)" \
633 "-O2 -flto tmpdir/pr15323a-r.o" "" \
634 {dummy.c} "pr15323a.exe" "pr15323.out" "-flto -O2" "c"] \
635 [list "PR ld/19317 (3)" \
636 "-O2 -flto tmpdir/pr19317-r.o" "" \
637 {dummy.c} "pr19317.exe" "pr19317.out" "-flto -O2" "c"] \
638 [list "Run pr20276" \
639 "-O2 -flto tmpdir/pr20276a.o tmpdir/pr20276b.o" "" \
640 {dummy.c} "pr20276" "pass.out" "-flto -O2" "c"] \
641 [list "Run pr20267a" \
642 "-O2 -flto -fcommon tmpdir/pr20267a.o tmpdir/libpr20267a.a" "" \
643 {dummy.c} "pr20267a" "pass.out" "-flto -O2 -fcommon" "c"] \
644 [list "Run pr20267b" \
645 "-O2 -flto -fcommon tmpdir/pr20267a.o tmpdir/libpr20267b.a" "" \
646 {dummy.c} "pr20267b" "pass.out" "-flto -O2 -fcommon" "c"] \
647 [list "Run pr22502" \
648 "-O2 -flto tmpdir/pr22502a.o tmpdir/pr22502b.o" "" \
649 {dummy.c} "pr20267" "pass.out" "-flto -O2 -fcommon" "c"] \
650 [list "Run pr22751" \
651 "-O2 -flto" "" \
652 {dummy.c} "pr22751" "pass.out" "-flto -O2" "c" "" \
653 "-Wl,--whole-archive tmpdir/pr22751.a -Wl,--no-whole-archive"] \
654 [list "Run pr24406-1" \
655 "-O2 -flto" "" \
656 {pr24406-1.c} "pr24406-1" "pass.out" "-flto -O2" "c" "" \
657 "-Wl,--wrap=read"] \
658 [list "Run pr24406-2" \
659 "-O2 -flto" "" \
660 {pr24406-2a.c} "pr24406-2" "pass.out" \
661 "-flto -O2" "c" "" \
662 "tmpdir/pr24406-2b.o -Wl,--wrap=cook"] \
663 [list "Run pr26163" \
664 "-O2 -flto" "" \
665 {pr26163b.c} "pr24406-2" "pass.out" \
666 "-flto -O2" "c" "" \
667 "tmpdir/pr26163a.o -Wl,--defsym,g=real_g"] \
668 [list "Run pr26262a" \
669 "-O2 -flto" "" \
670 {pr26262a.c} "pr26262a" "pass.out" \
671 "-flto -O2" "c" "" \
672 "tmpdir/pr26262b.o tmpdir/pr26262c.o"] \
673 [list "Run pr26262b" \
674 "-flto -O2 tmpdir/pr26262b.o tmpdir/pr26262c.o" "" \
675 {pr26262a.c} "pr26262b" "pass.out" \
676 "-flto -O2" "c" "" \
677 ""] \
680 if { [at_least_gcc_version 4 7] } {
681 set lto_run_tests [concat $lto_run_tests [list \
682 [list "PR ld/12942 (1)" \
683 "-O2 -flto -fuse-linker-plugin tmpdir/pr12942a.o tmpdir/pr12942b.o" "" \
684 {dummy.c} "pr12942a.exe" "pr12942.out" "" "c++"] \
685 [list "PR ld/12942 (2)" \
686 "-O2 -flto -fuse-linker-plugin tmpdir/pr12942a.o tmpdir/pr12942c.o" "" \
687 {dummy.c} "pr12942c.exe" "pr12942.out" "" "c++"] \
691 # LTO run-time tests for ELF which require shared library support.
692 set lto_run_elf_shared_tests [list \
693 [list "LTO 7" \
694 "-O2 -flto -fuse-linker-plugin tmpdir/lto-7b.o tmpdir/lto-7c.o tmpdir/lto-7a.o -Wl,--no-as-needed tmpdir/liblto-7.so" "" \
695 {dummy.c} "lto-7.exe" "lto-7.out" "" "c"] \
696 [list "Run pr21382" \
697 "-O2 -flto -fuse-linker-plugin -Wl,--as-needed tmpdir/pr21382a.o tmpdir/pr21382.so" "" \
698 {dummy.c} "pr21382.exe" "pass.out" "" "c"] \
699 [list {pr22220a} \
700 {-flto -fuse-linker-plugin tmpdir/pr22220main.o tmpdir/pr22220lib.so} {} \
701 {dummy.c} {pr22220a.exe} {pass.out} {} {c++}] \
702 [list {pr22220b} \
703 {-flto -fuse-linker-plugin -Wl,--no-as-needed tmpdir/pr22220lib.so tmpdir/pr22220main.o} {} \
704 {dummy.c} {pr22220b.exe} {pass.out} {} {c++}] \
705 [list {lto-18 (1)} \
706 {-flto -fuse-linker-plugin} {} \
707 {lto-18a.c} {lto-18-1.exe} {lto-18.out} {-flto -O2} {c} {} \
708 {tmpdir/lto-18d.o -Wl,--as-needed,-R,tmpdir -Ltmpdir -llto-18b -llto-18c}] \
709 [list {lto-18 (2)} \
710 {-flto -fuse-linker-plugin} {} \
711 {lto-18a.c} {lto-18-2.exe} {lto-18.out} {-flto -O2} {c} {} \
712 {-Wl,--as-needed,-R,tmpdir -Ltmpdir -llto-18b -llto-18c tmpdir/lto-18d.o}] \
713 [list {lto-18 (3)} \
714 {-static -flto -fuse-linker-plugin} {} \
715 {lto-18a.c} {lto-18-3.exe} {lto-18.out} {-flto -O2} {c} {} \
716 {tmpdir/lto-18d.o -Ltmpdir -llto-18b -llto-18c}] \
717 [list {lto-18 (4)} \
718 {-static -flto -fuse-linker-plugin} {} \
719 {lto-18a.c} {lto-18-4.exe} {lto-18.out} {-flto -O2} {c} {} \
720 { -Ltmpdir -llto-18b -llto-18c tmpdir/lto-18d.o}] \
721 [list {lto-19} \
722 {-Wl,--as-needed,-R,tmpdir} {} \
723 {lto-19c.c} {lto-19.exe} {pass.out} {-flto -O2} {c} {} \
724 {tmpdir/liblto-19.so tmpdir/liblto-19.a}] \
727 # LTO run-time tests for ELF
728 set lto_run_elf_tests [list \
729 [list "LTO 8" \
730 "-O2 -flto -fuse-linker-plugin tmpdir/lto-8b.o tmpdir/lto-8a.o" "" \
731 {dummy.c} "lto-8.exe" "lto-8.out" "" "c"] \
732 [list "LTO TLS IE" \
733 "-O2 -flto -fuse-linker-plugin" "" \
734 {run-ie.c} "run-ie.exe" "run-ie.out" "" "c"] \
737 run_cc_link_tests $lto_link_tests
739 # These compilation tests generate intermediate object files which will be used
740 # by some elf tests besides shared libs tests. So, always compile them.
741 run_cc_link_tests $lto_compile_elf_tests
743 # Restrict these to ELF targets that support shared libs and PIC.
744 if { [is_elf_format] && [check_lto_shared_available] } {
745 run_cc_link_tests $lto_link_elf_tests
746 set testname "PR ld/15146 (2)"
747 set exec_output [run_host_cmd "$CC_FOR_TARGET" "-O2 -flto -fuse-linker-plugin -Wl,-rpath-link,. -Wl,--no-copy-dt-needed-entries -Wl,--no-as-needed tmpdir/pr15146d.o tmpdir/pr15146c.so"]
748 if { [ regexp "undefined reference to symbol '\\.?xxx'" $exec_output ] } {
749 pass $testname
751 fail $testname
753 set testname "PR ld/16746 (3)"
754 set exec_output [run_host_cmd "$CC_FOR_TARGET" "-O2 -flto -fuse-linker-plugin tmpdir/pr16746b.o tmpdir/pr16746d.o"]
755 if { [ regexp "warning: \\.?foobar" $exec_output ] && ![ regexp "symbol from plugin" $exec_output ] } {
756 pass $testname
758 fail $testname
760 set testname "PR ld/16746 (4)"
761 set exec_output [run_host_cmd "$CC_FOR_TARGET" "-O2 -flto -fuse-linker-plugin tmpdir/pr16746d.o tmpdir/pr16746b.o"]
762 if { [ regexp "warning: \\.?foobar" $exec_output ] && ![ regexp "symbol from plugin" $exec_output ] } {
763 pass $testname
765 fail $testname
769 run_cc_link_tests [list \
770 [list \
771 "Build pr28138.a" \
772 "-T" "" \
773 {pr28138-1.c pr28138-2.c pr28138-3.c pr28138-4.c pr28138-5.c \
774 pr28138-6.c pr28138-7.c} {} "pr28138.a" \
776 [list \
777 "Build pr28138.o" \
778 "" "" \
779 {pr28138.c} {} \
783 set exec_output [run_host_cmd "sh" \
784 "-c \"ulimit -n 20; \
785 $CC_FOR_TARGET $gcc_B_opt $CFLAGS_FOR_TARGET \
786 $ld_L_opt -o tmpdir/pr28138 \
787 tmpdir/pr28138.o tmpdir/pr28138.a\""]
788 set exec_output [prune_warnings $exec_output]
789 if [string match "" $exec_output] then {
790 if { [isnative] } {
791 set exec_output [run_host_cmd "tmpdir/pr28138" ""]
792 if [string match "PASS" $exec_output] then {
793 pass "PR ld/28138 (build & run)"
794 } else {
795 fail "PR ld/28138 (built ok, run failed)"
797 } else {
798 pass "PR ld/28138 (build only)"
800 } else {
801 fail "PR ld/28138 (build only)"
804 set testname "Build liblto-11.a"
805 remote_file host delete "tmpdir/liblto-11.a"
806 set catch_output [run_host_cmd "$ar" "rc $plug_opt tmpdir/liblto-11.a tmpdir/lto-11a.o tmpdir/lto-11b.o tmpdir/lto-11c.o"]
807 if {![string match "" $catch_output]} {
808 fail $testname
809 restore_notify
810 return
813 if { [at_least_gcc_version 4 7] } {
814 # Check expected LTO linker errors.
815 # Since the asm symbol name hack in pr12365b.c doesn't work on all
816 # targets, run PR ld/12365 tests only for known targets.
817 if { ([istarget "i?86-*-elf*"]
818 || [istarget "i?86-*-linux*"]
819 || [istarget "i?86-*-gnu*"]
820 || [istarget "x86_64-*-linux*"]
821 || [istarget "amd64-*-linux*"]) } {
822 set testname "PR ld/12365"
823 set exec_output [run_host_cmd "$CC_FOR_TARGET" "-O2 -flto -flto-partition=none -fuse-linker-plugin -o tmpdir/pr12365 tmpdir/pr12365a.o tmpdir/pr12365b.o tmpdir/pr12365c.o"]
824 set exec_output [prune_warnings $exec_output]
825 if { [ regexp "undefined reference to `my_bcopy'" $exec_output ] } {
826 # Linker should catch the reference to undefined `my_bcopy'
827 # error caused by a GCC bug.
828 pass $testname
829 } elseif { [ string match "" $exec_output ] } {
830 global READELF
831 set exec_output [run_host_cmd "$READELF" "-s -W tmpdir/pr12365"]
832 if { [ regexp "my_bcopy" $exec_output ] } {
833 # Verify that there is no `my_bcopy' symbol in executable.
834 fail $testname
836 pass $testname
839 fail $testname
842 run_cc_link_tests [list \
843 [list \
844 "Build pr22721a.so" \
845 "-shared $NOSANITIZE_CFLAGS -nostdlib -nostartfiles \
846 -Wl,-version-script,pr22721.t" \
847 "" \
848 {pr22721a.s} \
849 {} \
850 "pr22721a.so" \
852 [list \
853 "Build pr22721b.o" \
854 "$plug_opt $NOSANITIZE_CFLAGS" \
855 "-O2 -fPIC -flto $lto_no_fat" \
856 {pr22721b.c} \
858 [list \
859 "Build PR ld/pr22721" \
860 "-O2 -flto -fuse-linker-plugin -nostdlib -nostartfiles \
861 $NOSANITIZE_CFLAGS \
862 -Wl,-e,_start tmpdir/pr22721b.o tmpdir/pr22721a.so" \
863 "$NOSANITIZE_CFLAGS" \
864 {dummy.c} \
865 {} \
866 "pr22721.exe"
870 set testname "PR ld/12942 (3)"
871 set exec_output [run_host_cmd "$CXX_FOR_TARGET" "-O2 -flto -fuse-linker-plugin tmpdir/pr12942b.o tmpdir/pr12942a.o"]
872 if { [ regexp "undefined reference to `\\.?link_error\\(\\)'" $exec_output ] } {
873 pass $testname
875 fail $testname
878 run_cc_link_tests [list \
879 [list \
880 "Build pr23460*.o" \
881 "$plug_opt" \
882 "-O2 -fPIC -flto $lto_no_fat" \
883 {pr23460a.c pr23460b.c pr23460c.c \
884 pr23460d.c pr23460e.c pr23460f.c} \
887 set exec_output [run_host_cmd "sh" \
888 "-c \"ulimit -n 20; \
889 $ar -rc $plug_opt \
890 tmpdir/libpr23460.a \
891 tmpdir/pr23460a.o \
892 tmpdir/pr23460b.o \
893 tmpdir/pr23460c.o \
894 tmpdir/pr23460d.o \
895 tmpdir/pr23460e.o \
896 tmpdir/pr23460f.o\""]
897 set exec_output [prune_warnings $exec_output]
898 if [string match "" $exec_output] then {
899 pass "PR binutils/23460"
900 } else {
901 fail "PR binutils/23460"
903 set exec_output [run_host_cmd "$RANLIB" "$plug_opt tmpdir/libpr23460.a"]
904 set exec_output [prune_warnings $exec_output]
905 if [string match "" $exec_output] then {
906 pass "PR binutils/23460"
907 } else {
908 fail "PR binutils/23460"
912 # Run "ld -r" to generate inputs for complex LTO tests.
913 run_dump_test "lto-3r"
914 remote_exec host "mv" "tmpdir/dump tmpdir/lto-3.o"
915 run_dump_test "lto-5r"
916 remote_exec host "mv" "tmpdir/dump tmpdir/lto-5.o"
918 run_cc_link_tests $lto_link_symbol_tests
920 run_ld_link_tests [list \
921 [list "PR ld/19317 (2)" \
922 "-r tmpdir/pr19317.o --no-error-execstack" "" "" \
923 {dummy.s} {} "pr19317-r.o"] \
926 run_ld_link_exec_tests $lto_run_tests
928 if { [is_elf_format] } {
929 run_ld_link_exec_tests $lto_run_elf_tests
931 # Note - it is not guaranteed that the ordering of symbols in the dynamic
932 # symbol table will match the ordering of the symbols specified by the
933 # --dynamic-list command line option.
935 # For PR22983 we want to make sure that all four symbols specified in
936 # pr222983.t are present in the output, but a simple sequences of regexps
937 # will not work as we do not know the order of the symbols. (Readelf
938 # does not have a symbol sorting option and the run_cc_list_tests proc
939 # does not allow for the output of the dump program to piped into `sort`).
941 # So instead we run readelf four times, each time checking for the
942 # presence of a specific symbol from the pr22983.t file.
943 run_cc_link_tests [list \
944 [list \
945 "Build pr22983" \
946 "-Wl,--dynamic-list,pr22983.t" \
947 "-flto" \
948 {pr22983a.c pr22983b.c} \
949 {{readelf {--dyn-syms --wide} pr22983.1.d} \
950 {readelf {--dyn-syms --wide} pr22983.2.d} \
951 {readelf {--dyn-syms --wide} pr22983.3.d} \
952 {readelf {--dyn-syms --wide} pr22983.4.d}} \
953 "pr22983" \
958 if { [is_elf_format] && [check_lto_shared_available] } {
959 run_ld_link_exec_tests $lto_run_elf_shared_tests
962 proc pr20103 {cflags libs} {
963 global CC_FOR_TARGET
965 set testname "PR ld/20103 ($cflags $libs)"
966 set exec_output [run_host_cmd "$CC_FOR_TARGET" "$cflags $libs"]
967 if { [ regexp "undefined reference to `\\.?dead'" $exec_output ] } {
968 pass "$testname (1)"
970 fail "$testname (1)"
972 if { [ regexp "plugin needed to handle lto object" $exec_output ] } {
973 fail "$testname (2)"
975 pass "$testname (2)"
979 if { [check_lto_fat_available] } {
980 run_cc_link_tests [list \
981 [list \
982 "Build fatpr20103a.a" \
983 "$plug_opt" "-flto -ffat-lto-objects" \
984 {pr20103a.c} {} "fatpr20103a.a"
986 [list \
987 "Build fatpr20103b.a" \
988 "$plug_opt" "-flto -ffat-lto-objects" \
989 {pr20103b.c} {} "fatpr20103b.a"
991 [list \
992 "Build fatpr20103c.a" \
993 "$plug_opt" "-flto -ffat-lto-objects" \
994 {pr20103c.c} {} "fatpr20103c.a" \
996 [list \
997 "Build thinpr20103a.a" \
998 "$plug_opt" "-flto -fno-fat-lto-objects" \
999 {pr20103a.c} {} "thinpr20103a.a"
1001 [list \
1002 "Build thinpr20103b.a" \
1003 "$plug_opt" "-flto -fno-fat-lto-objects" \
1004 {pr20103b.c} {} "thinpr20103b.a"
1006 [list \
1007 "Build thinpr20103c.a" \
1008 "$plug_opt" "-flto -fno-fat-lto-objects" \
1009 {pr20103c.c} {} "thinpr20103c.a" \
1011 [list \
1012 "Build pr20103a" \
1013 "-O2 -flto -Wl,--start-group tmpdir/thinpr20103a.a tmpdir/thinpr20103b.a tmpdir/thinpr20103c.a -Wl,--end-group" \
1014 "-O2 -flto" \
1015 {dummy.c} {} "pr20103a" \
1017 [list \
1018 "Build pr20103b" \
1019 "-O2 -flto -Wl,--start-group tmpdir/fatpr20103a.a tmpdir/fatpr20103b.a tmpdir/fatpr20103c.a -Wl,--end-group" \
1020 "-O2 -flto" \
1021 {dummy.c} {} "pr20103b" \
1023 [list \
1024 "Build pr20103c" \
1025 "-O2 -Wl,--start-group tmpdir/fatpr20103a.a tmpdir/fatpr20103b.a tmpdir/fatpr20103c.a -Wl,--end-group" \
1026 "-O2" \
1027 {dummy.c} {} "pr20103c" \
1030 pr20103 "-O2 -flto" "tmpdir/thinpr20103a.a tmpdir/thinpr20103b.a tmpdir/thinpr20103c.a"
1031 pr20103 "-O2 -flto" "tmpdir/fatpr20103a.a tmpdir/fatpr20103b.a tmpdir/fatpr20103c.a"
1032 pr20103 "-O2" "tmpdir/fatpr20103a.a tmpdir/fatpr20103b.a tmpdir/fatpr20103c.a"
1034 if { [at_least_gcc_version 4 9] } {
1035 run_cc_link_tests [list \
1036 [list \
1037 "Build pr20103d" \
1038 "-O2 -Wl,--start-group tmpdir/thinpr20103a.a tmpdir/thinpr20103b.a tmpdir/thinpr20103c.a -Wl,--end-group" \
1039 "-O2" \
1040 {dummy.c} {} "pr20103d" \
1043 pr20103 "-O2" "tmpdir/thinpr20103a.a tmpdir/thinpr20103b.a tmpdir/thinpr20103c.a"
1047 restore_notify