From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp001-out.apm-internet.net (smtp001-out.apm-internet.net [85.119.248.222]) by sourceware.org (Postfix) with ESMTPS id BA1133858D1E for ; Fri, 30 Dec 2022 08:55:26 +0000 (GMT) Received: (qmail 49831 invoked from network); 30 Dec 2022 08:55:25 -0000 X-APM-Out-ID: 16723905254982 X-APM-Authkey: 257869/1(257869/1) 2 Received: from unknown (HELO smtpclient.apple) (81.138.1.83) by smtp001.apm-internet.net with SMTP; 30 Dec 2022 08:55:25 -0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: [PATCH] Ada, Darwin: Do not link libgcc statically on Darwin [PR108202]. From: Iain Sandoe In-Reply-To: <20221224190049.99806-1-iain@sandoe.co.uk> Date: Fri, 30 Dec 2022 08:55:24 +0000 Cc: Arnaud Charlet Content-Transfer-Encoding: quoted-printable Message-Id: <596AC0EB-D5B0-412F-9D10-CB2F370B3EB7@sandoe.co.uk> References: <20221224190049.99806-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: I would like to revise this patch to be more conservative (only applying = to Darwin 8 and 9). > On 24 Dec 2022, at 19:00, Iain Sandoe via Gcc-patches = wrote: >=20 > Tested on i686, x86-64 darwin, x86_64-linux (with a 32b multilib). > OK for trunk? > Iain revised: [PATCH] Ada,Darwin: Do not link libgcc statically on Darwin 8 and 9 = [PR108202]. Normally, GCC executables are built with -static-libstdc++ = -static-libgcc on Darwin. This is fine in most cases, because GCC executables = typically do not use exceptions. However gnat1 does use exceptions and also = pulls in system libraries that are linked against the installed shared libgcc which contains the system unwinder. This means that gnat1 effectively = has two unwinder instances (which does not work reliably since the unwinders have global state). A recent change in the initialization of FDEs has made this a hard error now on Darwin versions (8 and 9) with libgcc installed in /usr/lib = (gnat1 now hangs when an exception is thrown). The solution is to link libgcc dynamically, picking up the installed system version. To do this we strip -static-libgcc from the link flags. PR ada/108202 gcc/ada/ChangeLog: * gcc-interface/Make-lang.in (GCC_LINKERFLAGS, GCC_LDFLAGS): Versions of ALL_LINKERFLAGS, LDFLAGS with -Werror and -static-libgcc filtered out for Darwin8 and 9 (-Werror is = filtered out for other hosts). --- gcc/ada/gcc-interface/Make-lang.in | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gcc/ada/gcc-interface/Make-lang.in = b/gcc/ada/gcc-interface/Make-lang.in index 2acd195017e..c81daae9c4a 100644 --- a/gcc/ada/gcc-interface/Make-lang.in +++ b/gcc/ada/gcc-interface/Make-lang.in @@ -260,11 +260,20 @@ else endif endif =20 +ifneq ($(filter darwin9% darwin8%,$(host_os)),) +# gnat1 uses exceptions which is incompatible with statically-linked = libgcc +# on Darwin8 and 9, since gnat1 also pulls in libraries linked with the = system +# unwinder. +GCC_LINKERFLAGS =3D $(filter-out -Werror -static-libgcc, = $(ALL_LINKERFLAGS)) +GCC_LDFLAGS =3D $(filter-out -static-libgcc, $(LDFLAGS)) +else # Strip -Werror during linking for the LTO bootstrap GCC_LINKERFLAGS =3D $(filter-out -Werror, $(ALL_LINKERFLAGS)) +GCC_LDFLAGS =3D $(LDFLAGS) +endif =20 -GCC_LINK=3D$(LINKER) $(GCC_LINKERFLAGS) $(LDFLAGS) -GCC_LLINK=3D$(LLINKER) $(GCC_LINKERFLAGS) $(LDFLAGS) +GCC_LINK=3D$(LINKER) $(GCC_LINKERFLAGS) $(GCC_LDFLAGS) +GCC_LLINK=3D$(LLINKER) $(GCC_LINKERFLAGS) $(GCC_LDFLAGS) =20 # Lists of files for various purposes. =20 --=20 2.37.1 (Apple Git-137.1)