public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Iain D Sandoe <iains@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r14-9541] libstdc++, Darwin: Do not use dev/null as the file for executables.
Date: Tue, 19 Mar 2024 12:48:54 +0000 (GMT)	[thread overview]
Message-ID: <20240319124854.5EC5F3858D37@sourceware.org> (raw)

https://gcc.gnu.org/g:e47330d0742c985fd8d5fe7089aa381d34967d61

commit r14-9541-ge47330d0742c985fd8d5fe7089aa381d34967d61
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Tue Mar 19 10:40:50 2024 +0000

    libstdc++, Darwin: Do not use dev/null as the file for executables.
    
    Darwin has a separate debug linker, which is invoked when the command
    line contains source files and debug is enabled.
    
    Using /dev/null as the executable name does not, therefore, work when
    debug is enabled, since the debug linker does not accept /dev/null as
    a valid executable name.
    
    The leads to incorrectly UNSUPPORTED testcases because of the unintended
    error result from the test compilation.
    
    The solution here is to use a temporary file that is deleted at the
    end of the test (which is the mechanism used elsewhere)
    
    libstdc++-v3/ChangeLog:
    
            * testsuite/lib/libstdc++.exp (v3_target_compile): Instead of
            /dev/null, use a temporary file for test executables on Darwin.
    
    Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

Diff:
---
 libstdc++-v3/testsuite/lib/libstdc++.exp | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 58804ecab26..7466fb51c58 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -615,11 +615,15 @@ proc v3_target_compile { source dest type options } {
 	}
     }
 
+    # For Windows and Darwin we might want to create a temporary file.
+    # Note that it needs deleting.
+    set file_to_delete ""
     # Small adjustment for Windows hosts.
     if { $dest == "/dev/null"
 	  && [info exists ::env(OS)] && [string match "Windows*" $::env(OS)] } {
 	if { $type == "executable" } {
 	    set dest "x.exe"
+	    set file_to_delete ${dest}
 	} else {
 	    # Windows uses special file named "nul" as a substitute for
 	    # /dev/null
@@ -627,6 +631,15 @@ proc v3_target_compile { source dest type options } {
 	}
     }
 
+    # Using /dev/null as the executable name does not work on Darwin when
+    # debug is enabled, since the debug linker does not accept /dev/null as
+    # a valid executable name.
+    if { $dest == "/dev/null" && [istarget *-*-darwin*]
+         && $type == "executable" } {
+	set dest dev-null-[pid].exe
+	set file_to_delete ${dest}
+    }
+
     lappend options "compiler=$cxx_final"
     lappend options "timeout=[timeout_value]"
 
@@ -637,7 +650,12 @@ proc v3_target_compile { source dest type options } {
     }
 
     set comp_output [target_compile $source $dest $type $options]
-
+    if { $type == "executable" && $file_to_delete != "" } {
+	file delete $file_to_delete
+	if { [istarget *-*-darwin*] && [file exists $file_to_delete.dSYM] } {
+	    file delete -force $file_to_delete.dSYM
+	}
+    }
     return $comp_output
 }

                 reply	other threads:[~2024-03-19 12:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240319124854.5EC5F3858D37@sourceware.org \
    --to=iains@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).