From patchwork Fri May 19 08:11:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 96254 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1066714vqo; Fri, 19 May 2023 01:12:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5TxZvtXjKftVVlQAImlHs/Sm+/GTuEsLEYcKxO7Dpz2mvLHQfaQjJfNXxiOngIRfv+qk/O X-Received: by 2002:aa7:d98e:0:b0:50b:c20d:63e3 with SMTP id u14-20020aa7d98e000000b0050bc20d63e3mr883447eds.10.1684483943145; Fri, 19 May 2023 01:12:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684483943; cv=none; d=google.com; s=arc-20160816; b=QUJy/fgQoYWgkKVMNu4VWtj5ycNXsKigNYPu6BbD60wBCNXT3wjAHJU31ri6vvmdkp iitgq5luHlEhW79efGYCAbzrehELj212PKbIK2GhZ4fiD/sm127IpmNJyo9wAIVuUmEH I2vWpKyLDINrkFwsEp0KE/moWqIyqk4pf/KGyFsdJbMyJ+lrMu6noRkhThioHL1AAoxc DAi5XE+eK7GRUcx52V35br09qxVEOoImpHOyJBQk2L0hYE5yTju0fuPx0fKygPGBerV4 0wTdz77+XDfW7Sxf41m1N/kj5xh3UD/WpvFI+7NSIRBuE9emgPlcm+p7zQhPyO/5Hf6g R2hA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=fU4bANn0IjpKsPSxSoLc4FVyFEREuEioG2md30ByfrE=; b=yUuBVlckMTo+9oP6AMFsrytj6u6IiYJp16UnsE9v9mUyeHugfWtRc8mxWEyAKCVBMp dNq2t3PNXVqnWauWSF/oIZUvqneGbS9nc0pLPiWN/rK/Q6ROxZMkqjAHwNyCBSyra3R3 unJpZEkjKOc1GAqVTlZGGkjA7SvpVsa9MMs9tDC89qDsdjoaMHdFCwS3qamoHVWH/F/s xKydLJG7Nga2+PmGwMsfWwmWOCc9m6b7yphDgZOnBtE/pyrLmS5U/syFv0cVD2EF0VN9 4n9gCuloP3AoNtBJcclCp3wNvR2VnmpoLhvX94cppxLwMHiMYWD1Wvx3b6WgjkHFKKjx reDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=btcm5lIU; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id w10-20020a50fa8a000000b00510d6cbbabcsi216498edr.212.2023.05.19.01.12.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 01:12:23 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=btcm5lIU; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 00B503858412 for ; Fri, 19 May 2023 08:12:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 00B503858412 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684483942; bh=fU4bANn0IjpKsPSxSoLc4FVyFEREuEioG2md30ByfrE=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=btcm5lIUCS0oZNcgps6dCU0ipkB3dy+Q9H+QLx7qOLi2sWJXY/SMpEkxllCIrvJsf 5O7uBwSzMa2VzP75gDpc8YQSUbYmCTi7epAivCYGgAhlbkp55hpBl86Wjai+RwKFD2 nOSlhUoeFWHvmPY+aloejVR6NlJs2jJiHM5n9BLY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id 00C9C3858D28 for ; Fri, 19 May 2023 08:11:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 00C9C3858D28 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3f42bcf5df1so28383835e9.3 for ; Fri, 19 May 2023 01:11:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684483896; x=1687075896; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=fU4bANn0IjpKsPSxSoLc4FVyFEREuEioG2md30ByfrE=; b=S+FSUbXicFRDqcqabjCU1j/gtt/S2pwaFxDMdyZF9uIEHhOWBQ6sDKFxwRQF+ZDnsX CPPyvJOIjoF18a6kjVvrCSCdZWwZuPOCcHhmxe0wA/QCHjF5pC6THj47AHwpGvtKOJLm ooaTL5BpkfbsZpOYkd5/JpP8nXJvhbXrHTIC2FG2mh/EoNvdSqVdNoPuArypCsCWxp9v wnOWeAO2AQBXb4Qifonsb9koPRrUG4sOY19jGpweQzktTEKYs5bfrhdywObNvCaNDpBW J+o/xs7mxvlYnPipvFdRfBVISKrqCLvwnTQMAQXdM1733KIITV7IJKGu4NU5ur8AvYgJ mxow== X-Gm-Message-State: AC+VfDzOMJBslixVCnk1TQIPrlDmt0tvNwZ35o+wq9G1cl1z1fFUlFVq CYTBbipBf/7Nc7+C4mkAjAIcBTkdHqQ= X-Received: by 2002:a7b:c041:0:b0:3f4:271a:8aaf with SMTP id u1-20020a7bc041000000b003f4271a8aafmr620227wmc.38.1684483895414; Fri, 19 May 2023 01:11:35 -0700 (PDT) Received: from localhost.localdomain (host81-138-1-83.in-addr.btopenworld.com. [81.138.1.83]) by smtp.gmail.com with ESMTPSA id m8-20020a7bca48000000b003f427687ba7sm1535302wml.41.2023.05.19.01.11.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 May 2023 01:11:35 -0700 (PDT) X-Google-Original-From: Iain Sandoe To: gcc-patches@gcc.gnu.org Subject: [pushed] Darwin, libgcc : Adjust min version supported for the OS. Date: Fri, 19 May 2023 09:11:30 +0100 Message-Id: <20230519081130.34977-1-iain@sandoe.co.uk> X-Mailer: git-send-email 2.39.2 (Apple Git-143) MIME-Version: 1.0 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, T_SCC_BODY_TEXT_LINE 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Sandoe via Gcc-patches From: Iain Sandoe Reply-To: iain@sandoe.co.uk Cc: Iain Sandoe Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766309434961947780?= X-GMAIL-MSGID: =?utf-8?q?1766309434961947780?= Tested across the Darwin range (this patch has been on the WIP branches for some time) and on x86_64-linux-gnu, for reference. pushed to trunk, thanks Iain --- 8< --- Tools from later versions of the OS deprecate or fail to support earlier OS revisions. Signed-off-by: Iain Sandoe libgcc/ChangeLog: * config.host: Arrange to set min Darwin OS versions from the configured host version. * config/darwin10-unwind-find-enc-func.c: Do not use current headers, but declare the nexessary structures locally to the versions in use for Mac OSX 10.6. * config/t-darwin: Amend to handle configured min OS versions. * config/t-darwin-min-1: New. * config/t-darwin-min-5: New. * config/t-darwin-min-8: New. --- libgcc/config.host | 18 ++++++++++ libgcc/config/darwin10-unwind-find-enc-func.c | 34 ++++++++++++++++--- libgcc/config/t-darwin | 10 +++--- libgcc/config/t-darwin-min-1 | 3 ++ libgcc/config/t-darwin-min-5 | 3 ++ libgcc/config/t-darwin-min-8 | 3 ++ 6 files changed, 63 insertions(+), 8 deletions(-) create mode 100644 libgcc/config/t-darwin-min-1 create mode 100644 libgcc/config/t-darwin-min-5 create mode 100644 libgcc/config/t-darwin-min-8 diff --git a/libgcc/config.host b/libgcc/config.host index b9975de9023..9d7212028d0 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -233,6 +233,24 @@ case ${host} in ;; esac tmake_file="$tmake_file t-slibgcc-darwin" + # newer toolsets produce warnings when building for unsupported versions. + case ${host} in + *-*-darwin1[89]* | *-*-darwin2* ) + tmake_file="t-darwin-min-8 $tmake_file" + ;; + *-*-darwin9* | *-*-darwin1[0-7]*) + tmake_file="t-darwin-min-5 $tmake_file" + ;; + *-*-darwin[4-8]*) + tmake_file="t-darwin-min-1 $tmake_file" + ;; + *) + # Fall back to configuring for the oldest system known to work with + # all archs and the current sources. + tmake_file="t-darwin-min-5 $tmake_file" + echo "Warning: libgcc configured to support macOS 10.5" 1>&2 + ;; + esac extra_parts="crt3.o libd10-uwfef.a crttms.o crttme.o libemutls_w.a" ;; *-*-dragonfly*) diff --git a/libgcc/config/darwin10-unwind-find-enc-func.c b/libgcc/config/darwin10-unwind-find-enc-func.c index 882ec3a2372..b08396c5f1b 100644 --- a/libgcc/config/darwin10-unwind-find-enc-func.c +++ b/libgcc/config/darwin10-unwind-find-enc-func.c @@ -1,8 +1,34 @@ -#include "tconfig.h" -#include "tsystem.h" -#include "unwind-dw2-fde.h" #include "libgcc_tm.h" +/* This shim is special, it needs to be built for Mac OSX 10.6 + regardless of the current system version. + We must also build it to use the unwinder layout that was + present for 10.6 (and not update that). + So we copy the referenced structures from unwind-dw2-fde.h + to avoid pulling in newer system headers and/or changed + layouts. */ +struct dwarf_eh_bases +{ + void *tbase; + void *dbase; + void *func; +}; + +typedef int sword __attribute__ ((mode (SI))); +typedef unsigned int uword __attribute__ ((mode (SI))); + +/* The first few fields of an FDE. */ +struct dwarf_fde +{ + uword length; + sword CIE_delta; + unsigned char pc_begin[]; +} __attribute__ ((packed, aligned (__alignof__ (void *)))); + +typedef struct dwarf_fde fde; + +extern const fde * _Unwind_Find_FDE (void *, struct dwarf_eh_bases *); + void * _darwin10_Unwind_FindEnclosingFunction (void *pc) { @@ -10,5 +36,5 @@ _darwin10_Unwind_FindEnclosingFunction (void *pc) const struct dwarf_fde *fde = _Unwind_Find_FDE (pc-1, &bases); if (fde) return bases.func; - return NULL; + return (void *) 0; } diff --git a/libgcc/config/t-darwin b/libgcc/config/t-darwin index 299d26c2c96..a3bb70c6a0a 100644 --- a/libgcc/config/t-darwin +++ b/libgcc/config/t-darwin @@ -1,15 +1,15 @@ # Set this as a minimum (unless overriden by arch t-files) since it's a # reasonable lowest common denominator that works for all our archs. -HOST_LIBGCC2_CFLAGS += -mmacosx-version-min=10.4 +HOST_LIBGCC2_CFLAGS += $(DARWIN_MIN_LIB_VERSION) crt3.o: $(srcdir)/config/darwin-crt3.c - $(crt_compile) -mmacosx-version-min=10.4 -c $< + $(crt_compile) $(DARWIN_MIN_CRT_VERSION) -c $< crttms.o: $(srcdir)/config/darwin-crt-tm.c - $(crt_compile) -mmacosx-version-min=10.4 -DSTART -c $< + $(crt_compile) $(DARWIN_MIN_CRT_VERSION) -DSTART -c $< crttme.o: $(srcdir)/config/darwin-crt-tm.c - $(crt_compile) -mmacosx-version-min=10.4 -DEND -c $< + $(crt_compile) $(DARWIN_MIN_CRT_VERSION) -DEND -c $< # Make emutls weak so that we can deal with -static-libgcc, override the # hidden visibility when this is present in libgcc_eh. @@ -25,6 +25,8 @@ libemutls_w.a: emutls_s.o $(RANLIB_FOR_TARGET) $@ # Patch to __Unwind_Find_Enclosing_Function for Darwin10. +# This needs to be built for darwin10, regardless of the current platform +# version. d10-uwfef.o: $(srcdir)/config/darwin10-unwind-find-enc-func.c libgcc_tm.h $(crt_compile) -mmacosx-version-min=10.6 -c $< diff --git a/libgcc/config/t-darwin-min-1 b/libgcc/config/t-darwin-min-1 new file mode 100644 index 00000000000..8c2cf8acd39 --- /dev/null +++ b/libgcc/config/t-darwin-min-1 @@ -0,0 +1,3 @@ +# Support building with -mmacosx-version-min back to 10.1. +DARWIN_MIN_LIB_VERSION = -mmacosx-version-min=10.4 +DARWIN_MIN_CRT_VERSION = -mmacosx-version-min=10.1 diff --git a/libgcc/config/t-darwin-min-5 b/libgcc/config/t-darwin-min-5 new file mode 100644 index 00000000000..138193151e7 --- /dev/null +++ b/libgcc/config/t-darwin-min-5 @@ -0,0 +1,3 @@ +# Support building with -mmacosx-version-min back to 10.5. +DARWIN_MIN_LIB_VERSION = -mmacosx-version-min=10.5 +DARWIN_MIN_CRT_VERSION = -mmacosx-version-min=10.5 diff --git a/libgcc/config/t-darwin-min-8 b/libgcc/config/t-darwin-min-8 new file mode 100644 index 00000000000..9efc9dc0257 --- /dev/null +++ b/libgcc/config/t-darwin-min-8 @@ -0,0 +1,3 @@ +# Support building with -mmacosx-version-min back to 10.8. +DARWIN_MIN_LIB_VERSION = -mmacosx-version-min=10.8 +DARWIN_MIN_CRT_VERSION = -mmacosx-version-min=10.8