public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2] ld: Support LD_UNDER_TEST environment variable
@ 2024-03-16 15:34 H.J. Lu
  2024-03-16 16:15 ` Andreas Schwab
  0 siblings, 1 reply; 2+ messages in thread
From: H.J. Lu @ 2024-03-16 15:34 UTC (permalink / raw)
  To: binutils

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.
---
 ld/testsuite/config/default.exp | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp
index 705543054c2..25e94ac8df6 100644
--- a/ld/testsuite/config/default.exp
+++ b/ld/testsuite/config/default.exp
@@ -21,6 +21,19 @@
 # Written by Jeffrey Wheat (cassidy@cygnus.com)
 #
 
+if [info exists env(LD_UNDER_TEST)] {
+    # LD_UNDER_TEST must be an absolute full path.
+    catch "file dirname $env(LD_UNDER_TEST)" dirname
+    if {[string index $dirname 0] ne "/"} {
+	perror "**************************************************"
+	perror "$env(LD_UNDER_TEST) isn't an absolute full path."
+	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,9 +77,16 @@ remote_exec host "mkdir -p tmpdir"
 if {[info exists ld_testsuite_bindir]} {
     set gcc_B_opt "-B$ld_testsuite_bindir/"
 } else {
+    if [info exists env(LD_UNDER_TEST)] {
+	file delete -force tmpdir/ld
+    }
     if {![file isdirectory tmpdir/ld]} then {
 	catch "exec mkdir tmpdir/ld" status
-	catch "exec ln -s ../../ld-new tmpdir/ld/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
     }
-- 
2.44.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] ld: Support LD_UNDER_TEST environment variable
  2024-03-16 15:34 [PATCH v2] ld: Support LD_UNDER_TEST environment variable H.J. Lu
@ 2024-03-16 16:15 ` Andreas Schwab
  0 siblings, 0 replies; 2+ messages in thread
From: Andreas Schwab @ 2024-03-16 16:15 UTC (permalink / raw)
  To: H.J. Lu; +Cc: binutils

On Mär 16 2024, H.J. Lu wrote:

> 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.
> ---
>  ld/testsuite/config/default.exp | 22 +++++++++++++++++++++-
>  1 file changed, 21 insertions(+), 1 deletion(-)
>
> diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp
> index 705543054c2..25e94ac8df6 100644
> --- a/ld/testsuite/config/default.exp
> +++ b/ld/testsuite/config/default.exp
> @@ -21,6 +21,19 @@
>  # Written by Jeffrey Wheat (cassidy@cygnus.com)
>  #
>  
> +if [info exists env(LD_UNDER_TEST)] {
> +    # LD_UNDER_TEST must be an absolute full path.
> +    catch "file dirname $env(LD_UNDER_TEST)" dirname
> +    if {[string index $dirname 0] ne "/"} {

[file pathtype $env(LD_UNDER_TEST)] ne "absolute"

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-03-16 16:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-16 15:34 [PATCH v2] ld: Support LD_UNDER_TEST environment variable H.J. Lu
2024-03-16 16:15 ` Andreas Schwab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).