+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"] \
+]