From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp002.apm-internet.net (smtp002.apm-internet.net [85.119.248.221]) by sourceware.org (Postfix) with ESMTPS id 43E363858D1E for ; Thu, 22 Dec 2022 19:14:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 43E363858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sandoe.co.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=sandoe.co.uk Received: (qmail 67260 invoked from network); 22 Dec 2022 19:14:19 -0000 X-APM-Out-ID: 16717364596725 X-APM-Authkey: 257869/1(257869/1) 2 Received: from unknown (HELO smtpclient.apple) (81.138.1.83) by smtp002.apm-internet.net with SMTP; 22 Dec 2022 19:14:19 -0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: [Ping^1] [PATCH] c++, driver: Fix -static-libstdc++ for targets without Bstatic/dynamic. From: Iain Sandoe In-Reply-To: <20221204163047.72124-1-iain@sandoe.co.uk> Date: Thu, 22 Dec 2022 19:14:19 +0000 Cc: Jason Merrill Content-Transfer-Encoding: quoted-printable Message-Id: <3CB7C34D-3B60-4A6B-B736-29B0AD9A6D37@sandoe.co.uk> References: <20221204163047.72124-1-iain@sandoe.co.uk> To: GCC Patches X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_COUK,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW,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: Hi this has become more important since it seems I can no longer link a = working gnat1 without it, thanks Iain > On 4 Dec 2022, at 16:30, Iain Sandoe via Gcc-patches = wrote: >=20 > This fixes a long-standing problem on Darwin where we cannot = independently set > -static-libstdc++ because the flag gets stripped by the g++ driver. >=20 > 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. >=20 > OK for master? > backports? > thanks > Iain >=20 > -- >8 -- >=20 > 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). >=20 > 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. >=20 > Signed-off-by: Iain Sandoe >=20 > gcc/cp/ChangeLog: >=20 > * 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(+) >=20 > 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, >=20 > case OPT_static_libstdc__: > library =3D library >=3D 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] |=3D SKIPOPT; > +#endif > break; >=20 > case OPT_stdlib_: > --=20 > 2.37.1 (Apple Git-137.1) >=20