diff options
author | Clément Chigot <chigot@adacore.com> | 2024-12-09 11:00:07 +0100 |
---|---|---|
committer | Clément Chigot <chigot@adacore.com> | 2025-01-06 14:01:09 +0100 |
commit | 7edefdf710da60f0aa8fa3579df0d6159d42af3a (patch) | |
tree | fc264f31466134682fbb2ad10afaa3009fc82267 | |
parent | e88c452e6f0cb1cfe75f988c36821bdc1f67b01c (diff) | |
download | fsf-binutils-gdb-users/chigot/try-lto-board-flags.zip fsf-binutils-gdb-users/chigot/try-lto-board-flags.tar.gz fsf-binutils-gdb-users/chigot/try-lto-board-flags.tar.bz2 |
ld/testsuite: move board flags to ld_linkusers/chigot/try-lto-board-flags
Both CFLAGS and LDFLAGS provided by dejagnu board configuration could be
required to perform a link.
Up to now, those flags were pulled with run_cc_link_tests and
run_ld_link_exec_tests and then passed to ld_link process as arguments.
This means that calling `ld_link` outside those functions must remember
to manually pass them.
-rw-r--r-- | ld/testsuite/ld-unique/unique.exp | 7 | ||||
-rw-r--r-- | ld/testsuite/lib/ld-lib.exp | 25 |
2 files changed, 16 insertions, 16 deletions
diff --git a/ld/testsuite/ld-unique/unique.exp b/ld/testsuite/ld-unique/unique.exp index 855e255..fe77516 100644 --- a/ld/testsuite/ld-unique/unique.exp +++ b/ld/testsuite/ld-unique/unique.exp @@ -113,13 +113,8 @@ if ![ld_compile "$CC_FOR_TARGET -c" "$srcdir/$subdir/unique_empty.s" "tmpdir/uni set fails [expr $fails + 1] } -# When using GCC as the linker driver, we need to specify board cflags when -# linking because cflags may contain linker options. For example when linker -# options are included in GCC spec files then we need the -specs option. -set board_flags [get_board_flags] - # Create executable containing unique symbol. -if ![ld_link "$CC_FOR_TARGET $NOPIE_LDFLAGS $board_flags" "tmpdir/unique_prog" "tmpdir/unique.o"] { +if ![ld_link "$CC_FOR_TARGET $NOPIE_LDFLAGS" "tmpdir/unique_prog" "tmpdir/unique.o"] { fail "Could not link a unique executable" set fails [expr $fails + 1] } diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp index bd2dd50..55f26d6 100644 --- a/ld/testsuite/lib/ld-lib.exp +++ b/ld/testsuite/lib/ld-lib.exp @@ -210,6 +210,17 @@ proc default_ld_link { ld target objects } { set flags [big_or_little_endian] } + # When using GCC as the linker driver, we need to specify board cflags when + # linking because cflags may contain linker options. For example when + # linker options are included in GCC spec files then we need the -specs + # option. + set gccexe [string replace $ld 0 [string last "/" $ld] ""] + if {[string match "*cc*" $gccexe] || + [string match "*++*" $gccexe] || + [string match "clang*" $gccexe]} then { + set flags "$flags [get_board_flags]" + } + remote_file host delete $target set exec_output [run_host_cmd "$ld" "$flags -o $target $objects"] set exec_output [prune_warnings $exec_output] @@ -701,12 +712,6 @@ proc run_ld_link_exec_tests { ldtests args } { global exec_output global STATIC_LDFLAGS - # When using GCC as the linker driver, we need to specify board cflags when - # linking because cflags may contain linker options. For example when - # linker options are included in GCC spec files then we need the -specs - # option. - set board_flags [get_board_flags] - foreach testitem $ldtests { set testname [lindex $testitem 0] set ld_options [lindex $testitem 1] @@ -786,12 +791,13 @@ proc run_ld_link_exec_tests { ldtests args } { pass $testname continue; } else { + set board_flags [get_board_flags] if { [string match "" $STATIC_LDFLAGS] \ && [regexp -- ".* \[-\]+static .*" " $board_flags $ld_options $objfiles $ld_after "] } { untested $testname continue } - if ![$link_proc $link_cmd $binfile "$board_flags -L$srcdir/$subdir $ld_options $objfiles $ld_after"] { + if ![$link_proc $link_cmd $binfile " -L$srcdir/$subdir $ld_options $objfiles $ld_after"] { set failed 1 } } @@ -867,8 +873,6 @@ proc run_cc_link_tests { ldtests } { global exec_output global STATIC_LDFLAGS - set board_flags [get_board_flags] - foreach testitem $ldtests { set testname [lindex $testitem 0] set ldflags [lindex $testitem 1] @@ -975,12 +979,13 @@ proc run_cc_link_tests { ldtests } { set failed 1 } } else { + set board_flags [get_board_flags] if { [string match "" $STATIC_LDFLAGS] \ && [regexp -- ".* \[-\]+static .*" " $board_flags $ldflags $objfiles "] } { untested $testname continue } - ld_link $cc_cmd $binfile "$board_flags -L$srcdir/$subdir $ldflags $objfiles" + ld_link $cc_cmd $binfile "-L$srcdir/$subdir $ldflags $objfiles" set ld_output "$exec_output" if { $check_ld(source) == "regexp" } then { |