From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1698) id C56943858D28; Sun, 21 Apr 2024 13:03:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C56943858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1713704597; bh=B9D953FtvHQbgL0uXcH/pHpQTsJaaIF5i+vnUiDhTmU=; h=From:To:Subject:Date:From; b=RUaeovQhjTNpIl3nbF5XQhZsTOhe2W/LqprIkMFhDQ2nI+LVpyM9uYJM3kCgd5KeD FUBVc2PZWV3xfVfEtehyNxpr9KBXKlDQC1QJoVzhUawf/kX+JwJeA8S/sBywSc3t9Y D6eqm5XtK4qnoA5/d0aYX5NHYnxdECJl5HtNT2+4= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Iain D Sandoe To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-10373] libstdc++, Darwin: Do not use dev/null as the file for executables. X-Act-Checkin: gcc X-Git-Author: Iain Sandoe X-Git-Refname: refs/heads/releases/gcc-12 X-Git-Oldrev: d450d2b3d0b36d5f2715f204cb0ad2ff1759d3c8 X-Git-Newrev: 678f6bc1655d9bf4ecec06e733122823a512ee4d Message-Id: <20240421130317.C56943858D28@sourceware.org> Date: Sun, 21 Apr 2024 13:03:17 +0000 (GMT) List-Id: https://gcc.gnu.org/g:678f6bc1655d9bf4ecec06e733122823a512ee4d commit r12-10373-g678f6bc1655d9bf4ecec06e733122823a512ee4d Author: Iain Sandoe 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 (cherry picked from commit e47330d0742c985fd8d5fe7089aa381d34967d61) Diff: --- libstdc++-v3/testsuite/lib/libstdc++.exp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp index 0debbea7ee1..789d0fce549 100644 --- a/libstdc++-v3/testsuite/lib/libstdc++.exp +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp @@ -510,11 +510,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 }