Rid libdummy.a from lto.exp

libdummy.a is used to make run_cc_link_tests compile objects and
archive them.  libdummy.a isn't used.  What we're really doing is
preventing a final link.  So do that directly.

	* lib/ld-lib.exp (run_ld_link_tests): Stop after assembling objects
	if binfile is empty.
	(run_ld_link_exec_tests, run_cc_link_tests): Likewise.  Tidy
	status checks.
	* ld-plugin/lto.exp: Don't use libdummy.a trick to compile objects.
	Instead use an empty output file.
This commit is contained in:
Alan Modra
2014-07-05 11:59:53 +09:30
parent 878f7dc7d1
commit abc868c609
3 changed files with 74 additions and 66 deletions

View File

@ -1,3 +1,12 @@
2014-07-05 Alan Modra <amodra@gmail.com>
* lib/ld-lib.exp (run_ld_link_tests): Stop after assembling objects
if binfile is empty.
(run_ld_link_exec_tests, run_cc_link_tests): Likewise. Tidy
status checks.
* ld-plugin/lto.exp: Don't use libdummy.a trick to compile objects.
Instead use an empty output file.
2014-07-03 Alan Modra <amodra@gmail.com> 2014-07-03 Alan Modra <amodra@gmail.com>
* ld-elf/pr17068.s: New. * ld-elf/pr17068.s: New.

View File

