From patchwork Thu Dec 24 22:24:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 1420545 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sandoe.co.uk Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D24Rb4XcSz9sT6 for ; Fri, 25 Dec 2020 09:26:16 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4D8493850431; Thu, 24 Dec 2020 22:26:12 +0000 (GMT) X-Original-To: GCC-patches@gcc.gnu.org Delivered-To: GCC-patches@gcc.gnu.org Received: from smtp1.wavenetuk.net (smtp.wavenetuk.net [195.26.36.10]) by sourceware.org (Postfix) with ESMTP id 9FE3B3858001 for ; Thu, 24 Dec 2020 22:26:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9FE3B3858001 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sandoe.co.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=iain@sandoe.co.uk Received: from [192.168.1.212] (host81-138-1-83.in-addr.btopenworld.com [81.138.1.83]) by smtp1.wavenetuk.net (Postfix) with ESMTPA id 2B2B21201424; Thu, 24 Dec 2020 22:26:04 +0000 (GMT) From: Iain Sandoe Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Date: Thu, 24 Dec 2020 22:24:41 +0000 Subject: [pushed] Darwin : Adjust handling of MACOSX_DEPLOYMENT_TARGET for macOS 11. Message-Id: <5D0E9153-FCC2-4EB1-866C-757F79996843@sandoe.co.uk> To: GCC Patches X-Mailer: Apple Mail (2.3273) X-Spam-Status: No, score=-15.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_COUK, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KHOP_HELO_FCRDNS, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" (resending, this never seemed to make it to patches@) The shift to macOS version 11 also means that '11' without any following '.x' is accepted as a valid version number. This adjusts the validation code to accept this and map it to 11.0.0 which matches what the clang toolchain appears to do. tested on x86_64-darwin20, x86_64-darwin16 pushed to master thanks Iain gcc/ChangeLog: * config/darwin-driver.c (validate_macosx_version_min): Allow MACOSX_DEPLOYMENT_TARGET=11. (darwin_default_min_version): Adjust warning spelling to avoid an apostrophe. --- gcc/config/darwin-driver.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/gcc/config/darwin-driver.c b/gcc/config/darwin-driver.c index 4a9426ef273..c5ad44191aa 100644 --- a/gcc/config/darwin-driver.c +++ b/gcc/config/darwin-driver.c @@ -43,13 +43,13 @@ static const char * validate_macosx_version_min (const char *version_str) { size_t version_len; - unsigned long major, minor, tiny = 0; + unsigned long major, minor = 0, tiny = 0; char *end; const char *old_version = version_str; bool need_rewrite = false; version_len = strlen (version_str); - if (version_len < 4) /* The minimum would be 10.x */ + if (version_len < 2) /* The minimum would be 11 */ return NULL; /* Version string must consist of digits and periods only. */ @@ -63,18 +63,27 @@ validate_macosx_version_min (const char *version_str) need_rewrite = true; major = strtoul (version_str, &end, 10); - version_str = end + ((*end == '.') ? 1 : 0); if (major < 10 || major > 11 ) /* MacOS 10 and 11 are known. */ return NULL; - /* Version string components must be present and numeric. */ - if (!ISDIGIT (version_str[0])) + /* Skip a separating period, if there's one. */ + version_str = end + ((*end == '.') ? 1 : 0); + + if (major == 11 && *end != '\0' && !ISDIGIT (version_str[0])) + /* For MacOS 11, we allow just the major number, but if the minor is + there it must be numeric. */ + return NULL; + else if (major == 11 && *end == '\0') + /* We will rewrite 11 => 11.0.0. */ + need_rewrite = true; + else if (major == 10 && (*end == '\0' || !ISDIGIT (version_str[0]))) + /* Otherwise, minor version components must be present and numeric. */ return NULL; /* If we have one or more leading zeros on a component, then rewrite the version string. */ - if (version_str[0] == '0' && version_str[1] != '\0' + if (*end != '\0' && version_str[0] == '0' && version_str[1] != '\0' && version_str[1] != '.') need_rewrite = true; @@ -220,7 +229,7 @@ darwin_default_min_version (void) const char *checked = validate_macosx_version_min (new_flag); if (checked == NULL) { - warning (0, "couldn%'t understand version %s", new_flag); + warning (0, "could not understand version %s", new_flag); return NULL; } new_flag = xstrndup (checked, strlen (checked));