Message ID | 20221224190049.99806-1-iain@sandoe.co.uk |
---|---|
State | Committed |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 48ED6385B521 for <patchwork@sourceware.org>; Sat, 24 Dec 2022 19:01:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 48ED6385B521 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671908481; bh=uxj7i1zD+d8y659i6Xp/eD8VIbA/TEvU34baespoyUw=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=sL3JkcGJfp3gvoTjwVBtKpmYQJPrz3aRm6k+KPeBzHlY5SOukGYT30nxDfuq08n7H 1NtmRQdjMsFUZ+aiT/DPT79PGO3Fdf4hOoH77Fg1cOqBBYq3TdROOzTK5xzBXhcB3o cjtktQcXz60EUvqpC4jhVbJ7Fd0E2bghq8X07ueM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by sourceware.org (Postfix) with ESMTPS id C2CDD3858D1E for <gcc-patches@gcc.gnu.org>; Sat, 24 Dec 2022 19:00:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C2CDD3858D1E Received: by mail-wm1-x334.google.com with SMTP id b24-20020a05600c4a9800b003d21efdd61dso5495611wmp.3 for <gcc-patches@gcc.gnu.org>; Sat, 24 Dec 2022 11:00:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=uxj7i1zD+d8y659i6Xp/eD8VIbA/TEvU34baespoyUw=; b=b27KPdZ3+M5CWXbn8RFF02GvWcrFJ+gfVikJfZ+MGJIP26T49JL2YZjzXWsgQjazxR 1pGUkQEq/yg5oZkl2RZQi6mnMVy8+1qRdN0f68HtDofqvPabeh0vyHk8Uo4bbuDkClpv QWDMNx6cVOGemRqnqNs+ngAnaL21iA0qA3M/Sf/WAfDRtI6SFCsdZZRG4w5SyGyMDvJY afOtOsHejYwX7SVgQ6WqKTLL34NvR0VA5jqkKThhSTTco3HRsuA8qvVJPqWgAsaBpDfQ h7T7Y3LjX011nd/APWzVRPSkL45Ac6gPyc0PYgA9aaDRAmDzdEU9tKDHFGuISXK+sBGu PJmw== X-Gm-Message-State: AFqh2kq9sCerH/GH4FB8S79AWsZCPNu7WsU4eFM+rOmZWW7/roZyXfnY WANHAbwgaPmJYHyL+2pCkeKI/gVpoDk= X-Google-Smtp-Source: AMrXdXteM+082qr/JcrnallbsS+Y0OqlL6dWzPwm96xKkByUe9nuawj+1WHc1vFdb0mgbyF20T3Tww== X-Received: by 2002:a05:600c:41d1:b0:3d2:3d7b:6118 with SMTP id t17-20020a05600c41d100b003d23d7b6118mr10039409wmh.24.1671908450285; Sat, 24 Dec 2022 11:00:50 -0800 (PST) Received: from localhost.localdomain (host81-138-1-83.in-addr.btopenworld.com. [81.138.1.83]) by smtp.gmail.com with ESMTPSA id bh12-20020a05600c3d0c00b003cfa81e2eb4sm8622963wmb.38.2022.12.24.11.00.49 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 24 Dec 2022 11:00:49 -0800 (PST) X-Google-Original-From: Iain Sandoe <iain@sandoe.co.uk> To: gcc-patches@gcc.gnu.org Subject: [PATCH] Ada, Darwin: Do not link libgcc statically on Darwin [PR108202]. Date: Sat, 24 Dec 2022 19:00:49 +0000 Message-Id: <20221224190049.99806-1-iain@sandoe.co.uk> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Iain Sandoe via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: iain@sandoe.co.uk Cc: Iain Sandoe <iains.gcc@gmail.com>, charlet@adacore.com Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
Ada, Darwin: Do not link libgcc statically on Darwin [PR108202].
|
|
Commit Message
Iain Sandoe
Dec. 24, 2022, 7 p.m. UTC
Tested on i686, x86-64 darwin, x86_64-linux (with a 32b multilib). OK for trunk? Iain --- 8< --- 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 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 Darwin (-Werror only for other hosts). --- gcc/ada/gcc-interface/Make-lang.in | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
Comments
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 <gcc-patches@gcc.gnu.org> wrote: > > 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 +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.
> I would like to revise this patch to be more conservative (only applying to Darwin 8 and 9). This is OK, thanks (and Happy New Year!) > > On 24 Dec 2022, at 19:00, Iain Sandoe via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > > > 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).
diff --git a/gcc/ada/gcc-interface/Make-lang.in b/gcc/ada/gcc-interface/Make-lang.in index 2acd195017e..64273c3bdb4 100644 --- a/gcc/ada/gcc-interface/Make-lang.in +++ b/gcc/ada/gcc-interface/Make-lang.in @@ -261,10 +261,20 @@ else endif # Strip -Werror during linking for the LTO bootstrap + +ifneq ($(findstring darwin,$(host)),) +# gnat1 uses exceptions which is incompatible with statically-linked libgcc +# on Darwin, 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 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.