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