From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 415743858D35 for ; Tue, 19 Mar 2024 11:02:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 415743858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 415743858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710846143; cv=none; b=NQFmxyIkkCwYfjbpIYXNSjQHq8+GzSzW8GwUddt5EpnBDOAkZJMIIVi+1g5CYJFSS3xmjSUTQ199rSK6kmA2R6xcU31+EJzNxiLPfWLG09jeICh1/w3k3iJ7FueVk7f+YSUvzUY6Z7p4cmrHr7ilKQK3qdpRHHqeP2h61wLjKeA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710846143; c=relaxed/simple; bh=FawYiFidbro6q9uqor28Zu9UiFQFspj2veXrzbNFCic=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=eMe/b0VV+ZhWCfXYLWIJF6xaKYESxklOGbgoiciF8uD3KIkFp/nMFFLU0xkjU9VO5UgndCYZ55G+x9pl6KfwJ8IfLZe8lvIxohXw4IXzQQAVTWnwgDznpmriMfBLQAAJFO9fub6G3GhFuZNxgtK+qtcxghXjVeoiLLXM8W6L3kQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710846134; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=RAk7bTHP9jEMINfEmd6EbfY6p2QP8c2VL7bx4xeI6XU=; b=Vy0KClSiaVzIGKHIEfZGCb00+gGRpfleNDD4KxwyglVOrqqI61ryGHAXw5cCwMdvKvUVp6 mvpoRBF9yKhbChq46UkPOq9iiofklb2NXI7Apfi/15ugyBeMYcSBkv9hwRPDYC/OFHXKJW PQGVtBBdmmFjuxrAJY3yMAkhiqQc2hU= Received: from mail-yw1-f197.google.com (mail-yw1-f197.google.com [209.85.128.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-19-7KgSuQ3LOia4Dbdpa04BBg-1; Tue, 19 Mar 2024 07:02:12 -0400 X-MC-Unique: 7KgSuQ3LOia4Dbdpa04BBg-1 Received: by mail-yw1-f197.google.com with SMTP id 00721157ae682-60cd073522cso107267607b3.1 for ; Tue, 19 Mar 2024 04:02:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710846131; x=1711450931; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=RAk7bTHP9jEMINfEmd6EbfY6p2QP8c2VL7bx4xeI6XU=; b=QV1n7PDHz+mnuJ8tcbCoTj8+EZ1Fg8oaWWYqm33FF1XoAGPW1riDKsSX7bmMeX1C03 DJ74pDfTOdvcmn6cBGNg+gHfFd79aqwdHNqjyo5/Bd4UZm4GSXrAgaWzFJhMP0BN8dlk qeUCaALXnyglmMK5gMbh2n3BXoV48irUfo2RrYLQFNah7Q28Qz8wWwSGS+QOoce1C2Bw 4JjTT8ikB9y40qt02nPh9VKSIYfCHwV0ku3Euf3UAObz5KgeA8GQ66V1ShmE2bsBf/GT Gte9TpTQXyGsnPZDBtuVcAy8gApwJ17KeahQhoiTUVTfE870VGQa8t8xaIRydmraTKOy 9xQw== X-Gm-Message-State: AOJu0Yz50mCRZZIutERrumrdDW15vmC5IjNt6mAVwixsiHdIF6k+3bYl JXhlxYTo0wOjLXscr1y6qZbjplbFufD9ekeJLNmyN3+Y6CVds7ksm1qXQ9xQ7OcLeZCm8/m7ZIf Ic1dKpdYGKaZxlatepB4B+AplQCRTu71emris/gMCIFoTV8/1y90sKcyoDvn39Li9GJLeXZFgRB FBZJqvKthzLlElao2OP/z+fy8/nEI= X-Received: by 2002:a0d:d942:0:b0:60a:470:d1bb with SMTP id b63-20020a0dd942000000b0060a0470d1bbmr2173749ywe.20.1710846131701; Tue, 19 Mar 2024 04:02:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG0jaEf2ip++hY6OWByRJNMiQp7kWK7Iv7fHPQnNE7gWFo/1Rsx2w7lZH8U9rA0Km2QPgjmtTu56uMxaN4+Dj4= X-Received: by 2002:a0d:d942:0:b0:60a:470:d1bb with SMTP id b63-20020a0dd942000000b0060a0470d1bbmr2173734ywe.20.1710846131433; Tue, 19 Mar 2024 04:02:11 -0700 (PDT) MIME-Version: 1.0 References: <20240319105420.21568-1-iain@sandoe.co.uk> In-Reply-To: <20240319105420.21568-1-iain@sandoe.co.uk> From: Jonathan Wakely Date: Tue, 19 Mar 2024 11:01:54 +0000 Message-ID: Subject: Re: [PATCH] libstdc++, Darwin: Do not use dev/null as the file for executables. To: iain@sandoe.co.uk Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org, fxcoudert@gmail.com, nightstrike@gmail.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, 19 Mar 2024 at 10:55, Iain Sandoe wrote: > > Note that Windows-based platforms do something quite similar, but always > use the same (x.exe) filename. I wonder, in passing, if that makes a > vulnerability in parallel testing (I chose to avoid the possibility for > Darwin). Parallel testing should use a separate directory for each runtest process, so each x.exe is in a separate directory. That's a predictable name that could be used by an attacker, but I don't think it's a problem specific to parallel testing. A single runtest process has the same behaviour. > Tested on x86_64-darwin21, x86_64-linux-gnu, > OK for trunk? > back-ports where applicable (I did not yet check)? > thanks > Iain > > --- 8< --- > > 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 > --- > 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..4ae4cecb169 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 deleteting. Capital N for Note, and "deleting". OK for trunk and branches with that change. > + 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 > } > > -- > 2.39.2 (Apple Git-143) >