aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-plugin
diff options
context:
space:
mode:
authorClément Chigot <chigot@adacore.com>2024-12-10 14:08:44 +0100
committerClément Chigot <chigot@adacore.com>2025-01-07 14:07:19 +0100
commit14c460302b59a274c10f10bfd4156d8259327176 (patch)
tree0a8b87094e958c7fa9f3fccf2867fdf5d77f7a36 /ld/testsuite/ld-plugin
parentf79e481b572096449ab75488b70e184869328c90 (diff)
downloadgdb-14c460302b59a274c10f10bfd4156d8259327176.zip
gdb-14c460302b59a274c10f10bfd4156d8259327176.tar.gz
gdb-14c460302b59a274c10f10bfd4156d8259327176.tar.bz2
ld/testsuite/lto: replace manual links by ld_link helper
Some tests are calling run_host_cmd in order to retrieve the errors/warnings messages generated. ld_link is also making them available through exec_output global variable but as the advantages of taking the board configuration into account unlike run_host_cmd.
Diffstat (limited to 'ld/testsuite/ld-plugin')
-rw-r--r--ld/testsuite/ld-plugin/lto.exp27
1 files changed, 15 insertions, 12 deletions
diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index b0816c4..e36480a 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -905,10 +905,8 @@ run_cc_link_tests $lto_compile_elf_tests
#
# Update LDPT_REGISTER_CLAIM_FILE_HOOK_V2 linker plugin hook
#
-set exec_output [run_host_cmd "$CC_FOR_TARGET" \
- "-O2 -fcommon -flto -o tmpdir/common-2 \
- tmpdir/common-2a.o tmpdir/libcommon-2.a \
- tmpdir/libcommon-2.a"]
+ld_link "$CC_FOR_TARGET" pr32083.exe "-O2 -fcommon -flto -o tmpdir/common-2 \
+ tmpdir/common-2a.o tmpdir/libcommon-2.a tmpdir/libcommon-2.a"
if [string match "" $exec_output] then {
pass "PR ld/32083"
} elseif { [ regexp "lto1: fatal error: multiple prevailing defs for 'func'" $exec_output ] } {
@@ -919,23 +917,25 @@ if [string match "" $exec_output] then {
# Restrict these to ELF targets that support shared libs and PIC.
if { [is_elf_format] && [check_lto_shared_available] } {
+ global exec_output
+
run_cc_link_tests $lto_link_elf_tests
set testname "PR ld/15146 (2)"
- set exec_output [run_host_cmd "$CC_FOR_TARGET" "-O2 -flto -fuse-linker-plugin -Wl,-rpath-link,. -Wl,--no-copy-dt-needed-entries -Wl,--no-as-needed tmpdir/pr15146d.o tmpdir/pr15146c.so"]
+ ld_link "$CC_FOR_TARGET" pr15146-2.exe "-O2 -flto -fuse-linker-plugin -Wl,-rpath-link,. -Wl,--no-copy-dt-needed-entries -Wl,--no-as-needed tmpdir/pr15146d.o tmpdir/pr15146c.so"
if { [ regexp "undefined reference to symbol '\\.?xxx'" $exec_output ] } {
pass $testname
} {
fail $testname
}
set testname "PR ld/16746 (3)"
- set exec_output [run_host_cmd "$CC_FOR_TARGET" "-O2 -flto -fuse-linker-plugin tmpdir/pr16746b.o tmpdir/pr16746d.o"]
+ ld_link "$CC_FOR_TARGET" pr16746-3.exe "-O2 -flto -fuse-linker-plugin tmpdir/pr16746b.o tmpdir/pr16746d.o"
if { [ regexp "warning: \\.?foobar" $exec_output ] && ![ regexp "symbol from plugin" $exec_output ] } {
pass $testname
} {
fail $testname
}
set testname "PR ld/16746 (4)"
- set exec_output [run_host_cmd "$CC_FOR_TARGET" "-O2 -flto -fuse-linker-plugin tmpdir/pr16746d.o tmpdir/pr16746b.o"]
+ ld_link "$CC_FOR_TARGET" pr16746-4.exe "-O2 -flto -fuse-linker-plugin tmpdir/pr16746d.o tmpdir/pr16746b.o"
if { [ regexp "warning: \\.?foobar" $exec_output ] && ![ regexp "symbol from plugin" $exec_output ] } {
pass $testname
} {
@@ -957,10 +957,11 @@ run_cc_link_tests [list \
] \
]
+set board_flags [get_board_flags]
set exec_output [run_host_cmd "sh" \
"-c \"ulimit -n 20; \
$CC_FOR_TARGET $gcc_B_opt $CFLAGS_FOR_TARGET \
- $ld_L_opt -o tmpdir/pr28138 \
+ $board_flags $ld_L_opt -o tmpdir/pr28138 \
tmpdir/pr28138.o tmpdir/pr28138.a\""]
set exec_output [prune_warnings $exec_output]
if [string match "" $exec_output] then {
@@ -991,14 +992,15 @@ if { [at_least_gcc_version 4 7] } {
# Check expected LTO linker errors.
# Since the asm symbol name hack in pr12365b.c doesn't work on all
# targets, run PR ld/12365 tests only for known targets.
+ global exec_output
+
if { ([istarget "i?86-*-elf*"]
|| [istarget "i?86-*-linux*"]
|| [istarget "i?86-*-gnu*"]
|| [istarget "x86_64-*-linux*"]
|| [istarget "amd64-*-linux*"]) } {
set testname "PR ld/12365"
- set exec_output [run_host_cmd "$CC_FOR_TARGET" "-O2 -flto -flto-partition=none -fuse-linker-plugin -o tmpdir/pr12365 tmpdir/pr12365a.o tmpdir/pr12365b.o tmpdir/pr12365c.o"]
- set exec_output [prune_warnings $exec_output]
+ ld_link "$CC_FOR_TARGET" pr12365.exe "-O2 -flto -flto-partition=none -fuse-linker-plugin -o tmpdir/pr12365 tmpdir/pr12365a.o tmpdir/pr12365b.o tmpdir/pr12365c.o"
if { [ regexp "undefined reference to `my_bcopy'" $exec_output ] } {
# Linker should catch the reference to undefined `my_bcopy'
# error caused by a GCC bug.
@@ -1045,7 +1047,7 @@ if { [at_least_gcc_version 4 7] } {
]
}
set testname "PR ld/12942 (3)"
- set exec_output [run_host_cmd "$CXX_FOR_TARGET" "-O2 -flto -fuse-linker-plugin tmpdir/pr12942b.o tmpdir/pr12942a.o"]
+ ld_link "$CXX_FOR_TARGET" pr12942-3.exe "-O2 -flto -fuse-linker-plugin tmpdir/pr12942b.o tmpdir/pr12942a.o"
if { [ regexp "undefined reference to `\\.?link_error\\(\\)'" $exec_output ] } {
pass $testname
} {
@@ -1138,9 +1140,10 @@ if { [is_elf_format] && [check_lto_shared_available] } {
proc pr20103 {cflags libs} {
global CC_FOR_TARGET
+ global exec_output
set testname "PR ld/20103 ($cflags $libs)"
- set exec_output [run_host_cmd "$CC_FOR_TARGET" "$cflags $libs"]
+ ld_link "$CC_FOR_TARGET" pr20103.exe "$cflags $libs"
# NB: Starting from GCC 4.9, -flto is optional for final link.
if { [ regexp "fatpr20103" "$libs" ] \
&& ([regexp " -flto" "$cflags"] \