aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2014-08-06 13:26:18 +0930
committerAlan Modra <amodra@gmail.com>2014-08-06 13:26:18 +0930
commitc3e11cbe51085fed6ca1c90f56611b8cbbabe3eb (patch)
tree702294bdfcf73ef89c4a4cbd52827849a3204a3e /ld
parent7cd4e5b756fa5c1ebe0ba7dd04e45d46330a7675 (diff)
downloadgdb-c3e11cbe51085fed6ca1c90f56611b8cbbabe3eb.zip
gdb-c3e11cbe51085fed6ca1c90f56611b8cbbabe3eb.tar.gz
gdb-c3e11cbe51085fed6ca1c90f56611b8cbbabe3eb.tar.bz2
Allow lto tests to run with older compilers
* lib/ld-lib.exp (check_lto_fat_available): New. (check_lto_available): Remove -ffat-lto-objects test. * ld-plugin/lto.exp: Use [list ] rather than { } to set up list variables, allowing substition of vars. Set lto_fat and plug_opt and add to various tests.
Diffstat (limited to 'ld')
-rw-r--r--ld/testsuite/ChangeLog8
-rw-r--r--ld/testsuite/ld-plugin/lto.exp536
-rw-r--r--ld/testsuite/lib/ld-lib.exp45
3 files changed, 321 insertions, 268 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 9114c7d..da8f2f5 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2014-08-06 Alan Modra <amodra@gmail.com>
+
+ * lib/ld-lib.exp (check_lto_fat_available): New.
+ (check_lto_available): Remove -ffat-lto-objects test.
+ * ld-plugin/lto.exp: Use [list ] rather than { } to set up list
+ variables, allowing substition of vars. Set lto_fat and plug_opt
+ and add to various tests.
+
2014-08-01 Takashi Yoshii <yoshii.takashi@renesas.com>
PR 10373
diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index 765d85f8..432c753 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -38,275 +38,290 @@ proc restore_notify { } {
set CXXFLAGS "$saved_CXXFLAGS"
}
-# Simple LTO tests and generate input files for complex LTO tests.
-set lto_link_tests {
- {"LTO 1"
- "-O2 -flto -fuse-linker-plugin" "-flto -fuse-linker-plugin"
- {lto-1a.c lto-1b.c} {} "lto-1.exe"}
- {"Compile 2"
- "" "-O2 -flto -fuse-linker-plugin"
- {lto-2.c} {} ""}
- {"LTO 2"
- "-static -O2 -flto -fuse-linker-plugin tmpdir/lto-2.o -lm" ""
- {dummy.c} {} "lto-2.exe"}
- {"Compile 3a"
- "" "-flto"
- {lto-3a.c} {} ""}
- {"Compile 3c"
- "" "-O2"
- {lto-3c.c} {} ""}
- {"Build liblto-3.a"
- "" "-flto -ffat-lto-objects"
- {lto-3b.c} {} "liblto-3.a"}
- {"Compile 5a"
- "" "-flto"
- {lto-5a.c} {} ""}
- {"Compile 5b"
- "" "-flto"
- {lto-5b.c} {} ""}
- {"LTO 6"
- "-O2 -flto -fuse-linker-plugin" ""
- {lto-6.c} {} "lto-6.exe" "c"}
- {"Compile 9"
- "" "-O2 -finline -flto"
- {lto-9.cc} {} "" "c++"}
- {"Compile 11a"
- "" "-O -flto"
- {lto-11a.c} {} ""}
- {"Compile 11b"
- "" "-O -flto"
- {lto-11b.c} {} ""}
- {"Compile 11c"
- "" "-O"
- {lto-11c.c} {} ""}
- {"Build liblto-12.a"
- "" "-O2 -flto"
- {lto-12c.c} {} "liblto-12.a"}
- {"Compile 12"
- "" "-O2 -flto"
- {lto-12a.c lto-12b.c} {} ""}
- {"Compile 13"
- "" "-O2 -flto"
- {lto-13a.c lto-13b.c} {} ""}
- {"Build liblto-13.a"
- "" "-O2"
- {lto-13c.c} {} "liblto-13.a"}
- {"Compile 14a"
- "" "-flto"
- {lto-14a.c lto-14b.c} {} ""}
- {"Build liblto-14.a"
- "" "-flto"
- {lto-14c.c} {} "liblto-14.a"}
- {"Compile 15a"
- "" "-flto"
- {lto-15a.c} {} ""}
- {"Build liblto-15.a"
- "" "-flto"
- {lto-15b.c} {} "liblto-15.a"}
- {"PR ld/12696"
- "-O2 -flto -fuse-linker-plugin -r -nostdlib" "-O2 -flto"
- {pr12696-1.cc} {} "pr12696-1r.o" "c++"}
- {"Compile PR ld/12758"
- "" ""
- {pr12758a.s} {} ""}
- {"Build libpr12758.a"
- "" "-flto -O2 -ffat-lto-objects"
- {pr12758b.c} {} "libpr12758.a"}
- {"PR ld/12758"
- "-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin tmpdir/pr12758a.o -Wl,--start-group tmpdir/libpr12758.a -Wl,--end-group" ""
- {dummy.c} {} "pr12758.exe"}
- {"Compile PR ld/12760"
- "" "-g -O0"
- {pr12760a.c} {} ""}
- {"Build libpr12760.a"
- "" "-flto -O2 -ffat-lto-objects"
- {pr12760b.c} {} "libpr12760.a"}
- {"PR ld/12760"
- "-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin tmpdir/pr12760a.o -Wl,--start-group tmpdir/libpr12760.a -Wl,--end-group" ""
- {dummy.c} {} "pr12760.exe" "c" "pr12760a.c:6: warning: Bad bar"}
- {"Build libpr13183.a"
- "-T" "-flto -O2 -ffat-lto-objects"
- {pr13183a.c} {} "libpr13183.a"}
- {"Compile PR ld/13183"
- "" "-flto -O2"
- {pr13183b.c} {} ""}
- {"Compile PR ld/13201"
- "" "-flto -O2"
- {pr13201.c} {} ""}
- {"PR ld/13287"
- "-flto -fuse-linker-plugin -Wl,--as-needed" "-flto"
- {pr13287.cc} {} "pr13287.exe" "c++"}
- {"PR ld/15323"
- "" "-O2"
- {pr15323a.c} {} "" "c"}
- {"Compile(1) PR ld/pr16846"
- "" "-flto"
- {pr16846a.c pr16846b.c} {} ""}
- {"Compile(2) PR ld/pr16846"
- "" ""
- {pr16846c.c} {} ""}
- {"PR ld/pr16846(1)"
- "-flto -fuse-linker-plugin tmpdir/pr16846a.o tmpdir/pr16846b.o tmpdir/pr16846c.o" ""
- {dummy.c} {} "pr16846a.exe"}
- {"PR ld/pr16846(2)"
- "-flto -fuse-linker-plugin tmpdir/pr16846a.o tmpdir/pr16846c.o tmpdir/pr16846b.o" ""
- {dummy.c} {} "pr16846b.exe"}
+set plugin_names {
+ liblto_plugin.so
+ liblto_plugin-0.dll
+ cyglto_plugin-0.dll
}
+set plug_opt ""
+foreach plug $plugin_names {
+ set plug_so [run_host_cmd $CC "--print-prog-name $plug"]
+ if { $plug_so ne $plug } then {
+ set plug_opt "--plugin $plug_so"
+ break
+ }
+}
+set lto_fat ""
+if { [check_lto_fat_available] } {
+ set lto_fat "-ffat-lto-objects"
+}
+
+# Simple LTO tests and generate input files for complex LTO tests.
+set lto_link_tests [list \
+ [list "LTO 1" \
+ "-O2 -flto -fuse-linker-plugin" "-flto -fuse-linker-plugin" \
+ {lto-1a.c lto-1b.c} {} "lto-1.exe"] \
+ [list "Compile 2" \
+ "" "-O2 -flto -fuse-linker-plugin" \
+ {lto-2.c} {} ""] \
+ [list "LTO 2" \
+ "-static -O2 -flto -fuse-linker-plugin tmpdir/lto-2.o -lm" "" \
+ {dummy.c} {} "lto-2.exe"] \
+ [list "Compile 3a" \
+ "" "-flto" \
+ {lto-3a.c} {} ""] \
+ [list "Compile 3c" \
+ "" "-O2" \
+ {lto-3c.c} {} ""] \
+ [list "Build liblto-3.a" \
+ "" "-flto $lto_fat" \
+ {lto-3b.c} {} "liblto-3.a"] \
+ [list "Compile 5a" \
+ "" "-flto $lto_fat" \
+ {lto-5a.c} {} ""] \
+ [list "Compile 5b" \
+ "" "-flto $lto_fat" \
+ {lto-5b.c} {} ""] \
+ [list "LTO 6" \
+ "-O2 -flto -fuse-linker-plugin" "" \
+ {lto-6.c} {} "lto-6.exe" "c"] \
+ [list "Compile 9" \
+ "" "-O2 -finline -flto" \
+ {lto-9.cc} {} "" "c++"] \
+ [list "Compile 11a" \
+ "" "-O -flto" \
+ {lto-11a.c} {} ""] \
+ [list "Compile 11b" \
+ "" "-O -flto" \
+ {lto-11b.c} {} ""] \
+ [list "Compile 11c" \
+ "" "-O" \
+ {lto-11c.c} {} ""] \
+ [list "Build liblto-12.a" \
+ "$plug_opt" "-O2 -flto" \
+ {lto-12c.c} {} "liblto-12.a"] \
+ [list "Compile 12" \
+ "" "-O2 -flto" \
+ {lto-12a.c lto-12b.c} {} ""] \
+ [list "Compile 13" \
+ "" "-O2 -flto" \
+ {lto-13a.c lto-13b.c} {} ""] \
+ [list "Build liblto-13.a" \
+ "" "-O2" \
+ {lto-13c.c} {} "liblto-13.a"] \
+ [list "Compile 14a" \
+ "" "-flto" \
+ {lto-14a.c lto-14b.c} {} ""] \
+ [list "Build liblto-14.a" \
+ "$plug_opt" "-flto" \
+ {lto-14c.c} {} "liblto-14.a"] \
+ [list "Compile 15a" \
+ "" "-flto" \
+ {lto-15a.c} {} ""] \
+ [list "Build liblto-15.a" \
+ "$plug_opt" "-flto" \
+ {lto-15b.c} {} "liblto-15.a"] \
+ [list "PR ld/12696" \
+ "-O2 -flto -fuse-linker-plugin -r -nostdlib" "-O2 -flto" \
+ {pr12696-1.cc} {} "pr12696-1r.o" "c++"] \
+ [list "Compile PR ld/12758" \
+ "" "" \
+ {pr12758a.s} {} ""] \
+ [list "Build libpr12758.a" \
+ "" "-flto -O2 $lto_fat" \
+ {pr12758b.c} {} "libpr12758.a"] \
+ [list "PR ld/12758" \
+ "-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin tmpdir/pr12758a.o -Wl,--start-group tmpdir/libpr12758.a -Wl,--end-group" "" \
+ {dummy.c} {} "pr12758.exe"] \
+ [list "Compile PR ld/12760" \
+ "" "-g -O0" \
+ {pr12760a.c} {} ""] \
+ [list "Build libpr12760.a" \
+ "" "-flto -O2 $lto_fat" \
+ {pr12760b.c} {} "libpr12760.a"] \
+ [list "PR ld/12760" \
+ "-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin tmpdir/pr12760a.o -Wl,--start-group tmpdir/libpr12760.a -Wl,--end-group" "" \
+ {dummy.c} {} "pr12760.exe" "c" "pr12760a.c:6: warning: Bad bar"] \
+ [list "Build libpr13183.a" \
+ "-T" "-flto -O2 $lto_fat" \
+ {pr13183a.c} {} "libpr13183.a"] \
+ [list "Compile PR ld/13183" \
+ "" "-flto -O2" \
+ {pr13183b.c} {} ""] \
+ [list "Compile PR ld/13201" \
+ "" "-flto -O2" \
+ {pr13201.c} {} ""] \
+ [list "PR ld/13287" \
+ "-flto -fuse-linker-plugin -Wl,--as-needed" "-flto" \
+ {pr13287.cc} {} "pr13287.exe" "c++"] \
+ [list "PR ld/15323" \
+ "" "-O2" \
+ {pr15323a.c} {} "" "c"] \
+ [list "Compile(1) PR ld/pr16846" \
+ "" "-flto" \
+ {pr16846a.c pr16846b.c} {} ""] \
+ [list "Compile(2) PR ld/pr16846" \
+ "" "" \
+ {pr16846c.c} {} ""] \
+ [list "PR ld/pr16846(1)" \
+ "-flto -fuse-linker-plugin tmpdir/pr16846a.o tmpdir/pr16846b.o tmpdir/pr16846c.o" "" \
+ {dummy.c} {} "pr16846a.exe"] \
+ [list "PR ld/pr16846(2)" \
+ "-flto -fuse-linker-plugin tmpdir/pr16846a.o tmpdir/pr16846c.o tmpdir/pr16846b.o" "" \
+ {dummy.c} {} "pr16846b.exe"] \
+]
if { [at_least_gcc_version 4 7] } {
- set lto_link_tests [concat $lto_link_tests {
- {"Compile PR ld/12942 (1)"
- "" "-flto -O2"
- {pr12942a.cc pr12942c.cc} {} "" "c++"}
- {"Compile PR ld/12942 (2)"
- "" "-O0"
- {pr12942b.cc} {} "" "c++"}
- }]
+ set lto_link_tests [concat $lto_link_tests [list \
+ [list "Compile PR ld/12942 (1)" \
+ "" "-flto -O2" \
+ {pr12942a.cc pr12942c.cc} {} "" "c++"] \
+ [list "Compile PR ld/12942 (2)" \
+ "" "-O0" \
+ {pr12942b.cc} {} "" "c++"] \
+ ]]
}
# Generate input files for complex LTO tests for ELF.
-set lto_link_elf_tests {
- {"Compile 7"
- "" "-flto -O2"
- {lto-7a.c lto-7b.c lto-7c.c} {} ""}
- {"Build liblto-7.so"
- "-shared" "-O2 -fpic"
- {lto-7d.c} {} "liblto-7.so" "c"}
- {"Compile 8a"
- "" "-O2"
- {lto-8a.c} {} ""}
- {"Compile 8b"
- "" "-flto -O2"
- {lto-8b.c} {} ""}
- {"Build liblto-17a.so"
- "-shared -O2 -fpic -flto -fuse-linker-plugin" "-O2 -fpic -flto"
- {lto-17a.c} {{"nm" {} "lto-17a.d"}} "liblto-17a.so" "c"}
- {"Build liblto-17b.so 1"
- "-shared -O2 -fpic -flto -fuse-linker-plugin tmpdir/lto-17a.o" "-O2 -fpic -flto"
- {lto-17b.c} {{"nm" {} "lto-17b-1.d"}} "liblto-17b.so"}
- {"Build liblto-17b.so 2"
- "-shared -O2 -fpic -flto -fuse-linker-plugin tmpdir/lto-17a.o" "-O2 -fpic -flto"
- {lto-17b.c} {{"nm" {} "lto-17b-2.d"}} "liblto-17b.so"}
- {"PR ld/12982"
- "-O2 -flto -fuse-linker-plugin" "-O2 -flto"
- {pr12982.c} {{"readelf" {-l --wide} "pr12982.d"}} "pr12982.exe"}
- {"PR ld/12975"
- "-shared -O2 -fPIC -flto -fuse-linker-plugin -nostdlib -Wl,-version-script,pr12975.t" "-O2 -flto"
- {pr12975.c} {{"readelf" {-s --wide} "pr12975.d"}} "pr12975.so" "c"}
- {"PR ld/13229"
- "-shared -O2 -fPIC -flto -fuse-linker-plugin -nostdlib" "-O2 -finline -fno-early-inlining -flto"
- {pr13229.cc} {{"readelf" {-s --wide} "pr13229.d"}} "pr13229.so" "c++"}
- {"PR ld/13244"
- "-shared -O2 -fPIC -flto -fuse-linker-plugin -nostdlib" "-O2 -fno-early-inlining -flto"
- {pr13244.c} {{"readelf" {-s --wide} "pr13244.d"}} "pr13244.so" "c"}
- {"Build libpr15146a.a"
- "" "-flto -O2"
- {pr15146a.c} {} "lib15146a.a"}
- {"Build pr15146b.so"
- "-shared" "-O2 -fpic"
- {pr15146b.c} {} "pr15146b.so" "c"}
- {"Build pr15146c.so"
- "-shared -Wl,--no-as-needed tmpdir/pr15146b.so" "-O2 -fpic"
- {pr15146c.c} {} "pr15146c.so" "c"}
- {"PR ld/15146 (1)"
- "-O2 -flto -fuse-linker-plugin -Wl,-rpath-link,. -Wl,--no-copy-dt-needed-entries -Wl,--no-as-needed tmpdir/pr15146a.o tmpdir/pr15146c.so" ""
- {dummy.c} {{"readelf" {-d} "pr15146.d"}} "pr15146a.exe"}
- {"Build libpr15146d.a"
- "" "-flto -O2"
- {pr15146d.c} {} "lib15146d.a"}
- {"Build libpr15146d.a"
- "" "-flto -O2"
- {pr15146d.c} {} "lib15146d.a"}
-}
+set lto_link_elf_tests [list \
+ [list "Compile 7" \
+ "" "-flto -O2" \
+ {lto-7a.c lto-7b.c lto-7c.c} {} ""] \
+ [list "Build liblto-7.so" \
+ "-shared" "-O2 -fpic" \
+ {lto-7d.c} {} "liblto-7.so" "c"] \
+ [list "Compile 8a" \
+ "" "-O2" \
+ {lto-8a.c} {} ""] \
+ [list "Compile 8b" \
+ "" "-flto -O2" \
+ {lto-8b.c} {} ""] \
+ [list "Build liblto-17a.so" \
+ "-shared -O2 -fpic -flto -fuse-linker-plugin" "-O2 -fpic -flto" \
+ {lto-17a.c} {{"nm" {} "lto-17a.d"}} "liblto-17a.so" "c"] \
+ [list "Build liblto-17b.so 1" \
+ "-shared -O2 -fpic -flto -fuse-linker-plugin tmpdir/lto-17a.o" "-O2 -fpic -flto" \
+ {lto-17b.c} {{"nm" {} "lto-17b-1.d"}} "liblto-17b.so"] \
+ [list "Build liblto-17b.so 2" \
+ "-shared -O2 -fpic -flto -fuse-linker-plugin tmpdir/lto-17a.o" "-O2 -fpic -flto" \
+ {lto-17b.c} {{"nm" {} "lto-17b-2.d"}} "liblto-17b.so"] \
+ [list "PR ld/12982" \
+ "-O2 -flto -fuse-linker-plugin" "-O2 -flto" \
+ {pr12982.c} {{"readelf" {-l --wide} "pr12982.d"}} "pr12982.exe"] \
+ [list "PR ld/12975" \
+ "-shared -O2 -fPIC -flto -fuse-linker-plugin -nostdlib -Wl,-version-script,pr12975.t" "-O2 -flto" \
+ {pr12975.c} {{"readelf" {-s --wide} "pr12975.d"}} "pr12975.so" "c"] \
+ [list "PR ld/13229" \
+ "-shared -O2 -fPIC -flto -fuse-linker-plugin -nostdlib" "-O2 -finline -fno-early-inlining -flto" \
+ {pr13229.cc} {{"readelf" {-s --wide} "pr13229.d"}} "pr13229.so" "c++"] \
+ [list "PR ld/13244" \
+ "-shared -O2 -fPIC -flto -fuse-linker-plugin -nostdlib" "-O2 -fno-early-inlining -flto" \
+ {pr13244.c} {{"readelf" {-s --wide} "pr13244.d"}} "pr13244.so" "c"] \
+ [list "Build libpr15146a.a" \
+ "$plug_opt" "-flto -O2" \
+ {pr15146a.c} {} "lib15146a.a"] \
+ [list "Build pr15146b.so" \
+ "-shared" "-O2 -fpic" \
+ {pr15146b.c} {} "pr15146b.so" "c"] \
+ [list "Build pr15146c.so" \
+ "-shared -Wl,--no-as-needed tmpdir/pr15146b.so" "-O2 -fpic" \
+ {pr15146c.c} {} "pr15146c.so" "c"] \
+ [list "PR ld/15146 (1)" \
+ "-O2 -flto -fuse-linker-plugin -Wl,-rpath-link,. -Wl,--no-copy-dt-needed-entries -Wl,--no-as-needed tmpdir/pr15146a.o tmpdir/pr15146c.so" "" \
+ {dummy.c} {{"readelf" {-d} "pr15146.d"}} "pr15146a.exe"] \
+ [list "Build libpr15146d.a" \
+ "$plug_opt" "-flto -O2" \
+ {pr15146d.c} {} "lib15146d.a"] \
+]
# Check final symbols in executables.
-set lto_link_symbol_tests {
- {"LTO 3 symbol"
- "-O2 -flto -fuse-linker-plugin tmpdir/lto-3a.o tmpdir/lto-3c.o tmpdir/liblto-3.a" ""
- {dummy.c} {{"nm" {} "lto-3.d"}} "lto-3.exe" "c"}
- {"LTO 5 symbol"
- "-O2 -flto -fuse-linker-plugin tmpdir/lto-5.o" ""
- {dummy.c} {{"nm" {} "lto-5.d"}} "lto-5.exe" "c"}
- {"LTO 9 symbol"
- "-O2 -flto -fuse-linker-plugin tmpdir/lto-9.o" ""
- {dummy.c} {{"nm" {-C} "lto-9.d"}} "lto-9.exe" "c++"}
- {"LTO 16a symbol"
- "-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin" "-flto"
- {lto-16a.c} {{"nm" {} "lto-16a.d"}} "lto-16.exe" "c"}
- {"LTO 16b symbol"
- "-O2 -Wl,-e,foo -u bar -nostdlib -flto -fuse-linker-plugin" "-flto"
- {lto-16a.c lto-16b.c} {{"nm" {} "lto-16b.d"}} "lto-16b.exe" "c"}
- {"PR ld/13183"
- "-O2 -flto -fuse-linker-plugin tmpdir/pr13183b.o tmpdir/libpr13183.a" ""
- {dummy.c} {{"nm" {} "pr13183.d"}} "pr13183.exe" "c"}
-}
+set lto_link_symbol_tests [list \
+ [list "LTO 3 symbol" \
+ "-O2 -flto -fuse-linker-plugin tmpdir/lto-3a.o tmpdir/lto-3c.o tmpdir/liblto-3.a" "" \
+ {dummy.c} {{"nm" {} "lto-3.d"}} "lto-3.exe" "c"] \
+ [list "LTO 5 symbol" \
+ "-O2 -flto -fuse-linker-plugin tmpdir/lto-5.o" "" \
+ {dummy.c} {{"nm" {} "lto-5.d"}} "lto-5.exe" "c"] \
+ [list "LTO 9 symbol" \
+ "-O2 -flto -fuse-linker-plugin tmpdir/lto-9.o" "" \
+ {dummy.c} {{"nm" {-C} "lto-9.d"}} "lto-9.exe" "c++"] \
+ [list "LTO 16a symbol" \
+ "-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin" "-flto" \
+ {lto-16a.c} {{"nm" {} "lto-16a.d"}} "lto-16.exe" "c"] \
+ [list "LTO 16b symbol" \
+ "-O2 -Wl,-e,foo -u bar -nostdlib -flto -fuse-linker-plugin" "-flto" \
+ {lto-16a.c lto-16b.c} {{"nm" {} "lto-16b.d"}} "lto-16b.exe" "c"] \
+ [list "PR ld/13183" \
+ "-O2 -flto -fuse-linker-plugin tmpdir/pr13183b.o tmpdir/libpr13183.a" "" \
+ {dummy.c} {{"nm" {} "pr13183.d"}} "pr13183.exe" "c"] \
+]
# LTO run-time tests.
-set lto_run_tests {
- {"LTO 3a"
- "-O2 -flto -fuse-linker-plugin tmpdir/lto-3a.o tmpdir/lto-3c.o tmpdir/liblto-3.a" ""
- {dummy.c} "lto-3b.exe" "lto-3.out" "" "c"}
- {"LTO 3b"
- "-O2 -flto -fuse-linker-plugin tmpdir/lto-3a.o tmpdir/lto-3c.o tmpdir/lto-3.o" ""
- {dummy.c} "lto-3c.exe" "lto-3.out" "" "c"}
- {"LTO 3c"
- "-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" ""
- {dummy.c} "lto-3d.exe" "lto-3.out" "" "c"}
- {"LTO 5"
- "-O2 -flto -fuse-linker-plugin tmpdir/lto-5.o" ""
- {dummy.c} "lto-5.exe" "lto-5.out" "" "c"}
- {"LTO 11"
- "-O -flto -fuse-linker-plugin tmpdir/liblto-11.a" ""
- {dummy.c} "lto-11.exe" "lto-11.out" "" "c"}
- {"LTO 12a"
- "-O -flto -fuse-linker-plugin tmpdir/lto-12a.o tmpdir/liblto-12.a tmpdir/lto-12b.o" ""
- {dummy.c} "lto-12a.exe" "lto-12.out" "" "c"}
- {"LTO 12b"
- "-O -flto -fuse-linker-plugin tmpdir/lto-12a.o tmpdir/lto-12b.o tmpdir/liblto-12.a" ""
- {dummy.c} "lto-12b.exe" "lto-12.out" "" "c"}
- {"LTO 13"
- "-O -flto -fuse-linker-plugin tmpdir/lto-13a.o tmpdir/liblto-13.a tmpdir/lto-13b.o" ""
- {dummy.c} "lto-13.exe" "lto-13.out" "" "c"}
- {"LTO 14"
- "-O2 -flto -fuse-linker-plugin tmpdir/lto-14a.o -Wl,--whole-archive tmpdir/liblto-14.a -Wl,--no-whole-archive tmpdir/lto-14b.o" ""
- {dummy.c} "lto-14.exe" "lto-14.out" "" "c"}
- {"LTO 15"
- "-O2 -flto -fuse-linker-plugin -Wl,--start-group tmpdir/liblto-15.a tmpdir/lto-15a.o -Wl,--end-group" ""
- {dummy.c} "lto-15.exe" "lto-15.out" "" "c"}
- {"PR ld/13066"
- "-O2 -flto -fuse-linker-plugin" ""
- {pr13066.cc} "pr13066.exe" "pr13066.out" "" "c++"}
- {"PR ld/13201"
- "-O2 -flto -fuse-linker-plugin -Wl,--as-needed tmpdir/pr13201.o -lm" ""
- {dummy.c} "pr13201.exe" "pr13201.out" "" "c"}
- {"PR ld/15323"
- "-O2 -flto -fuse-linker-plugin tmpdir/pr15323a.o" ""
- {pr15323b.c} "pr15323.exe" "pr15323.out" "-flto -O2" "c"}
-}
+set lto_run_tests [list \
+ [list "LTO 3a" \
+ "-O2 -flto -fuse-linker-plugin tmpdir/lto-3a.o tmpdir/lto-3c.o tmpdir/liblto-3.a" "" \
+ {dummy.c} "lto-3b.exe" "lto-3.out" "" "c"] \
+ [list "LTO 3b" \
+ "-O2 -flto -fuse-linker-plugin tmpdir/lto-3a.o tmpdir/lto-3c.o tmpdir/lto-3.o" "" \
+ {dummy.c} "lto-3c.exe" "lto-3.out" "" "c"] \
+ [list "LTO 3c" \
+ "-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" "" \
+ {dummy.c} "lto-3d.exe" "lto-3.out" "" "c"] \
+ [list "LTO 5" \
+ "-O2 -flto -fuse-linker-plugin tmpdir/lto-5.o" "" \
+ {dummy.c} "lto-5.exe" "lto-5.out" "" "c"] \
+ [list "LTO 11" \
+ "-O -flto -fuse-linker-plugin tmpdir/liblto-11.a" "" \
+ {dummy.c} "lto-11.exe" "lto-11.out" "" "c"] \
+ [list "LTO 12a" \
+ "-O -flto -fuse-linker-plugin tmpdir/lto-12a.o tmpdir/liblto-12.a tmpdir/lto-12b.o" "" \
+ {dummy.c} "lto-12a.exe" "lto-12.out" "" "c"] \
+ [list "LTO 12b" \
+ "-O -flto -fuse-linker-plugin tmpdir/lto-12a.o tmpdir/lto-12b.o tmpdir/liblto-12.a" "" \
+ {dummy.c} "lto-12b.exe" "lto-12.out" "" "c"] \
+ [list "LTO 13" \
+ "-O -flto -fuse-linker-plugin tmpdir/lto-13a.o tmpdir/liblto-13.a tmpdir/lto-13b.o" "" \
+ {dummy.c} "lto-13.exe" "lto-13.out" "" "c"] \
+ [list "LTO 14" \
+ "-O2 -flto -fuse-linker-plugin tmpdir/lto-14a.o -Wl,--whole-archive tmpdir/liblto-14.a -Wl,--no-whole-archive tmpdir/lto-14b.o" "" \
+ {dummy.c} "lto-14.exe" "lto-14.out" "" "c"] \
+ [list "LTO 15" \
+ "-O2 -flto -fuse-linker-plugin -Wl,--start-group tmpdir/liblto-15.a tmpdir/lto-15a.o -Wl,--end-group" "" \
+ {dummy.c} "lto-15.exe" "lto-15.out" "" "c"] \
+ [list "PR ld/13066" \
+ "-O2 -flto -fuse-linker-plugin" "" \
+ {pr13066.cc} "pr13066.exe" "pr13066.out" "" "c++"] \
+ [list "PR ld/13201" \
+ "-O2 -flto -fuse-linker-plugin -Wl,--as-needed tmpdir/pr13201.o -lm" "" \
+ {dummy.c} "pr13201.exe" "pr13201.out" "" "c"] \
+ [list "PR ld/15323" \
+ "-O2 -flto -fuse-linker-plugin tmpdir/pr15323a.o" "" \
+ {pr15323b.c} "pr15323.exe" "pr15323.out" "-flto -O2" "c"] \
+]
if { [at_least_gcc_version 4 7] } {
- set lto_run_tests [concat $lto_run_tests {
- {"PR ld/12942 (1)"
- "-O2 -flto -fuse-linker-plugin tmpdir/pr12942a.o tmpdir/pr12942b.o" ""
- {dummy.c} "pr12942a.exe" "pr12942.out" "" "c++"}
- {"PR ld/12942 (2)"
- "-O2 -flto -fuse-linker-plugin tmpdir/pr12942a.o tmpdir/pr12942c.o" ""
- {dummy.c} "pr12942c.exe" "pr12942.out" "" "c++"}
- }]
+ set lto_run_tests [concat $lto_run_tests [list \
+ [list "PR ld/12942 (1)" \
+ "-O2 -flto -fuse-linker-plugin tmpdir/pr12942a.o tmpdir/pr12942b.o" "" \
+ {dummy.c} "pr12942a.exe" "pr12942.out" "" "c++"] \
+ [list "PR ld/12942 (2)" \
+ "-O2 -flto -fuse-linker-plugin tmpdir/pr12942a.o tmpdir/pr12942c.o" "" \
+ {dummy.c} "pr12942c.exe" "pr12942.out" "" "c++"] \
+ ]]
}
# LTO run-time tests for ELF
-set lto_run_elf_tests {
- {"LTO 7"
- "-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" ""
- {dummy.c} "lto-7.exe" "lto-7.out" "" "c"}
- {"LTO 8"
- "-O2 -flto -fuse-linker-plugin tmpdir/lto-8b.o tmpdir/lto-8a.o" ""
- {dummy.c} "lto-8.exe" "lto-8.out" "" "c"}
- {"LTO TLS IE"
- "-O2 -flto -fuse-linker-plugin" ""
- {run-ie.c} "run-ie.exe" "run-ie.out" "" "c"}
-}
+set lto_run_elf_tests [list \
+ [list "LTO 7" \
+ "-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" "" \
+ {dummy.c} "lto-7.exe" "lto-7.out" "" "c"] \
+ [list "LTO 8" \
+ "-O2 -flto -fuse-linker-plugin tmpdir/lto-8b.o tmpdir/lto-8a.o" "" \
+ {dummy.c} "lto-8.exe" "lto-8.out" "" "c"] \
+ [list "LTO TLS IE" \
+ "-O2 -flto -fuse-linker-plugin" "" \
+ {run-ie.c} "run-ie.exe" "run-ie.out" "" "c"] \
+]
run_cc_link_tests $lto_link_tests
@@ -324,19 +339,6 @@ if { [is_elf_format] && [check_lto_shared_available] } {
set testname "Build liblto-11.a"
remote_file host delete "tmpdir/liblto-11.a"
-set plugin_names {
- liblto_plugin.so
- liblto_plugin-0.dll
- cyglto_plugin-0.dll
-}
-set plug_opt ""
-foreach plug $plugin_names {
- set plug_so [run_host_cmd $CC "--print-prog-name $plug"]
- if { $plug_so ne $plug } then {
- set plug_opt "--plugin $plug_so"
- break
- }
-}
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"]
if {![string match "" $catch_output]} {
unresolved $testname
diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp
index 9dac6be..c4ce0e7 100644
--- a/ld/testsuite/lib/ld-lib.exp
+++ b/ld/testsuite/lib/ld-lib.exp
@@ -1424,6 +1424,15 @@ proc run_cc_link_tests { ldtests } {
set is_unresolved 0
set failed 0
+ #verbose -log "testname is $testname"
+ #verbose -log "ldflags is $ldflags"
+ #verbose -log "cflags is $cflags"
+ #verbose -log "src_files is $src_files"
+ #verbose -log "actions is $actions"
+ #verbose -log "binfile is $binfile"
+ #verbose -log "lang is $lang"
+ #verbose -log "warnings is $warnings"
+
# Compile each file in the test.
foreach src_file $src_files {
set fileroot "[file rootname [file tail $src_file]]"
@@ -1686,7 +1695,7 @@ proc check_lto_available { } {
puts $f "int main() { return 0; }"
close $f
remote_download host $src
- set lto_available_saved [run_host_cmd_yesno "$CC" "$flags -flto -ffat-lto-objects -fuse-linker-plugin $src -o $output"]
+ set lto_available_saved [run_host_cmd_yesno "$CC" "$flags -flto -fuse-linker-plugin $src -o $output"]
remote_file host delete $src
remote_file host delete $output
file delete $src
@@ -1694,6 +1703,40 @@ proc check_lto_available { } {
return $lto_available_saved
}
+# Returns true if the target compiler supports LTO -ffat-lto-objects
+proc check_lto_fat_available { } {
+ global lto_fat_available_saved
+ global CC
+
+ if {![info exists lto_fat_available_saved]} {
+ if { [which $CC] == 0 } {
+ set lto_fat_available_saved 0
+ return 0
+ }
+ # Check if gcc supports -flto -fuse-linker-plugin
+ set flags ""
+ if [board_info [target_info name] exists cflags] {
+ append flags " [board_info [target_info name] cflags]"
+ }
+ if [board_info [target_info name] exists ldflags] {
+ append flags " [board_info [target_info name] ldflags]"
+ }
+
+ set basename "tmpdir/lto[pid]"
+ set src ${basename}.c
+ set output ${basename}.out
+ set f [open $src "w"]
+ puts $f "int main() { return 0; }"
+ close $f
+ remote_download host $src
+ set lto_fat_available_saved [run_host_cmd_yesno "$CC" "$flags -flto -ffat-lto-objects -fuse-linker-plugin $src -o $output"]
+ remote_file host delete $src
+ remote_file host delete $output
+ file delete $src
+ }
+ return $lto_fat_available_saved
+}
+
# Returns true if the target compiler supports LTO and -shared
proc check_lto_shared_available { } {
global lto_shared_available_saved