]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++, Darwin: Do not use dev/null as the file for executables.
authorIain Sandoe <iain@sandoe.co.uk>
Tue, 19 Mar 2024 10:40:50 +0000 (10:40 +0000)
committerIain Sandoe <iain@sandoe.co.uk>
Mon, 29 Apr 2024 07:04:48 +0000 (08:04 +0100)
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>
(cherry picked from commit e47330d0742c985fd8d5fe7089aa381d34967d61)

libstdc++-v3/testsuite/lib/libstdc++.exp

index 527d6ba07115a5993976ee0ce938024ba377ab51..dde67de3eb75d371cc438e151e3997862e1e686c 100644 (file)
@@ -507,11 +507,41 @@ 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
+           set dest "nul"
+       }
+    }
+
+    # 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]"
 
     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
 }