From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1698) id 56A583858413; Mon, 2 Jan 2023 10:53:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 56A583858413 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672656816; bh=oaq8kIDqF0qRZ4T5jJtjLsKgFWuXdXA948zYrhWEx5g=; h=From:To:Subject:Date:From; b=uskrhEfqfiXP1WeObFBGl6KPLD2Bf34JPhvEwki7mto2sLre/+BmrzyKPlWUJFslC mT0dMmwFCvGmilDruFFTTTch1arlBSD5st7DdYq4OPvUr738LNjb5fDHz/c5T0P6g2 Xkkndfd7epBAkv4s/LEgQpatF9a0s0JN+4cXWXrY= MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Iain D Sandoe To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4952] Ada, Darwin: Do not link libgcc statically on Darwin 8 and 9 [PR108202]. X-Act-Checkin: gcc X-Git-Author: Iain Sandoe X-Git-Refname: refs/heads/master X-Git-Oldrev: 46c0ea7704e9da9e6d574afc7ca1d218f49d237a X-Git-Newrev: 8385088039f58a1d403cbb0792105236d240de85 Message-Id: <20230102105336.56A583858413@sourceware.org> Date: Mon, 2 Jan 2023 10:53:36 +0000 (GMT) List-Id: https://gcc.gnu.org/g:8385088039f58a1d403cbb0792105236d240de85 commit r13-4952-g8385088039f58a1d403cbb0792105236d240de85 Author: Iain Sandoe Date: Thu Dec 22 17:32:59 2022 +0000 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 no 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). Diff: --- 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 +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 = $(filter-out -Werror -static-libgcc, $(ALL_LINKERFLAGS)) +GCC_LDFLAGS = $(filter-out -static-libgcc, $(LDFLAGS)) +else # Strip -Werror during linking for the LTO bootstrap GCC_LINKERFLAGS = $(filter-out -Werror, $(ALL_LINKERFLAGS)) +GCC_LDFLAGS = $(LDFLAGS) +endif -GCC_LINK=$(LINKER) $(GCC_LINKERFLAGS) $(LDFLAGS) -GCC_LLINK=$(LLINKER) $(GCC_LINKERFLAGS) $(LDFLAGS) +GCC_LINK=$(LINKER) $(GCC_LINKERFLAGS) $(GCC_LDFLAGS) +GCC_LLINK=$(LLINKER) $(GCC_LINKERFLAGS) $(GCC_LDFLAGS) # Lists of files for various purposes.