From e6a6c7676a7df49cfbbffda26eadd2032dbc2bbe Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 31 Jul 2020 07:40:27 -0700 Subject: ld: Add -fno-lto to linker tests LTO can be used to build binutils with $ CC="gcc -flto -ffat-lto-objects -Wl,--as-needed" CXX="g++ -flto -ffat-lto-objects -Wl,--as-needed" .../configure But not all linker tests are compatible with LTO. Pass -fno-lto to CC to disable LTO on linker tests by default. -flto is passed explicitly to CC in linker LTO tests. * testsuite/ld-elf/indirect.exp: Append -fno-lto to CC. * testsuite/ld-elfvers/vers.exp: Likewise. * testsuite/ld-elfweak/elfweak.exp: Likewise. * testsuite/ld-ifunc/ifunc.exp: Likewise. * testsuite/ld-plugin/lto.exp (no_lto): New. Add $no_lto to build pr15146c.so. * testsuite/lib/ld-lib.exp (at_least_gcc_version): Filter out -Wl,xxx options. (check_gcc_plugin_enabled): Likewise. (run_ld_link_exec_tests): Prepend -fno-lto to $cflags. (run_cc_link_tests): Likewise. --- ld/testsuite/ld-elf/indirect.exp | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'ld/testsuite/ld-elf/indirect.exp') diff --git a/ld/testsuite/ld-elf/indirect.exp b/ld/testsuite/ld-elf/indirect.exp index acda39e..8acae4d 100644 --- a/ld/testsuite/ld-elf/indirect.exp +++ b/ld/testsuite/ld-elf/indirect.exp @@ -58,19 +58,25 @@ proc check_link_message { cmd string testname } { } } -if { ![ld_compile $CC $srcdir/$subdir/indirect1a.c tmpdir/indirect1a.o] - || ![ld_compile $CC $srcdir/$subdir/indirect1b.c tmpdir/indirect1b.o] - || ![ld_compile "$CC -fPIC" $srcdir/$subdir/indirect2.c tmpdir/indirect2.o] - || ![ld_compile $CC $srcdir/$subdir/indirect3a.c tmpdir/indirect3a.o] - || ![ld_compile $CC $srcdir/$subdir/indirect3b.c tmpdir/indirect3b.o] - || ![ld_compile $CC $srcdir/$subdir/indirect4a.c tmpdir/indirect4a.o] - || ![ld_compile $CC $srcdir/$subdir/indirect4b.c tmpdir/indirect4b.o] - || ![ld_compile "$CC -O2 -fPIC -I../bfd" $srcdir/$subdir/pr18720a.c tmpdir/pr18720a.o] - || ![ld_compile $CC $srcdir/$subdir/pr18720b.c tmpdir/pr18720b.o] - || ![ld_compile "$CC -fPIC" $srcdir/$subdir/pr19553d.c tmpdir/pr19553d.o] - || ![ld_compile "$CC -fPIC" $srcdir/$subdir/pr19553c.c tmpdir/pr19553c.o] - || ![ld_compile "$CC -fPIC" $srcdir/$subdir/pr19553b.c tmpdir/pr19553b.o] - || ![ld_compile $CC $srcdir/$subdir/pr19553a.c tmpdir/pr19553a.o] } { +# Disable LTO for these tests. +set cc_cmd "$CC" +if {[check_lto_available]} { + append cc_cmd " -fno-lto" +} + +if { ![ld_compile $cc_cmd $srcdir/$subdir/indirect1a.c tmpdir/indirect1a.o] + || ![ld_compile $cc_cmd $srcdir/$subdir/indirect1b.c tmpdir/indirect1b.o] + || ![ld_compile "$cc_cmd -fPIC" $srcdir/$subdir/indirect2.c tmpdir/indirect2.o] + || ![ld_compile $cc_cmd $srcdir/$subdir/indirect3a.c tmpdir/indirect3a.o] + || ![ld_compile $cc_cmd $srcdir/$subdir/indirect3b.c tmpdir/indirect3b.o] + || ![ld_compile $cc_cmd $srcdir/$subdir/indirect4a.c tmpdir/indirect4a.o] + || ![ld_compile $cc_cmd $srcdir/$subdir/indirect4b.c tmpdir/indirect4b.o] + || ![ld_compile "$cc_cmd -O2 -fPIC -I../bfd" $srcdir/$subdir/pr18720a.c tmpdir/pr18720a.o] + || ![ld_compile $cc_cmd $srcdir/$subdir/pr18720b.c tmpdir/pr18720b.o] + || ![ld_compile "$cc_cmd -fPIC" $srcdir/$subdir/pr19553d.c tmpdir/pr19553d.o] + || ![ld_compile "$cc_cmd -fPIC" $srcdir/$subdir/pr19553c.c tmpdir/pr19553c.o] + || ![ld_compile "$cc_cmd -fPIC" $srcdir/$subdir/pr19553b.c tmpdir/pr19553b.o] + || ![ld_compile $cc_cmd $srcdir/$subdir/pr19553a.c tmpdir/pr19553a.o] } { unresolved "Indirect symbol tests" return } -- cgit v1.1