@ -43,81 +43,81 @@ set lto_link_tests {
{"LTO 1" {"LTO 1"
"-O2 -flto -fuse-linker-plugin" "-flto -fuse-linker-plugin" "-O2 -flto -fuse-linker-plugin" "-flto -fuse-linker-plugin"
{lto-1a.c lto-1b.c} {} "lto-1.exe"} {lto-1a.c lto-1b.c} {} "lto-1.exe"}
{"Build libdummy.a 2" {"Compile 2"
"" "-O2 -flto -fuse-linker-plugin" "" "-O2 -flto -fuse-linker-plugin"
{lto-2.c} {} "libdummy.a"} {lto-2.c} {} ""}
{"LTO 2" {"LTO 2"
"-static -O2 -flto -fuse-linker-plugin tmpdir/lto-2.o -lm" "" "-static -O2 -flto -fuse-linker-plugin tmpdir/lto-2.o -lm" ""
{dummy.c} {} "lto-2.exe"} {dummy.c} {} "lto-2.exe"}
{"Build libdummy.a 3a" {"Compile 3a"
"" "-flto" "" "-flto"
{lto-3a.c} {} "libdummy.a"} {lto-3a.c} {} ""}
{"Build libdummy.a 3c" {"Compile 3c"
"" "-O2" "" "-O2"
{lto-3c.c} {} "libdummy.a"} {lto-3c.c} {} ""}
{"Build liblto-3.a" {"Build liblto-3.a"
"" "-flto -ffat-lto-objects" "" "-flto -ffat-lto-objects"
{lto-3b.c} {} "liblto-3.a"} {lto-3b.c} {} "liblto-3.a"}
{"Build libdummy.a 5a" {"Compile 5a"
"" "-flto" "" "-flto"
{lto-5a.c} {} "libdummy.a"} {lto-5a.c} {} ""}
{"Build libdummy.a 5b" {"Compile 5b"
"" "-flto" "" "-flto"
{lto-5b.c} {} "libdummy.a"} {lto-5b.c} {} ""}
{"LTO 6" {"LTO 6"
"-O2 -flto -fuse-linker-plugin" "" "-O2 -flto -fuse-linker-plugin" ""
{lto-6.c} {} "lto-6.exe" "c"} {lto-6.c} {} "lto-6.exe" "c"}
{"Build libdummy.a 9" {"Compile 9"
"" "-O2 -finline -flto" "" "-O2 -finline -flto"
{lto-9.cc} {} "libdummy.a" "c++"} {lto-9.cc} {} "" "c++"}
{"Build libdummy.a 11a" {"Compile 11a"
"" "-O -flto" "" "-O -flto"
{lto-11a.c} {} "libdummy.a"} {lto-11a.c} {} ""}
{"Build libdummy.a 11b" {"Compile 11b"
"" "-O -flto" "" "-O -flto"
{lto-11b.c} {} "libdummy.a"} {lto-11b.c} {} ""}
{"Build libdummy.a 11c" {"Compile 11c"
"" "-O" "" "-O"
{lto-11c.c} {} "libdummy.a"} {lto-11c.c} {} ""}
{"Build liblto-12.a" {"Build liblto-12.a"
"" "-O2 -flto" "" "-O2 -flto"
{lto-12c.c} {} "liblto-12.a"} {lto-12c.c} {} "liblto-12.a"}
{"Build libdummy.a 12" {"Compile 12"
"" "-O2 -flto" "" "-O2 -flto"
{lto-12a.c lto-12b.c} {} "libdummy.a"} {lto-12a.c lto-12b.c} {} ""}
{"Build libdummy.a 13" {"Compile 13"
"" "-O2 -flto" "" "-O2 -flto"
{lto-13a.c lto-13b.c} {} "libdummy.a"} {lto-13a.c lto-13b.c} {} ""}
{"Build liblto-13.a" {"Build liblto-13.a"
"" "-O2" "" "-O2"
{lto-13c.c} {} "liblto-13.a"} {lto-13c.c} {} "liblto-13.a"}
{"Build libdummy.a 14a" {"Compile 14a"
"" "-flto" "" "-flto"
{lto-14a.c lto-14b.c} {} "libdummy.a"} {lto-14a.c lto-14b.c} {} ""}
{"Build liblto-14.a" {"Build liblto-14.a"
"" "-flto" "" "-flto"
{lto-14c.c} {} "liblto-14.a"} {lto-14c.c} {} "liblto-14.a"}
{"Build libdummy.a 15a" {"Compile 15a"
"" "-flto" "" "-flto"
{lto-15a.c} {} "libdummy.a"} {lto-15a.c} {} ""}
{"Build liblto-15.a" {"Build liblto-15.a"
"" "-flto" "" "-flto"
{lto-15b.c} {} "liblto-15.a"} {lto-15b.c} {} "liblto-15.a"}
{"PR ld/12696" {"PR ld/12696"
"-O2 -flto -fuse-linker-plugin -r -nostdlib" "-O2 -flto" "-O2 -flto -fuse-linker-plugin -r -nostdlib" "-O2 -flto"
{pr12696-1.cc} {} "pr12696-1r.o" "c++"} {pr12696-1.cc} {} "pr12696-1r.o" "c++"}
{"Build libdummy.a PR ld/12758" {"Compile PR ld/12758"
"" "" "" ""
{pr12758a.s} {} "libdummy.a"} {pr12758a.s} {} ""}
{"Build libpr12758.a" {"Build libpr12758.a"
"" "-flto -O2 -ffat-lto-objects" "" "-flto -O2 -ffat-lto-objects"
{pr12758b.c} {} "libpr12758.a"} {pr12758b.c} {} "libpr12758.a"}
{"PR ld/12758" {"PR ld/12758"
"-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin tmpdir/pr12758a.o -Wl,--start-group tmpdir/libpr12758.a -Wl,--end-group" "" "-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"} {dummy.c} {} "pr12758.exe"}
{"Build libdummy.a PR ld/12760" {"Compile PR ld/12760"
"" "-g -O0" "" "-g -O0"
{pr12760a.c} {} "libdummy.a"} {pr12760a.c} {} ""}
{"Build libpr12760.a" {"Build libpr12760.a"
"" "-flto -O2 -ffat-lto-objects" "" "-flto -O2 -ffat-lto-objects"
{pr12760b.c} {} "libpr12760.a"} {pr12760b.c} {} "libpr12760.a"}
@ -127,24 +127,24 @@ set lto_link_tests {
{"Build libpr13183.a" {"Build libpr13183.a"
"-T" "-flto -O2 -ffat-lto-objects" "-T" "-flto -O2 -ffat-lto-objects"
{pr13183a.c} {} "libpr13183.a"} {pr13183a.c} {} "libpr13183.a"}
{"Build libdummy.a PR ld/13183" {"Compile PR ld/13183"
"" "-flto -O2" "" "-flto -O2"
{pr13183b.c} {} "libdummy.a"} {pr13183b.c} {} ""}
{"Build libdummy.a PR ld/13201" {"Compile PR ld/13201"
"" "-flto -O2" "" "-flto -O2"
{pr13201.c} {} "libdummy.a"} {pr13201.c} {} ""}
{"PR ld/13287" {"PR ld/13287"
"-flto -fuse-linker-plugin -Wl,--as-needed" "-flto" "-flto -fuse-linker-plugin -Wl,--as-needed" "-flto"
{pr13287.cc} {} "pr13287.exe" "c++"} {pr13287.cc} {} "pr13287.exe" "c++"}
{"PR ld/15323" {"PR ld/15323"
"" "-O2" "" "-O2"
{pr15323a.c} {} "libdummy.a" "c"} {pr15323a.c} {} "" "c"}
{"Build libdummy.a(1) PR ld/pr16846" {"Compile(1) PR ld/pr16846"
"" "-flto" "" "-flto"
{pr16846a.c pr16846b.c} {} "libdummy.a"} {pr16846a.c pr16846b.c} {} ""}
{"Build libdummy.a(2) PR ld/pr16846" {"Compile(2) PR ld/pr16846"
"" "" "" ""
{pr16846c.c} {} "libdummy.a"} {pr16846c.c} {} ""}
{"PR ld/pr16846(1)" {"PR ld/pr16846(1)"
"-flto -fuse-linker-plugin tmpdir/pr16846a.o tmpdir/pr16846b.o tmpdir/pr16846c.o" "" "-flto -fuse-linker-plugin tmpdir/pr16846a.o tmpdir/pr16846b.o tmpdir/pr16846c.o" ""
{dummy.c} {} "pr16846a.exe"} {dummy.c} {} "pr16846a.exe"}
@ -155,29 +155,29 @@ set lto_link_tests {
if { [at_least_gcc_version 4 7] } { if { [at_least_gcc_version 4 7] } {
set lto_link_tests [concat $lto_link_tests { set lto_link_tests [concat $lto_link_tests {
{"Build libdummy.a PR ld/12942 (1)" {"Compile PR ld/12942 (1)"
"" "-flto -O2" "" "-flto -O2"
{pr12942a.cc pr12942c.cc} {} "libdummy.a" "c++"} {pr12942a.cc pr12942c.cc} {} "" "c++"}
{"Build libdummy.a PR ld/12942 (2)" {"Compile PR ld/12942 (2)"
"" "-O0" "" "-O0"
{pr12942b.cc} {} "libdummy.a" "c++"} {pr12942b.cc} {} "" "c++"}
}] }]
} }
# Generate input files for complex LTO tests for ELF. # Generate input files for complex LTO tests for ELF.
set lto_link_elf_tests { set lto_link_elf_tests {
{"Build libdummy.a 7" {"Compile 7"
"" "-flto -O2" "" "-flto -O2"
{lto-7a.c lto-7b.c lto-7c.c} {} "libdummy.a"} {lto-7a.c lto-7b.c lto-7c.c} {} ""}
{"Build liblto-7.so" {"Build liblto-7.so"
"-shared" "-O2 -fpic" "-shared" "-O2 -fpic"
{lto-7d.c} {} "liblto-7.so" "c"} {lto-7d.c} {} "liblto-7.so" "c"}
{"Build libdummy.a 8a" {"Compile 8a"
"" "-O2" "" "-O2"
{lto-8a.c} {} "libdummy.a"} {lto-8a.c} {} ""}
{"Build libdummy.a 8b" {"Compile 8b"
"" "-flto -O2" "" "-flto -O2"
{lto-8b.c} {} "libdummy.a"} {lto-8b.c} {} ""}
{"Build liblto-17a.so" {"Build liblto-17a.so"
"-shared -O2 -fpic -flto -fuse-linker-plugin" "-O2 -fpic -flto" "-shared -O2 -fpic -flto -fuse-linker-plugin" "-O2 -fpic -flto"
{lto-17a.c} {{"nm" {} "lto-17a.d"}} "liblto-17a.so" "c"} {lto-17a.c} {{"nm" {} "lto-17a.d"}} "liblto-17a.so" "c"}

View File

@ -1131,7 +1131,9 @@ proc run_ld_link_tests { ldtests } {
continue continue
} }
if { [regexp ".*\\.a$" $binfile] } { if { $binfile eq "tmpdir/" } {
# compile only
} elseif { [regexp ".*\\.a$" $binfile] } {
if { ![ar_simple_create $ar $ld_options $binfile "$objfiles $ld_after"] } { if { ![ar_simple_create $ar $ld_options $binfile "$objfiles $ld_after"] } {
set failed 1 set failed 1
} }
@ -1334,10 +1336,12 @@ proc run_ld_link_exec_tests { targets_to_xfail ldtests } {
set link_cmd $ld set link_cmd $ld
} }
if ![$link_proc $link_cmd $binfile "-L$srcdir/$subdir $ld_options $objfiles"] { if { $binfile eq "tmpdir/" } {
# compile only
pass $testname
continue;
} elseif ![$link_proc $link_cmd $binfile "-L$srcdir/$subdir $ld_options $objfiles"] {
set failed 1 set failed 1
} else {
set failed 0
} }
# Check if exec_output is expected. # Check if exec_output is expected.
@ -1450,18 +1454,16 @@ proc run_cc_link_tests { ldtests } {
set cc_cmd $CC set cc_cmd $CC
} }
if { [regexp ".*\\.a$" $binfile] } { if { $binfile eq "tmpdir/" } {
# compile only
} elseif { [regexp ".*\\.a$" $binfile] } {
if { ![ar_simple_create $ar $ldflags $binfile "$objfiles"] } { if { ![ar_simple_create $ar $ldflags $binfile "$objfiles"] } {
fail $testname fail $testname
set failed 1 set failed 1
} else {
set failed 0
} }
} else { } else {
if { ![ld_simple_link $cc_cmd $binfile "-L$srcdir/$subdir $ldflags $objfiles"] } { if { ![ld_simple_link $cc_cmd $binfile "-L$srcdir/$subdir $ldflags $objfiles"] } {
set failed 1 set failed 1
} else {
set failed 0
} }
# Check if exec_output is expected. # Check if exec_output is expected.
@ -1535,16 +1537,13 @@ proc run_cc_link_tests { ldtests } {
} }
} }
} }
if { $failed != 0 } {
fail $testname
} else { if { $is_unresolved == 0 } {
pass $testname
} }
} }
# Catch action errors. if { $failed != 0 } {
if { $is_unresolved != 0 } { fail $testname
} elseif { $is_unresolved == 0 } {
pass $testname
} else {
unresolved $testname unresolved $testname
continue continue
} }