diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2024-03-16 06:23:19 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2024-03-19 07:07:54 -0700 |
commit | f6080a91c5e283deff59337711091111e75d94a2 (patch) | |
tree | 143c46bfabfc7a239987b7c3bdfb7949a20f39d1 | |
parent | 2c16eb1d8346f0d390f5278d5ff187854c2d5879 (diff) | |
download | binutils-f6080a91c5e283deff59337711091111e75d94a2.zip binutils-f6080a91c5e283deff59337711091111e75d94a2.tar.gz binutils-f6080a91c5e283deff59337711091111e75d94a2.tar.bz2 |
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.
-rw-r--r-- | ld/testsuite/config/default.exp | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp index 7055430..afaf4bc 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/" } |