[binutils-gdb] ld: Support LD_UNDER_TEST environment variable
H.J. Lu
hjl@sourceware.org
Tue Mar 19 14:08:26 GMT 2024
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f6080a91c5e283deff59337711091111e75d94a2
commit f6080a91c5e283deff59337711091111e75d94a2
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Sat Mar 16 06:23:19 2024 -0700
ld: Support LD_UNDER_TEST environment variable
Support LD_UNDER_TEST environment variable to test a different linker.
Issue an error if LD_UNDER_TEST isn't an absolute full path.
* testsuite/config/default.exp: If LD_UNDER_TEST environment
variable exists, set ld and LD to it and set up tmpdir/ld/ld.
Issue an error if LD_UNDER_TEST isn't an absolute full path.
Diff:
---
ld/testsuite/config/default.exp | 30 ++++++++++++++++++++++++++----
1 file changed, 26 insertions(+), 4 deletions(-)
diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp
index 705543054c2..afaf4bcb1ff 100644
--- a/ld/testsuite/config/default.exp
+++ b/ld/testsuite/config/default.exp
@@ -21,6 +21,23 @@
# Written by Jeffrey Wheat (cassidy@cygnus.com)
#
+if [info exists env(LD_UNDER_TEST)] {
+ # LD_UNDER_TEST must be an absolute full path.
+ if {[file pathtype $env(LD_UNDER_TEST)] ne "absolute"} {
+ perror "**************************************************"
+ perror "Environment variable LD_UNDER_TEST ($env(LD_UNDER_TEST)) isn't an absolute full path."
+ perror "**************************************************"
+ exit 1
+ } elseif {![file exists $env(LD_UNDER_TEST)]} {
+ perror "**************************************************"
+ perror "Environment variable LD_UNDER_TEST ($env(LD_UNDER_TEST)) doesn't exist."
+ perror "**************************************************"
+ exit 1
+ }
+ set ld "$env(LD_UNDER_TEST)"
+ set LD "$ld"
+}
+
if ![info exists ld] then {
set ld [findfile $base_dir/ld-new $base_dir/ld-new [transform ld]]
}
@@ -64,12 +81,17 @@ remote_exec host "mkdir -p tmpdir"
if {[info exists ld_testsuite_bindir]} {
set gcc_B_opt "-B$ld_testsuite_bindir/"
} else {
- if {![file isdirectory tmpdir/ld]} then {
- catch "exec mkdir tmpdir/ld" status
+ # Delete tmpdir/ld first to remove tmpdir/ld/ld created by the
+ # previous LD_UNDER_TEST runs.
+ file delete -force tmpdir/ld
+ catch "exec mkdir tmpdir/ld" status
+ if [info exists env(LD_UNDER_TEST)] {
+ catch "exec ln -s $env(LD_UNDER_TEST) tmpdir/ld/ld" status
+ } else {
catch "exec ln -s ../../ld-new tmpdir/ld/ld" status
- catch "exec ln -s ld tmpdir/ld/collect-ld" status
- catch "exec ln -s ../../../gas/as-new tmpdir/ld/as" status
}
+ catch "exec ln -s ld tmpdir/ld/collect-ld" status
+ catch "exec ln -s ../../../gas/as-new tmpdir/ld/as" status
set gcc_B_opt "-B[pwd]/tmpdir/ld/"
}
More information about the Binutils-cvs
mailing list