]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - ld/testsuite/ld-plugin/lto.exp
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-plugin / lto.exp
1 # Expect script for ld-plugin LTO tests
2 # Copyright (C) 2011-2022 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
22 if { ![check_compiler_available] || [which $CXX_FOR_TARGET] == 0 } {
23 return
24 }
25
26 # These tests require plugin and LTO.
27 if { ![check_plugin_api_available]
28 || ![check_lto_available] } {
29 return
30 }
31
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
36
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"
44 }
45
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"
52 }
53
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" \
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" \
131 "$NOSANITIZE_CFLAGS" \
132 {dummy.c} {} "pr12758.exe"] \
133 [list "Build libpr13183.a" \
134 "-T" "-flto -O2 $lto_fat" \
135 {pr13183a.c} {} "libpr13183.a"] \
136 [list "Compile PR ld/13183" \
137 "" "-flto -O2" \
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"]]] \
234 ]
235
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}] \
252 ]]
253 }
254
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++"] \
263 ]]
264 }
265
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"] \
280 ]
281
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" \
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" \
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 ]
475
476 # PR 14918 checks that libgcc is not spuriously included in a shared link of
477 # an empty program. The ARM crt1.o startup code however calls __libc_csu_init
478 # in /usr/lib/libc_nonshared.a(elf-init.oS). This in turn needs
479 # __aeabi_unwind_cpp_pr0@@GCC_3.5 which is provided by libgcc_s.so.1, so the
480 # test fails. Hence this code to skip the test.
481 if { ! [istarget "arm*-*-*"] } {
482 lappend lto_link_elf_tests \
483 [list "PR ld/14918" \
484 "-flto" "-flto" \
485 {pr14918.c} {{"readelf" {-d --wide} "pr14918.d"}} "pr14918.exe" "c"]
486 }
487
488 # PR 12982 checks that an executable stack is not created by default
489 # when using the LTO plugin. The HPPA target however requires an
490 # executable stack for syscall restarts and signal returns, so we
491 # skip this test for that target.
492 if { ! [istarget "hppa*-*-*"] } {
493 lappend lto_link_elf_tests \
494 [list "PR ld/12982" \
495 "-O2 -flto -fuse-linker-plugin" "-O2 -flto" \
496 {pr12982.c} {{"readelf" {-l --wide} "pr12982.d"}} "pr12982.exe"]
497 }
498
499 # Check final symbols in executables.
500 set lto_link_symbol_tests [list \
501 [list "LTO 3 symbol" \
502 "-O2 -flto -fuse-linker-plugin tmpdir/lto-3a.o tmpdir/lto-3c.o tmpdir/liblto-3.a" "" \
503 {dummy.c} {{"nm" {} "lto-3.d"}} "lto-3.exe" "c"] \
504 [list "LTO 5 symbol" \
505 "-O2 -flto -fuse-linker-plugin tmpdir/lto-5.o" "" \
506 {dummy.c} {{"nm" {} "lto-5.d"}} "lto-5.exe" "c"] \
507 [list "LTO 9 symbol" \
508 "-O2 -flto -fuse-linker-plugin tmpdir/lto-9.o" "" \
509 {dummy.c} {{"nm" {-C} "lto-9.d"}} "lto-9.exe" "c++"] \
510 [list "LTO 16a symbol" \
511 "-O2 $NOSANITIZE_CFLAGS -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin" \
512 "-flto $NOSANITIZE_CFLAGS" \
513 {lto-16a.c} {{"nm" {} "lto-16a.d"}} "lto-16.exe" "c"] \
514 [list "LTO 16b symbol" \
515 "-O2 $NOSANITIZE_CFLAGS -Wl,-e,foo -u bar -nostdlib -flto -fuse-linker-plugin" \
516 "-flto $NOSANITIZE_CFLAGS" \
517 {lto-16a.c lto-16b.c} {{"nm" {} "lto-16b.d"}} "lto-16b.exe" "c"] \
518 [list "PR ld/13183" \
519 "-O2 -flto -fuse-linker-plugin tmpdir/pr13183b.o tmpdir/libpr13183.a" "" \
520 {dummy.c} {{"nm" {} "pr13183.d"}} "pr13183.exe" "c"] \
521 ]
522
523 # LTO run-time tests.
524 set lto_run_tests [list \
525 [list "LTO 3a" \
526 "-O2 -flto -fuse-linker-plugin tmpdir/lto-3a.o tmpdir/lto-3c.o tmpdir/liblto-3.a" "" \
527 {dummy.c} "lto-3b.exe" "lto-3.out" "" "c"] \
528 [list "LTO 3b" \
529 "-O2 -flto -fuse-linker-plugin tmpdir/lto-3a.o tmpdir/lto-3c.o tmpdir/lto-3.o" "" \
530 {dummy.c} "lto-3c.exe" "lto-3.out" "" "c"] \
531 [list "LTO 3c" \
532 "-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" "" \
533 {dummy.c} "lto-3d.exe" "lto-3.out" "" "c"] \
534 [list "LTO 5" \
535 "-O2 -flto -fuse-linker-plugin tmpdir/lto-5.o" "" \
536 {dummy.c} "lto-5.exe" "lto-5.out" "" "c"] \
537 [list "LTO 11" \
538 "-O -flto -fuse-linker-plugin tmpdir/liblto-11.a" "" \
539 {dummy.c} "lto-11.exe" "lto-11.out" "" "c"] \
540 [list "LTO 12a" \
541 "-O -flto -fuse-linker-plugin tmpdir/lto-12a.o tmpdir/liblto-12.a tmpdir/lto-12b.o" "" \
542 {dummy.c} "lto-12a.exe" "lto-12.out" "" "c"] \
543 [list "LTO 12b" \
544 "-O -flto -fuse-linker-plugin tmpdir/lto-12a.o tmpdir/lto-12b.o tmpdir/liblto-12.a" "" \
545 {dummy.c} "lto-12b.exe" "lto-12.out" "" "c"] \
546 [list "LTO 13" \
547 "-O -flto -fuse-linker-plugin tmpdir/lto-13a.o tmpdir/liblto-13.a tmpdir/lto-13b.o" "" \
548 {dummy.c} "lto-13.exe" "lto-13.out" "" "c"] \
549 [list "LTO 14" \
550 "-O2 -flto -fuse-linker-plugin tmpdir/lto-14a.o -Wl,--whole-archive tmpdir/liblto-14.a -Wl,--no-whole-archive tmpdir/lto-14b.o" "" \
551 {dummy.c} "lto-14.exe" "lto-14.out" "" "c"] \
552 [list "LTO 15" \
553 "-O2 -flto -fuse-linker-plugin -Wl,--start-group tmpdir/liblto-15.a tmpdir/lto-15a.o -Wl,--end-group" "" \
554 {dummy.c} "lto-15.exe" "lto-15.out" "" "c"] \
555 [list "PR ld/13066" \
556 "-O2 -flto -fuse-linker-plugin" "" \
557 {pr13066.cc} "pr13066.exe" "pr13066.out" "" "c++"] \
558 [list "PR ld/13201" \
559 "-O2 -flto -fuse-linker-plugin -Wl,--as-needed tmpdir/pr13201.o -lm" "" \
560 {dummy.c} "pr13201.exe" "pr13201.out" "" "c"] \
561 [list "PR ld/15323 (3)" \
562 "-O2 -flto -fuse-linker-plugin tmpdir/pr15323a.o" "" \
563 {pr15323b.c} "pr15323.exe" "pr15323.out" "-flto -O2" "c"] \
564 [list "PR ld/15323 (4)" \
565 "-O2 -flto tmpdir/pr15323a-r.o" "" \
566 {dummy.c} "pr15323a.exe" "pr15323.out" "-flto -O2" "c"] \
567 [list "PR ld/19317 (3)" \
568 "-O2 -flto tmpdir/pr19317-r.o" "" \
569 {dummy.c} "pr19317.exe" "pr19317.out" "-flto -O2" "c"] \
570 [list "Run pr20276" \
571 "-O2 -flto tmpdir/pr20276a.o tmpdir/pr20276b.o" "" \
572 {dummy.c} "pr20276" "pass.out" "-flto -O2" "c"] \
573 [list "Run pr20267a" \
574 "-O2 -flto -fcommon tmpdir/pr20267a.o tmpdir/libpr20267a.a" "" \
575 {dummy.c} "pr20267a" "pass.out" "-flto -O2 -fcommon" "c"] \
576 [list "Run pr20267b" \
577 "-O2 -flto -fcommon tmpdir/pr20267a.o tmpdir/libpr20267b.a" "" \
578 {dummy.c} "pr20267b" "pass.out" "-flto -O2 -fcommon" "c"] \
579 [list "Run pr22502" \
580 "-O2 -flto tmpdir/pr22502a.o tmpdir/pr22502b.o" "" \
581 {dummy.c} "pr20267" "pass.out" "-flto -O2 -fcommon" "c"] \
582 [list "Run pr22751" \
583 "-O2 -flto" "" \
584 {dummy.c} "pr22751" "pass.out" "-flto -O2" "c" "" \
585 "-Wl,--whole-archive tmpdir/pr22751.a -Wl,--no-whole-archive"] \
586 [list "Run pr24406-1" \
587 "-O2 -flto" "" \
588 {pr24406-1.c} "pr24406-1" "pass.out" "-flto -O2" "c" "" \
589 "-Wl,--wrap=read"] \
590 [list "Run pr24406-2" \
591 "-O2 -flto" "" \
592 {pr24406-2a.c} "pr24406-2" "pass.out" \
593 "-flto -O2" "c" "" \
594 "tmpdir/pr24406-2b.o -Wl,--wrap=cook"] \
595 [list "Run pr26163" \
596 "-O2 -flto" "" \
597 {pr26163b.c} "pr24406-2" "pass.out" \
598 "-flto -O2" "c" "" \
599 "tmpdir/pr26163a.o -Wl,--defsym,g=real_g"] \
600 [list "Run pr26262a" \
601 "-O2 -flto" "" \
602 {pr26262a.c} "pr26262a" "pass.out" \
603 "-flto -O2" "c" "" \
604 "tmpdir/pr26262b.o tmpdir/pr26262c.o"] \
605 [list "Run pr26262b" \
606 "-flto -O2 tmpdir/pr26262b.o tmpdir/pr26262c.o" "" \
607 {pr26262a.c} "pr26262b" "pass.out" \
608 "-flto -O2" "c" "" \
609 ""] \
610 ]
611
612 if { [at_least_gcc_version 4 7] } {
613 set lto_run_tests [concat $lto_run_tests [list \
614 [list "PR ld/12942 (1)" \
615 "-O2 -flto -fuse-linker-plugin tmpdir/pr12942a.o tmpdir/pr12942b.o" "" \
616 {dummy.c} "pr12942a.exe" "pr12942.out" "" "c++"] \
617 [list "PR ld/12942 (2)" \
618 "-O2 -flto -fuse-linker-plugin tmpdir/pr12942a.o tmpdir/pr12942c.o" "" \
619 {dummy.c} "pr12942c.exe" "pr12942.out" "" "c++"] \
620 ]]
621 }
622
623 # LTO run-time tests for ELF which require shared library support.
624 set lto_run_elf_shared_tests [list \
625 [list "LTO 7" \
626 "-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" "" \
627 {dummy.c} "lto-7.exe" "lto-7.out" "" "c"] \
628 [list "Run pr21382" \
629 "-O2 -flto -fuse-linker-plugin -Wl,--as-needed tmpdir/pr21382a.o tmpdir/pr21382.so" "" \
630 {dummy.c} "pr21382.exe" "pass.out" "" "c"] \
631 [list {pr22220a} \
632 {-flto -fuse-linker-plugin tmpdir/pr22220main.o tmpdir/pr22220lib.so} {} \
633 {dummy.c} {pr22220a.exe} {pass.out} {} {c++}] \
634 [list {pr22220b} \
635 {-flto -fuse-linker-plugin -Wl,--no-as-needed tmpdir/pr22220lib.so tmpdir/pr22220main.o} {} \
636 {dummy.c} {pr22220b.exe} {pass.out} {} {c++}] \
637 [list {lto-18 (1)} \
638 {-flto -fuse-linker-plugin} {} \
639 {lto-18a.c} {lto-18-1.exe} {lto-18.out} {-flto -O2} {c} {} \
640 {tmpdir/lto-18d.o -Wl,--as-needed,-R,tmpdir -Ltmpdir -llto-18b -llto-18c}] \
641 [list {lto-18 (2)} \
642 {-flto -fuse-linker-plugin} {} \
643 {lto-18a.c} {lto-18-2.exe} {lto-18.out} {-flto -O2} {c} {} \
644 {-Wl,--as-needed,-R,tmpdir -Ltmpdir -llto-18b -llto-18c tmpdir/lto-18d.o}] \
645 [list {lto-18 (3)} \
646 {-static -flto -fuse-linker-plugin} {} \
647 {lto-18a.c} {lto-18-3.exe} {lto-18.out} {-flto -O2} {c} {} \
648 {tmpdir/lto-18d.o -Ltmpdir -llto-18b -llto-18c}] \
649 [list {lto-18 (4)} \
650 {-static -flto -fuse-linker-plugin} {} \
651 {lto-18a.c} {lto-18-4.exe} {lto-18.out} {-flto -O2} {c} {} \
652 { -Ltmpdir -llto-18b -llto-18c tmpdir/lto-18d.o}] \
653 [list {lto-19} \
654 {-Wl,--as-needed,-R,tmpdir} {} \
655 {lto-19c.c} {lto-19.exe} {pass.out} {-flto -O2} {c} {} \
656 {tmpdir/liblto-19.so tmpdir/liblto-19.a}] \
657 ]
658
659 # LTO run-time tests for ELF
660 set lto_run_elf_tests [list \
661 [list "LTO 8" \
662 "-O2 -flto -fuse-linker-plugin tmpdir/lto-8b.o tmpdir/lto-8a.o" "" \
663 {dummy.c} "lto-8.exe" "lto-8.out" "" "c"] \
664 [list "LTO TLS IE" \
665 "-O2 -flto -fuse-linker-plugin" "" \
666 {run-ie.c} "run-ie.exe" "run-ie.out" "" "c"] \
667 ]
668
669 run_cc_link_tests $lto_link_tests
670
671 # These compilation tests generate intermediate object files which will be used
672 # by some elf tests besides shared libs tests. So, always compile them.
673 run_cc_link_tests $lto_compile_elf_tests
674
675 # Restrict these to ELF targets that support shared libs and PIC.
676 if { [is_elf_format] && [check_lto_shared_available] } {
677 run_cc_link_tests $lto_link_elf_tests
678 set testname "PR ld/15146 (2)"
679 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"]
680 if { [ regexp "undefined reference to symbol '\\.?xxx'" $exec_output ] } {
681 pass $testname
682 } {
683 fail $testname
684 }
685 set testname "PR ld/16746 (3)"
686 set exec_output [run_host_cmd "$CC_FOR_TARGET" "-O2 -flto -fuse-linker-plugin tmpdir/pr16746b.o tmpdir/pr16746d.o"]
687 if { [ regexp "warning: \\.?foobar" $exec_output ] && ![ regexp "symbol from plugin" $exec_output ] } {
688 pass $testname
689 } {
690 fail $testname
691 }
692 set testname "PR ld/16746 (4)"
693 set exec_output [run_host_cmd "$CC_FOR_TARGET" "-O2 -flto -fuse-linker-plugin tmpdir/pr16746d.o tmpdir/pr16746b.o"]
694 if { [ regexp "warning: \\.?foobar" $exec_output ] && ![ regexp "symbol from plugin" $exec_output ] } {
695 pass $testname
696 } {
697 fail $testname
698 }
699 }
700
701 run_cc_link_tests [list \
702 [list \
703 "Build pr28138.a" \
704 "-T" "" \
705 {pr28138-1.c pr28138-2.c pr28138-3.c pr28138-4.c pr28138-5.c \
706 pr28138-6.c pr28138-7.c} {} "pr28138.a" \
707 ] \
708 [list \
709 "Build pr28138.o" \
710 "" "" \
711 {pr28138.c} {} \
712 ] \
713 ]
714
715 set exec_output [run_host_cmd "sh" \
716 "-c \"ulimit -n 20; \
717 $CC_FOR_TARGET -Btmpdir/ld -o tmpdir/pr28138 \
718 tmpdir/pr28138.o tmpdir/pr28138.a\""]
719 set exec_output [prune_warnings $exec_output]
720 if [string match "" $exec_output] then {
721 if { [isnative] } {
722 set exec_output [run_host_cmd "tmpdir/pr28138" ""]
723 if [string match "PASS" $exec_output] then {
724 pass "PR ld/28138 (build & run)"
725 } else {
726 fail "PR ld/28138 (built ok, run failed)"
727 }
728 } else {
729 pass "PR ld/28138 (build only)"
730 }
731 } else {
732 fail "PR ld/28138 (build only)"
733 }
734
735 set testname "Build liblto-11.a"
736 remote_file host delete "tmpdir/liblto-11.a"
737 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"]
738 if {![string match "" $catch_output]} {
739 fail $testname
740 restore_notify
741 return
742 }
743
744 if { [at_least_gcc_version 4 7] } {
745 # Check expected LTO linker errors.
746 # Since the asm symbol name hack in pr12365b.c doesn't work on all
747 # targets, run PR ld/12365 tests only for known targets.
748 if { ([istarget "i?86-*-elf*"]
749 || [istarget "i?86-*-linux*"]
750 || [istarget "i?86-*-gnu*"]
751 || [istarget "x86_64-*-linux*"]
752 || [istarget "amd64-*-linux*"]) } {
753 set testname "PR ld/12365"
754 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"]
755 set exec_output [prune_warnings $exec_output]
756 if { [ regexp "undefined reference to `my_bcopy'" $exec_output ] } {
757 # Linker should catch the reference to undefined `my_bcopy'
758 # error caused by a GCC bug.
759 pass $testname
760 } elseif { [ string match "" $exec_output ] } {
761 global READELF
762 set exec_output [run_host_cmd "$READELF" "-s -W tmpdir/pr12365"]
763 if { [ regexp "my_bcopy" $exec_output ] } {
764 # Verify that there is no `my_bcopy' symbol in executable.
765 fail $testname
766 } {
767 pass $testname
768 }
769 } {
770 fail $testname
771 }
772
773 run_cc_link_tests [list \
774 [list \
775 "Build pr22721a.so" \
776 "-shared $NOSANITIZE_CFLAGS -nostdlib -nostartfiles \
777 -Wl,-version-script,pr22721.t" \
778 "" \
779 {pr22721a.s} \
780 {} \
781 "pr22721a.so" \
782 ] \
783 [list \
784 "Build pr22721b.o" \
785 "$plug_opt $NOSANITIZE_CFLAGS" \
786 "-O2 -fPIC -flto $lto_no_fat" \
787 {pr22721b.c} \
788 ] \
789 [list \
790 "Build PR ld/pr22721" \
791 "-O2 -flto -fuse-linker-plugin -nostdlib -nostartfiles \
792 $NOSANITIZE_CFLAGS \
793 -Wl,-e,_start tmpdir/pr22721b.o tmpdir/pr22721a.so" \
794 "$NOSANITIZE_CFLAGS" \
795 {dummy.c} \
796 {} \
797 "pr22721.exe"
798 ] \
799 ]
800 }
801 set testname "PR ld/12942 (3)"
802 set exec_output [run_host_cmd "$CXX_FOR_TARGET" "-O2 -flto -fuse-linker-plugin tmpdir/pr12942b.o tmpdir/pr12942a.o"]
803 if { [ regexp "undefined reference to `\\.?link_error\\(\\)'" $exec_output ] } {
804 pass $testname
805 } {
806 fail $testname
807 }
808
809 run_cc_link_tests [list \
810 [list \
811 "Build pr23460*.o" \
812 "$plug_opt" \
813 "-O2 -fPIC -flto $lto_no_fat" \
814 {pr23460a.c pr23460b.c pr23460c.c \
815 pr23460d.c pr23460e.c pr23460f.c} \
816 ] \
817 ]
818 set exec_output [run_host_cmd "sh" \
819 "-c \"ulimit -n 20; \
820 $ar -rc $plug_opt \
821 tmpdir/libpr23460.a \
822 tmpdir/pr23460a.o \
823 tmpdir/pr23460b.o \
824 tmpdir/pr23460c.o \
825 tmpdir/pr23460d.o \
826 tmpdir/pr23460e.o \
827 tmpdir/pr23460f.o\""]
828 set exec_output [prune_warnings $exec_output]
829 if [string match "" $exec_output] then {
830 pass "PR binutils/23460"
831 } else {
832 fail "PR binutils/23460"
833 }
834 set exec_output [run_host_cmd "$RANLIB" "$plug_opt tmpdir/libpr23460.a"]
835 set exec_output [prune_warnings $exec_output]
836 if [string match "" $exec_output] then {
837 pass "PR binutils/23460"
838 } else {
839 fail "PR binutils/23460"
840 }
841 }
842
843 # Run "ld -r" to generate inputs for complex LTO tests.
844 run_dump_test "lto-3r"
845 remote_exec host "mv" "tmpdir/dump tmpdir/lto-3.o"
846 run_dump_test "lto-5r"
847 remote_exec host "mv" "tmpdir/dump tmpdir/lto-5.o"
848
849 run_cc_link_tests $lto_link_symbol_tests
850
851 run_ld_link_tests [list \
852 [list "PR ld/19317 (2)" \
853 "-r tmpdir/pr19317.o" "" "" \
854 {dummy.s} {} "pr19317-r.o"] \
855 ]
856
857 run_ld_link_exec_tests $lto_run_tests
858
859 if { [is_elf_format] } {
860 run_ld_link_exec_tests $lto_run_elf_tests
861
862 # Note - it is not guaranteed that the ordering of symbols in the dynamic
863 # symbol table will match the ordering of the symbols specified by the
864 # --dynamic-list command line option.
865 #
866 # For PR22983 we want to make sure that all four symbols specified in
867 # pr222983.t are present in the output, but a simple sequences of regexps
868 # will not work as we do not know the order of the symbols. (Readelf
869 # does not have a symbol sorting option and the run_cc_list_tests proc
870 # does not allow for the output of the dump program to piped into `sort`).
871 #
872 # So instead we run readelf four times, each time checking for the
873 # presence of a specific symbol from the pr22983.t file.
874 run_cc_link_tests [list \
875 [list \
876 "Build pr22983" \
877 "-Wl,--dynamic-list,pr22983.t" \
878 "-flto" \
879 {pr22983a.c pr22983b.c} \
880 {{readelf {--dyn-syms --wide} pr22983.1.d} \
881 {readelf {--dyn-syms --wide} pr22983.2.d} \
882 {readelf {--dyn-syms --wide} pr22983.3.d} \
883 {readelf {--dyn-syms --wide} pr22983.4.d}} \
884 "pr22983" \
885 ] \
886 ]
887 }
888
889 if { [is_elf_format] && [check_lto_shared_available] } {
890 run_ld_link_exec_tests $lto_run_elf_shared_tests
891 }
892
893 proc pr20103 {cflags libs} {
894 global CC_FOR_TARGET
895
896 set testname "PR ld/20103 ($cflags $libs)"
897 set exec_output [run_host_cmd "$CC_FOR_TARGET" "$cflags $libs"]
898 if { [ regexp "undefined reference to `\\.?dead'" $exec_output ] } {
899 pass "$testname (1)"
900 } {
901 fail "$testname (1)"
902 }
903 if { [ regexp "plugin needed to handle lto object" $exec_output ] } {
904 fail "$testname (2)"
905 } {
906 pass "$testname (2)"
907 }
908 }
909
910 if { [check_lto_fat_available] } {
911 run_cc_link_tests [list \
912 [list \
913 "Build fatpr20103a.a" \
914 "$plug_opt" "-flto -ffat-lto-objects" \
915 {pr20103a.c} {} "fatpr20103a.a"
916 ] \
917 [list \
918 "Build fatpr20103b.a" \
919 "$plug_opt" "-flto -ffat-lto-objects" \
920 {pr20103b.c} {} "fatpr20103b.a"
921 ] \
922 [list \
923 "Build fatpr20103c.a" \
924 "$plug_opt" "-flto -ffat-lto-objects" \
925 {pr20103c.c} {} "fatpr20103c.a" \
926 ] \
927 [list \
928 "Build thinpr20103a.a" \
929 "$plug_opt" "-flto -fno-fat-lto-objects" \
930 {pr20103a.c} {} "thinpr20103a.a"
931 ] \
932 [list \
933 "Build thinpr20103b.a" \
934 "$plug_opt" "-flto -fno-fat-lto-objects" \
935 {pr20103b.c} {} "thinpr20103b.a"
936 ] \
937 [list \
938 "Build thinpr20103c.a" \
939 "$plug_opt" "-flto -fno-fat-lto-objects" \
940 {pr20103c.c} {} "thinpr20103c.a" \
941 ] \
942 [list \
943 "Build pr20103a" \
944 "-O2 -flto -Wl,--start-group tmpdir/thinpr20103a.a tmpdir/thinpr20103b.a tmpdir/thinpr20103c.a -Wl,--end-group" \
945 "-O2 -flto" \
946 {dummy.c} {} "pr20103a" \
947 ] \
948 [list \
949 "Build pr20103b" \
950 "-O2 -flto -Wl,--start-group tmpdir/fatpr20103a.a tmpdir/fatpr20103b.a tmpdir/fatpr20103c.a -Wl,--end-group" \
951 "-O2 -flto" \
952 {dummy.c} {} "pr20103b" \
953 ] \
954 [list \
955 "Build pr20103c" \
956 "-O2 -Wl,--start-group tmpdir/fatpr20103a.a tmpdir/fatpr20103b.a tmpdir/fatpr20103c.a -Wl,--end-group" \
957 "-O2" \
958 {dummy.c} {} "pr20103c" \
959 ] \
960 ]
961 pr20103 "-O2 -flto" "tmpdir/thinpr20103a.a tmpdir/thinpr20103b.a tmpdir/thinpr20103c.a"
962 pr20103 "-O2 -flto" "tmpdir/fatpr20103a.a tmpdir/fatpr20103b.a tmpdir/fatpr20103c.a"
963 pr20103 "-O2" "tmpdir/fatpr20103a.a tmpdir/fatpr20103b.a tmpdir/fatpr20103c.a"
964
965 if { [at_least_gcc_version 4 9] } {
966 run_cc_link_tests [list \
967 [list \
968 "Build pr20103d" \
969 "-O2 -Wl,--start-group tmpdir/thinpr20103a.a tmpdir/thinpr20103b.a tmpdir/thinpr20103c.a -Wl,--end-group" \
970 "-O2" \
971 {dummy.c} {} "pr20103d" \
972 ] \
973 ]
974 pr20103 "-O2" "tmpdir/thinpr20103a.a tmpdir/thinpr20103b.a tmpdir/thinpr20103c.a"
975 }
976 }
977
978 restore_notify