1 # Expect script for ld-plugin LTO tests
2 # Copyright (C) 2011-2017 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,
21 # Check to see if the C and C++ compilers work
22 if { [which $CC] == 0 || [which $CXX] == 0 } {
26 # These tests require plugin and LTO.
27 if { ![check_plugin_api_available]
28 || ![check_lto_available] } {
34 set saved_CFLAGS "$CFLAGS"
35 set saved_CXXFLAGS "$CXXFLAGS"
36 regsub -all "(\\-Wp,)?-D_FORTIFY_SOURCE=\[0-9\]+" $CFLAGS "" CFLAGS
37 regsub -all "(\\-Wp,)?-D_FORTIFY_SOURCE=\[0-9\]+" $CXXFLAGS "" CXXFLAGS
39 proc restore_notify { } {
42 set CFLAGS "$saved_CFLAGS"
43 set CXXFLAGS "$saved_CXXFLAGS"
52 foreach plug $plugin_names {
53 set plug_so [run_host_cmd $CC "--print-prog-name $plug"]
54 if { $plug_so eq $plug } then {
55 set plug_so [run_host_cmd $CC "--print-file-name $plug"]
57 if { $plug_so ne $plug } then {
58 set plug_opt "--plugin $plug_so"
64 if { [check_lto_fat_available] } {
65 set lto_fat "-ffat-lto-objects"
66 set lto_no_fat "-fno-fat-lto-objects"
69 # Simple LTO tests and generate input files for complex LTO tests.
70 set lto_link_tests [list \
72 "-O2 -flto -fuse-linker-plugin" "-flto -fuse-linker-plugin" \
73 {lto-1a.c lto-1b.c} {} "lto-1.exe"] \
75 "" "-O2 -flto -fuse-linker-plugin" \
78 "-static -O2 -flto -fuse-linker-plugin tmpdir/lto-2.o -lm" "" \
79 {dummy.c} {} "lto-2.exe"] \
86 [list "Build liblto-3.a" \
88 {lto-3b.c} {} "liblto-3.a"] \
96 "-O2 -flto -fuse-linker-plugin" "" \
97 {lto-6.c} {} "lto-6.exe" "c"] \
98 [list "Compile PR ld/12365" \
99 "" "-flto -O2 $lto_fat" \
100 {pr12365a.c pr12365b.c pr12365c.c} {} ""] \
102 "" "-O2 -finline -flto" \
103 {lto-9.cc} {} "" "c++"] \
104 [list "Compile 11a" \
107 [list "Compile 11b" \
110 [list "Compile 11c" \
113 [list "Build liblto-12.a" \
114 "$plug_opt" "-O2 -flto" \
115 {lto-12c.c} {} "liblto-12.a"] \
118 {lto-12a.c lto-12b.c} {} ""] \
121 {lto-13a.c lto-13b.c} {} ""] \
122 [list "Build liblto-13.a" \
124 {lto-13c.c} {} "liblto-13.a"] \
125 [list "Compile 14a" \
127 {lto-14a.c lto-14b.c} {} ""] \
128 [list "Build liblto-14.a" \
129 "$plug_opt" "-flto" \
130 {lto-14c.c} {} "liblto-14.a"] \
131 [list "Compile 15a" \
134 [list "Build liblto-15.a" \
135 "$plug_opt" "-flto" \
136 {lto-15b.c} {} "liblto-15.a"] \
137 [list "PR ld/12696" \
138 "-O2 -flto -fuse-linker-plugin -r -nostdlib" "-O2 -flto" \
139 {pr12696-1.cc} {} "pr12696-1r.o" "c++"] \
140 [list "Compile PR ld/12758" \
142 {pr12758a.s} {} ""] \
143 [list "Build libpr12758.a" \
144 "" "-flto -O2 $lto_fat" \
145 {pr12758b.c} {} "libpr12758.a"] \
146 [list "PR ld/12758" \
147 "-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin tmpdir/pr12758a.o -Wl,--start-group tmpdir/libpr12758.a -Wl,--end-group" "" \
148 {dummy.c} {} "pr12758.exe"] \
149 [list "Compile PR ld/12760" \
151 {pr12760a.c} {} ""] \
152 [list "Build libpr12760.a" \
153 "" "-flto -O2 $lto_fat" \
154 {pr12760b.c} {} "libpr12760.a"] \
155 [list "PR ld/12760" \
156 "-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin tmpdir/pr12760a.o -Wl,--start-group tmpdir/libpr12760.a -Wl,--end-group" "" \
157 {dummy.c} {{warning "pr12760a.c:6: warning: Bad \\.?bar"}} \
159 [list "Build libpr13183.a" \
160 "-T" "-flto -O2 $lto_fat" \
161 {pr13183a.c} {} "libpr13183.a"] \
162 [list "Compile PR ld/13183" \
164 {pr13183b.c} {} ""] \
165 [list "Compile PR ld/13201" \
168 [list "PR ld/13287" \
169 "-flto -fuse-linker-plugin -Wl,--as-needed" "-flto" \
170 {pr13287.cc} {} "pr13287.exe" "c++"] \
171 [list "PR ld/15323 (1)" \
173 {pr15323a.c} {} "" "c"] \
174 [list "PR ld/15323 (2)" \
175 "-O2 -flto -r -nostdlib" "-O2 -flto" \
176 {pr15323a.c} {} "pr15323a-r.o" "c"] \
177 [list "Compile(1) PR ld/pr16846" \
179 {pr16846a.c pr16846b.c} {} ""] \
180 [list "Compile(2) PR ld/pr16846" \
182 {pr16846c.c} {} ""] \
183 [list "PR ld/pr16846(1)" \
184 "-flto -fuse-linker-plugin tmpdir/pr16846a.o tmpdir/pr16846b.o tmpdir/pr16846c.o" "" \
185 {dummy.c} {} "pr16846a.exe"] \
186 [list "PR ld/pr16846(2)" \
187 "-flto -fuse-linker-plugin tmpdir/pr16846a.o tmpdir/pr16846c.o tmpdir/pr16846b.o" "" \
188 {dummy.c} {} "pr16846b.exe"] \
189 [list "PR ld/19317 (1)" \
190 "$plug_opt" "-flto $lto_no_fat" \
191 {pr19317.c} {} "libpr19317.a"] \
192 [list "Build pr20276a.o" \
195 [list "Build pr20276b.o" \
196 "$plug_opt" "-flto $lto_no_fat" \
198 [list "Build pr20267a.o" \
201 [list "Build libpr20267a.a" \
202 "$plug_opt" "-flto $lto_fat" \
203 {pr20267b.c} {} "libpr20267a.a"] \
204 [list "Build libpr20267b.a" \
205 "$plug_opt" "-flto $lto_no_fat" \
206 {pr20267b.c} {} "libpr20267b.a"] \
207 [list "Build pr20321" \
208 "-flto -Wl,-plugin,$plug_so" "-flto" \
209 {pr20321.c} {{warning ".*: duplicated plugin"}} \
211 [list "Build pr22502a.o" \
214 [list "Build pr22502b.o" \
215 "$plug_opt" "-flto $lto_no_fat" \
219 if { [at_least_gcc_version 4 7] } {
220 set lto_link_tests [concat $lto_link_tests [list \
221 [list "Compile PR ld/12942 (1)" \
223 {pr12942a.cc pr12942c.cc} {} "" "c++"] \
224 [list "Compile PR ld/12942 (2)" \
226 {pr12942b.cc} {} "" "c++"] \
230 set lto_compile_elf_tests [list \
233 {lto-7a.c lto-7b.c lto-7c.c} {} ""] \
242 # Generate input files for complex LTO tests for ELF.
243 set lto_link_elf_tests [list \
244 [list "Build liblto-7.so" \
245 "-shared" "-O2 -fpic" \
246 {lto-7d.c} {} "liblto-7.so" "c"] \
247 [list "Build liblto-17a.so" \
248 "-shared -O2 -fpic -flto -fuse-linker-plugin" "-O2 -fpic -flto" \
249 {lto-17a.c} {{"nm" {} "lto-17a.d"}} "liblto-17a.so" "c"] \
250 [list "Build liblto-17b.so 1" \
251 "-shared -O2 -fpic -flto -fuse-linker-plugin tmpdir/lto-17a.o" "-O2 -fpic -flto" \
252 {lto-17b.c} {{"nm" {} "lto-17b-1.d"}} "liblto-17b.so"] \
253 [list "Build liblto-17b.so 2" \
254 "-shared -O2 -fpic -flto -fuse-linker-plugin tmpdir/lto-17a.o" "-O2 -fpic -flto" \
255 {lto-17b.c} {{"nm" {} "lto-17b-2.d"}} "liblto-17b.so"] \
256 [list "PR ld/12982" \
257 "-O2 -flto -fuse-linker-plugin" "-O2 -flto" \
258 {pr12982.c} {{"readelf" {-l --wide} "pr12982.d"}} "pr12982.exe"] \
259 [list "PR ld/12975" \
260 "-shared -O2 -fPIC -flto -fuse-linker-plugin -nostdlib -Wl,-version-script,pr12975.t" "-O2 -flto" \
261 {pr12975.c} {{"readelf" {-s --wide} "pr12975.d"}} "pr12975.so" "c"] \
262 [list "PR ld/13229" \
263 "-shared -O2 -fPIC -flto -fuse-linker-plugin -nostdlib" "-O2 -finline -fno-early-inlining -flto" \
264 {pr13229.cc} {{"readelf" {-s --wide} "pr13229.d"}} "pr13229.so" "c++"] \
265 [list "PR ld/13244" \
266 "-shared -O2 -fPIC -flto -fuse-linker-plugin -nostdlib" "-O2 -fno-early-inlining -flto" \
267 {pr13244.c} {{"readelf" {-s --wide} "pr13244.d"}} "pr13244.so" "c"] \
268 [list "Build libpr15146a.a" \
269 "$plug_opt" "-flto -O2" \
270 {pr15146a.c} {} "lib15146a.a"] \
271 [list "Build pr15146b.so" \
272 "-shared" "-O2 -fpic" \
273 {pr15146b.c} {} "pr15146b.so" "c"] \
274 [list "Build pr15146c.so" \
275 "-shared -Wl,--no-as-needed tmpdir/pr15146b.so" "-O2 -fpic" \
276 {pr15146c.c} {} "pr15146c.so" "c"] \
277 [list "PR ld/15146 (1)" \
278 "-O2 -flto -fuse-linker-plugin -Wl,-rpath-link,. -Wl,--no-copy-dt-needed-entries -Wl,--no-as-needed tmpdir/pr15146a.o tmpdir/pr15146c.so" "" \
279 {dummy.c} {{"readelf" {-d} "pr15146.d"}} "pr15146a.exe"] \
280 [list "Build libpr15146d.a" \
281 "$plug_opt" "-flto -O2" \
282 {pr15146d.c} {} "lib15146d.a"] \
283 [list "Build libpr16746a.a" \
285 {pr16746a.c pr16746b.c} {} "lib15146a.a"] \
286 [list "Build libpr16746b.a" \
287 "$plug_opt" "-O2 -flto" \
288 {pr16746c.c pr16746d.c} {} "lib15146b.a"] \
289 [list "PR ld/16746 (1)" \
290 "-O2 -flto -fuse-linker-plugin tmpdir/pr16746a.o tmpdir/pr16746c.o" "-O2 -flto" \
291 {dummy.c} {} "pr16746a.exe"] \
292 [list "PR ld/16746 (2)" \
293 "-O2 -flto -fuse-linker-plugin tmpdir/pr16746c.o tmpdir/pr16746a.o" "-O2 -flto" \
294 {dummy.c} {} "pr16746b.exe"] \
295 [list "Build pr21382a.o" \
297 {pr21382a.c} {} "" "c"] \
298 [list "Build pr21382.so" \
299 "-shared" "-O2 -fpic" \
300 {pr21382b.c} {} "pr21382.so" "c"] \
301 [list {Build pr22220lib.so} \
302 {-shared -Wl,--version-script=pr22220lib.ver} {-fPIC} \
303 {pr22220lib.cc} {} {pr22220lib.so} {c++}] \
304 [list {Build pr22220main.o} \
306 {pr22220main.cc} {} {} {c++}] \
309 # PR 14918 checks that libgcc is not spuriously included in a shared link of
310 # an empty program. The ARM crt1.o startup code however calls __libc_csu_init
311 # in /usr/lib/libc_nonshared.a(elf-init.oS). This in turn needs
312 # __aeabi_unwind_cpp_pr0@@GCC_3.5 which is provided by libgcc_s.so.1, so the
313 # test fails. Hence this code to skip the test.
314 if { ! [istarget "arm*-*-*"] } {
315 set lto_link_elf_tests [concat $lto_link_elf_tests [list \
316 [list "PR ld/14918" \
318 {pr14918.c} {{"readelf" {-d --wide} "pr14918.d"}} "pr14918.exe" "c"] \
322 # Check final symbols in executables.
323 set lto_link_symbol_tests [list \
324 [list "LTO 3 symbol" \
325 "-O2 -flto -fuse-linker-plugin tmpdir/lto-3a.o tmpdir/lto-3c.o tmpdir/liblto-3.a" "" \
326 {dummy.c} {{"nm" {} "lto-3.d"}} "lto-3.exe" "c"] \
327 [list "LTO 5 symbol" \
328 "-O2 -flto -fuse-linker-plugin tmpdir/lto-5.o" "" \
329 {dummy.c} {{"nm" {} "lto-5.d"}} "lto-5.exe" "c"] \
330 [list "LTO 9 symbol" \
331 "-O2 -flto -fuse-linker-plugin tmpdir/lto-9.o" "" \
332 {dummy.c} {{"nm" {-C} "lto-9.d"}} "lto-9.exe" "c++"] \
333 [list "LTO 16a symbol" \
334 "-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin" "-flto" \
335 {lto-16a.c} {{"nm" {} "lto-16a.d"}} "lto-16.exe" "c"] \
336 [list "LTO 16b symbol" \
337 "-O2 -Wl,-e,foo -u bar -nostdlib -flto -fuse-linker-plugin" "-flto" \
338 {lto-16a.c lto-16b.c} {{"nm" {} "lto-16b.d"}} "lto-16b.exe" "c"] \
339 [list "PR ld/13183" \
340 "-O2 -flto -fuse-linker-plugin tmpdir/pr13183b.o tmpdir/libpr13183.a" "" \
341 {dummy.c} {{"nm" {} "pr13183.d"}} "pr13183.exe" "c"] \
344 # LTO run-time tests.
345 set lto_run_tests [list \
347 "-O2 -flto -fuse-linker-plugin tmpdir/lto-3a.o tmpdir/lto-3c.o tmpdir/liblto-3.a" "" \
348 {dummy.c} "lto-3b.exe" "lto-3.out" "" "c"] \
350 "-O2 -flto -fuse-linker-plugin tmpdir/lto-3a.o tmpdir/lto-3c.o tmpdir/lto-3.o" "" \
351 {dummy.c} "lto-3c.exe" "lto-3.out" "" "c"] \
353 "-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" "" \
354 {dummy.c} "lto-3d.exe" "lto-3.out" "" "c"] \
356 "-O2 -flto -fuse-linker-plugin tmpdir/lto-5.o" "" \
357 {dummy.c} "lto-5.exe" "lto-5.out" "" "c"] \
359 "-O -flto -fuse-linker-plugin tmpdir/liblto-11.a" "" \
360 {dummy.c} "lto-11.exe" "lto-11.out" "" "c"] \
362 "-O -flto -fuse-linker-plugin tmpdir/lto-12a.o tmpdir/liblto-12.a tmpdir/lto-12b.o" "" \
363 {dummy.c} "lto-12a.exe" "lto-12.out" "" "c"] \
365 "-O -flto -fuse-linker-plugin tmpdir/lto-12a.o tmpdir/lto-12b.o tmpdir/liblto-12.a" "" \
366 {dummy.c} "lto-12b.exe" "lto-12.out" "" "c"] \
368 "-O -flto -fuse-linker-plugin tmpdir/lto-13a.o tmpdir/liblto-13.a tmpdir/lto-13b.o" "" \
369 {dummy.c} "lto-13.exe" "lto-13.out" "" "c"] \
371 "-O2 -flto -fuse-linker-plugin tmpdir/lto-14a.o -Wl,--whole-archive tmpdir/liblto-14.a -Wl,--no-whole-archive tmpdir/lto-14b.o" "" \
372 {dummy.c} "lto-14.exe" "lto-14.out" "" "c"] \
374 "-O2 -flto -fuse-linker-plugin -Wl,--start-group tmpdir/liblto-15.a tmpdir/lto-15a.o -Wl,--end-group" "" \
375 {dummy.c} "lto-15.exe" "lto-15.out" "" "c"] \
376 [list "PR ld/13066" \
377 "-O2 -flto -fuse-linker-plugin" "" \
378 {pr13066.cc} "pr13066.exe" "pr13066.out" "" "c++"] \
379 [list "PR ld/13201" \
380 "-O2 -flto -fuse-linker-plugin -Wl,--as-needed tmpdir/pr13201.o -lm" "" \
381 {dummy.c} "pr13201.exe" "pr13201.out" "" "c"] \
382 [list "PR ld/15323 (3)" \
383 "-O2 -flto -fuse-linker-plugin tmpdir/pr15323a.o" "" \
384 {pr15323b.c} "pr15323.exe" "pr15323.out" "-flto -O2" "c"] \
385 [list "PR ld/15323 (4)" \
386 "-O2 -flto tmpdir/pr15323a-r.o" "" \
387 {dummy.c} "pr15323a.exe" "pr15323.out" "-flto -O2" "c"] \
388 [list "PR ld/19317 (3)" \
389 "-O2 -flto tmpdir/pr19317-r.o" "" \
390 {dummy.c} "pr19317.exe" "pr19317.out" "-flto -O2" "c"] \
391 [list "Run pr20276" \
392 "-O2 -flto tmpdir/pr20276a.o tmpdir/pr20276b.o" "" \
393 {dummy.c} "pr20276" "pass.out" "-flto -O2" "c"] \
394 [list "Run pr20267a" \
395 "-O2 -flto tmpdir/pr20267a.o tmpdir/libpr20267a.a" "" \
396 {dummy.c} "pr20267a" "pass.out" "-flto -O2" "c"] \
397 [list "Run pr20267b" \
398 "-O2 -flto tmpdir/pr20267a.o tmpdir/libpr20267b.a" "" \
399 {dummy.c} "pr20267b" "pass.out" "-flto -O2" "c"] \
400 [list "Run pr22502" \
401 "-O2 -flto tmpdir/pr22502a.o tmpdir/pr22502b.o" "" \
402 {dummy.c} "pr20267" "pass.out" "-flto -O2" "c"] \
405 if { [at_least_gcc_version 4 7] } {
406 set lto_run_tests [concat $lto_run_tests [list \
407 [list "PR ld/12942 (1)" \
408 "-O2 -flto -fuse-linker-plugin tmpdir/pr12942a.o tmpdir/pr12942b.o" "" \
409 {dummy.c} "pr12942a.exe" "pr12942.out" "" "c++"] \
410 [list "PR ld/12942 (2)" \
411 "-O2 -flto -fuse-linker-plugin tmpdir/pr12942a.o tmpdir/pr12942c.o" "" \
412 {dummy.c} "pr12942c.exe" "pr12942.out" "" "c++"] \
416 # LTO run-time tests for ELF which require shared library support.
417 set lto_run_elf_shared_tests [list \
419 "-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" "" \
420 {dummy.c} "lto-7.exe" "lto-7.out" "" "c"] \
421 [list "Run pr21382" \
422 "-O2 -flto -fuse-linker-plugin -Wl,--as-needed tmpdir/pr21382a.o tmpdir/pr21382.so" "" \
423 {dummy.c} "pr21382.exe" "pass.out" "" "c"] \
425 {-flto -fuse-linker-plugin tmpdir/pr22220main.o tmpdir/pr22220lib.so} {} \
426 {dummy.c} {pr22220a.exe} {pass.out} {} {c++}] \
428 {-flto -fuse-linker-plugin -Wl,--no-as-needed tmpdir/pr22220lib.so tmpdir/pr22220main.o} {} \
429 {dummy.c} {pr22220b.exe} {pass.out} {} {c++}] \
432 # LTO run-time tests for ELF
433 set lto_run_elf_tests [list \
435 "-O2 -flto -fuse-linker-plugin tmpdir/lto-8b.o tmpdir/lto-8a.o" "" \
436 {dummy.c} "lto-8.exe" "lto-8.out" "" "c"] \
438 "-O2 -flto -fuse-linker-plugin" "" \
439 {run-ie.c} "run-ie.exe" "run-ie.out" "" "c"] \
442 run_cc_link_tests $lto_link_tests
444 # These compilation tests generate intermediate object files which will be used
445 # by some elf tests besides shared libs tests. So, always compile them.
446 run_cc_link_tests $lto_compile_elf_tests
448 # Restrict these to ELF targets that support shared libs and PIC.
449 if { [is_elf_format] && [check_lto_shared_available] } {
450 run_cc_link_tests $lto_link_elf_tests
451 set testname "PR ld/15146 (2)"
452 set exec_output [run_host_cmd "$CC" "-O2 -flto -fuse-linker-plugin -Wl,-rpath-link,. -Wl,--no-copy-dt-needed-entries -Wl,--no-as-needed tmpdir/pr15146d.o tmpdir/pr15146c.so"]
453 if { [ regexp "undefined reference to symbol '\\.?xxx'" $exec_output ] } {
458 set testname "PR ld/16746 (3)"
459 set exec_output [run_host_cmd "$CC" "-O2 -flto -fuse-linker-plugin tmpdir/pr16746b.o tmpdir/pr16746d.o"]
460 if { [ regexp "warning: \\.?foobar" $exec_output ] && ![ regexp "symbol from plugin" $exec_output ] } {
465 set testname "PR ld/16746 (4)"
466 set exec_output [run_host_cmd "$CC" "-O2 -flto -fuse-linker-plugin tmpdir/pr16746d.o tmpdir/pr16746b.o"]
467 if { [ regexp "warning: \\.?foobar" $exec_output ] && ![ regexp "symbol from plugin" $exec_output ] } {
474 set testname "Build liblto-11.a"
475 remote_file host delete "tmpdir/liblto-11.a"
476 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"]
477 if {![string match "" $catch_output]} {
483 if { [at_least_gcc_version 4 7] } {
484 # Check expected LTO linker errors.
485 # Since the asm symbol name hack in pr12365b.c doesn't work on all
486 # targets, run PR ld/12365 tests only for known targets.
487 if { ([istarget "i?86-*-elf*"]
488 || (([istarget "i?86-*-linux*"] || [istarget "i?86-*-gnu*"])
489 && ![istarget "*-*-*aout*"]
490 && ![istarget "*-*-*oldld*"])
491 || [istarget "i?86-*-nacl*"]
492 || [istarget "x86_64-*-nacl*"]
493 || [istarget "x86_64-*-linux*"]
494 || [istarget "amd64-*-linux*"]) } {
495 set testname "PR ld/12365"
496 set exec_output [run_host_cmd "$CC" "-O2 -flto -flto-partition=none -fuse-linker-plugin -o tmpdir/pr12365 tmpdir/pr12365a.o tmpdir/pr12365b.o tmpdir/pr12365c.o"]
497 if { [ regexp "undefined reference to `my_bcopy'" $exec_output ] } {
498 # Linker should catch the reference to undefined `my_bcopy'
499 # error caused by a GCC bug.
501 } elseif { [ string match "" $exec_output ] } {
503 set exec_output [run_host_cmd "$READELF" "-s -W tmpdir/pr12365"]
504 if { [ regexp "my_bcopy" $exec_output ] } {
505 # Verify that there is no `my_bcopy' symbol in executable.
514 set testname "PR ld/12942 (3)"
515 set exec_output [run_host_cmd "$CXX" "-O2 -flto -fuse-linker-plugin tmpdir/pr12942b.o tmpdir/pr12942a.o"]
516 if { [ regexp "undefined reference to `\\.?link_error\\(\\)'" $exec_output ] } {
523 # Run "ld -r" to generate inputs for complex LTO tests.
524 run_dump_test "lto-3r"
525 remote_exec host "mv" "tmpdir/dump tmpdir/lto-3.o"
526 run_dump_test "lto-5r"
527 remote_exec host "mv" "tmpdir/dump tmpdir/lto-5.o"
529 run_cc_link_tests $lto_link_symbol_tests
531 run_ld_link_tests [list \
532 [list "PR ld/19317 (2)" \
533 "-r tmpdir/pr19317.o" "" "" \
534 {dummy.s} {} "pr19317-r.o"] \
537 run_ld_link_exec_tests $lto_run_tests
539 if { [is_elf_format] } {
540 run_ld_link_exec_tests $lto_run_elf_tests
543 if { [is_elf_format] && [check_lto_shared_available] } {
544 run_ld_link_exec_tests $lto_run_elf_shared_tests
547 proc pr20103 {cflags libs} {
550 set testname "PR ld/20103 ($cflags $libs)"
551 set exec_output [run_host_cmd "$CC" "$cflags $libs"]
552 if { [ regexp "undefined reference to `\\.?dead'" $exec_output ] } {
557 if { [ regexp "plugin needed to handle lto object" $exec_output ] } {
564 if { [check_lto_fat_available] } {
565 run_cc_link_tests [list \
567 "Build fatpr20103a.a" \
568 "$plug_opt" "-flto -ffat-lto-objects" \
569 {pr20103a.c} {} "fatpr20103a.a"
572 "Build fatpr20103b.a" \
573 "$plug_opt" "-flto -ffat-lto-objects" \
574 {pr20103b.c} {} "fatpr20103b.a"
577 "Build fatpr20103c.a" \
578 "$plug_opt" "-flto -ffat-lto-objects" \
579 {pr20103c.c} {} "fatpr20103c.a" \
582 "Build thinpr20103a.a" \
583 "$plug_opt" "-flto -fno-fat-lto-objects" \
584 {pr20103a.c} {} "thinpr20103a.a"
587 "Build thinpr20103b.a" \
588 "$plug_opt" "-flto -fno-fat-lto-objects" \
589 {pr20103b.c} {} "thinpr20103b.a"
592 "Build thinpr20103c.a" \
593 "$plug_opt" "-flto -fno-fat-lto-objects" \
594 {pr20103c.c} {} "thinpr20103c.a" \
598 "-O2 -flto -Wl,--start-group tmpdir/thinpr20103a.a tmpdir/thinpr20103b.a tmpdir/thinpr20103c.a -Wl,--end-group" \
600 {dummy.c} {} "pr20103a" \
604 "-O2 -flto -Wl,--start-group tmpdir/fatpr20103a.a tmpdir/fatpr20103b.a tmpdir/fatpr20103c.a -Wl,--end-group" \
606 {dummy.c} {} "pr20103b" \
610 "-O2 -Wl,--start-group tmpdir/fatpr20103a.a tmpdir/fatpr20103b.a tmpdir/fatpr20103c.a -Wl,--end-group" \
612 {dummy.c} {} "pr20103c" \
615 pr20103 "-O2 -flto" "tmpdir/thinpr20103a.a tmpdir/thinpr20103b.a tmpdir/thinpr20103c.a"
616 pr20103 "-O2 -flto" "tmpdir/fatpr20103a.a tmpdir/fatpr20103b.a tmpdir/fatpr20103c.a"
617 pr20103 "-O2" "tmpdir/fatpr20103a.a tmpdir/fatpr20103b.a tmpdir/fatpr20103c.a"
619 if { [at_least_gcc_version 4 9] } {
620 run_cc_link_tests [list \
623 "-O2 -Wl,--start-group tmpdir/thinpr20103a.a tmpdir/thinpr20103b.a tmpdir/thinpr20103c.a -Wl,--end-group" \
625 {dummy.c} {} "pr20103d" \
628 pr20103 "-O2" "tmpdir/thinpr20103a.a tmpdir/thinpr20103b.a tmpdir/thinpr20103c.a"