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.133.124]) by sourceware.org (Postfix) with ESMTPS id 111F23858D1E for ; Thu, 22 Dec 2022 21:15:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 111F23858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671743739; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LnRXIhYPZM1DNytYtKzSqOxpNlteHmW0iJqFtkmHOVc=; b=hwhcwm/WBg98riFcOtB38qpNwlX6OALNKRbBmnAuCVTeQs/nMcKSGO7z0mnj+UfkM5LPvT P53nO92xKNAIkYMC6O2+9Fm8KtP3FSP28iCtj5MeYV/4TAAEzW9weCCAcvrAu5UtL1w0Oq ezkB1eDd2Ag1l+b6+JZOTZXpuK2CGAw= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-262-JYEWjxaiNzWL4nUAJrSGGw-1; Thu, 22 Dec 2022 16:15:38 -0500 X-MC-Unique: JYEWjxaiNzWL4nUAJrSGGw-1 Received: by mail-qk1-f199.google.com with SMTP id bm30-20020a05620a199e00b006ff813575b1so1939072qkb.16 for ; Thu, 22 Dec 2022 13:15:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LnRXIhYPZM1DNytYtKzSqOxpNlteHmW0iJqFtkmHOVc=; b=4KR+8MIsGdRO6rjTfJdy+DUBSIVbg7CsTH0aaWWaEsXi2y2ap80PtA8XYVIeKbYHDX a7SxawkIR+Y/m52uJSGM7qYSEqENnRJ1Z/lrs3ik9OgE817l3V9Ba6c9DC+AdSr77D71 PMxFtgT0FQuLc5kDQu3BQnMZdkaPC0ofZbvKOgw6rIp/mRALJ1SoNoPMUx8ddVTpLqF7 z1820SumhZJAYRrv6z4H2JKGT6uzbjzr+Uo/39VunhI+UYxqzBSHm3KqQOgn3Af0F1LL 8fjA7XAp5/bnnNQ/edsR2JYel9aJ6vxsUafMK8D9Io4lxUscvSd/d2sfU9m+TYZ+LaS/ bmxQ== X-Gm-Message-State: AFqh2kqcyx6XrPkk+aeMKQjihSk0XtlE2fcmES7mx1p4VidN2b6QpRhx KgFIEe52c6YEnBqJQzpdCfnoDtMqfy+2h2FCwcVuvZE6Dq8EYorkRT5W972XMCHFiWtD19YEdMu cRp8o6MyVj4CVyRx6/Q== X-Received: by 2002:a05:6214:5c87:b0:4c7:d93:f918 with SMTP id lj7-20020a0562145c8700b004c70d93f918mr9695623qvb.18.1671743737368; Thu, 22 Dec 2022 13:15:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXv8AUJbT78XdkMI/glHj1adUROHr/NLjfpAarrbdvl7zqr/O10eBoe2prhm0PCdEB7Uj1CgJQ== X-Received: by 2002:a05:6214:5c87:b0:4c7:d93:f918 with SMTP id lj7-20020a0562145c8700b004c70d93f918mr9695596qvb.18.1671743737039; Thu, 22 Dec 2022 13:15:37 -0800 (PST) Received: from [192.168.1.108] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id u2-20020a37ab02000000b006fc92cf4703sm905439qke.132.2022.12.22.13.15.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Dec 2022 13:15:35 -0800 (PST) Message-ID: Date: Thu, 22 Dec 2022 16:15:35 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH] c++, driver: Fix -static-libstdc++ for targets without Bstatic/dynamic. To: iain@sandoe.co.uk, gcc-patches@gcc.gnu.org References: <20221204163047.72124-1-iain@sandoe.co.uk> From: Jason Merrill In-Reply-To: <20221204163047.72124-1-iain@sandoe.co.uk> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP 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 12/4/22 11:30, Iain Sandoe wrote: > This fixes a long-standing problem on Darwin where we cannot independently set > -static-libstdc++ because the flag gets stripped by the g++ driver. > > This patch is essentially the same as the one used for the 'D' driver and has > been in local use for some time. It has also been tested on Linux. > > OK for master? > backports? > thanks > Iain > > -- >8 -- > > The current implementation for swapping between the static and shared c++ > runtimes relies on the static linker supporting Bstatic/dynamic which is > not available for every target (Darwin's linker does not support this). > > Specs substitution (%s) is an alternative solution for this (which is what > Darwin uses for Fortran, D and Objective-C). However, specs substitution > requires that the '-static-libstdc++' be preserved in the driver's command > line. The patch here arranges for this to be done when the configuration > determines that linker support for Bstatic/dynamic is missing. Would it work to define LIBSTDCXX_STATIC instead? If not, the patch is OK. Really there should be a way for lang_specific_driver to mark a flag as "validated" rather than prune it. > Signed-off-by: Iain Sandoe > > gcc/cp/ChangeLog: > > * g++spec.cc (lang_specific_driver): Preserve -static-libstdc++ in > the driver command line for targets without -Bstatic/dynamic support > in their static linker. > --- > gcc/cp/g++spec.cc | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/gcc/cp/g++spec.cc b/gcc/cp/g++spec.cc > index 3d3b042dd56..f95d7965355 100644 > --- a/gcc/cp/g++spec.cc > +++ b/gcc/cp/g++spec.cc > @@ -234,7 +234,12 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, > > case OPT_static_libstdc__: > library = library >= 0 ? 2 : library; > +#ifdef HAVE_LD_STATIC_DYNAMIC > + /* Remove -static-libstdc++ from the command only if target supports > + LD_STATIC_DYNAMIC. When not supported, it is left in so that a > + back-end target can use outfile substitution. */ > args[i] |= SKIPOPT; > +#endif > break; > > case OPT_stdlib_: