From patchwork Wed Oct 18 09:40:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 154786 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp4669610vqb; Wed, 18 Oct 2023 02:41:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGldlrzHHF5nLmP0Y0XEhuCZKoPuQTt9hI9UEyHVaGUZkB+Kn3AGRJhlTpQGJ4FJyRCnVKw X-Received: by 2002:a05:6214:d4b:b0:65b:3119:7982 with SMTP id 11-20020a0562140d4b00b0065b31197982mr5927131qvr.52.1697622075153; Wed, 18 Oct 2023 02:41:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697622075; cv=pass; d=google.com; s=arc-20160816; b=kTbw3n5+abV02goF1fdytyBaVAB0tyvX4Jic7fvqKQCyNTCBUPJXwkNgzi5/ze2hAg 7moCw9K5QD7wuf39eRcXvU4M/CGyKOWY/gIdynTLcuqILmbHBxpy//5rr64toF0SzKlJ hK7OfX/HF9GxJcj9LzhxrI3Rta6cGZaFv5jlKkLXg53Z7FJT/wy3g3+5jdD56Zc52vgw zjrTQWYdwA2k/EECTICY1kNoSCsRaucb/ScmU6xaPFgaqBGv7dGjLcui0Pb2jy7lf5dl A3s35Tc5EgURL0/06SkTcpvyejRxfzWHFR4KbqMRiObeL1tQnHvcjfmGXxwkj0a+aZrs +XZQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:reply-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=gfSmOV6Tj8rdtsyDpUAt4l/ZFBSNtkwCiRCSP19p4Uw=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=toMCxO5BJVPMJbm2ObYeCmD369ywomy+cqVS9qeDDws/1/1IaCWKhfOftY0THXcnd9 4CoL8SxjmPEtY8iHqzfZq6Ub9LDdpD1SeanV/eM7WaffGcNYNmgDRjm/AlyPy0otLtMA 0NPmlIZNGrqwAv4jl8OOz3S1lRIttWxTvdTdJne9Vw/7k+18Lcn6aNexJnBSqT1VZg3A XlUorLwbFcnAA2DppcnOsEvqH7zVAJx9rCt//Q5nEFfxZDzANA83mVSk+sC88f9Iv6tW AfafLiRhoHgwawKYwiYBph3z8xpJOeJXYTOILoUiXm3qA/oIlDaY0DMQWNVGRY948iWB 9KuQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=OESdkYeJ; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id di6-20020ad458e6000000b00657b96cbcd9si2277770qvb.278.2023.10.18.02.41.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 02:41:15 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=OESdkYeJ; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DAED7385770B for ; Wed, 18 Oct 2023 09:41:14 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by sourceware.org (Postfix) with ESMTPS id A4CD43858D33 for ; Wed, 18 Oct 2023 09:40:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A4CD43858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A4CD43858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697622050; cv=none; b=DDEaYHn7JbjCa8FPhZQVmOWho2mTnAkCbwkFRR7A9xia1wQ9PT+6674Q6c6d5ECN/HSHmLmBkpEBKM5VdlRAHifq7s0nOMxc4SHhMUC7DkJzscAfSlm04XNaSe6A46RTTOdRp0K93IVwhJLwOlXqxIWQnQkD2isps2WRp1ufZyo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697622050; c=relaxed/simple; bh=k6CO8OQGFUzoNN4PQDImvItc0U47RB5yCrmPY5d09vY=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=NRNjCBmvfvryBjma6tJ6kNVsQ7utxu/R+pfniYBdWlOp7hJLhfXId783ggV0Grv8T+jh+2xeuVUFAj34lE1mjcr5UVxSdc6OZFHpzyfBqZ1zY9c/3KyAoS5vrjRnGxcBSV9KVyhtkQKlQoXV+dlrBdhisaA2FcmTtWSjIA4v+/U= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-405497850dbso62563025e9.0 for ; Wed, 18 Oct 2023 02:40:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697622046; x=1698226846; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:to:from:from:to:cc:subject:date:message-id:reply-to; bh=gfSmOV6Tj8rdtsyDpUAt4l/ZFBSNtkwCiRCSP19p4Uw=; b=OESdkYeJbYLKLw62WVrIOTGQpv0YeWkeeee0YKIBM7vCPjpOYBvOXs3sBB3P97GPc/ FGQM2e415RWFSolrvCNW+7Go3Nxt0uIyOzWwLM7JQUqyaQ/ETfw5HDMvJsB7WEEFURx9 xXRRkD/TrN6xzECEN16YzwUEgcTyzfZETb1jHFjHT7ClLt/5DHg7mEZLx+fgqN7vZgYM KGrbKSzVcnTPH4UllwrJbrezcXQx7/G08Aj98LIlZ54JashByAQsXEnygFXthqkHN5RJ RlzKTjvLOD1EJUn6sQmsihT6bNjb1qqGafvvfXHZRiYJ7Ahxn239Vo7n3mNMZYqrGJmY MjlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697622046; x=1698226846; 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=gfSmOV6Tj8rdtsyDpUAt4l/ZFBSNtkwCiRCSP19p4Uw=; b=BbbAhk7JFGOb/d7jUciJ8DtjPxD51b4GvaGk4nGfOt2fgUMZVD1kIWu4rTZAut7Hmw 6tKoiVr2YGfZMCjkkMa8VK+8ZLsz39aZySHSJ2Ri2XeiBYtsnbKN89ClyzvcPGRUeEqo ZPVSbtS+OHxtQ9MLSc0btCN34E6P6F4xUrYE+Ju/z8xX1sPOuM2xl7CT52b7miwgac9A oiV2F26IBOlwPKMRFZss0JNanruMAe/BMeAn6kavvwGv4QiJmebycdWXW5F+uJQlQQwz JjdScFE1zuqk/hkme29gZQz0WuUPFvgF2JuzCFt4YEqytKnFKgXQSBuEcCzyUZQ6ZVFm QIgA== X-Gm-Message-State: AOJu0YznYqZ9tcjMRpgLb9Hd93e/foP5kq/qb2tTbRxsUvbCFkkwaAoQ Rp1qrOd/x91LLrjXncXQQu/FKYUJRJs= X-Received: by 2002:a5d:6188:0:b0:321:6005:8979 with SMTP id j8-20020a5d6188000000b0032160058979mr3938763wru.17.1697622046014; Wed, 18 Oct 2023 02:40:46 -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 p4-20020adfcc84000000b00327de0173f6sm1704968wrj.115.2023.10.18.02.40.45 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 18 Oct 2023 02:40:45 -0700 (PDT) From: Iain Sandoe X-Google-Original-From: Iain Sandoe To: gcc-patches@gcc.gnu.org Subject: [pushed] Darwin: Check as for .build_version support and use it if available. Date: Wed, 18 Oct 2023 10:40:44 +0100 Message-Id: <20231018094044.66965-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.4 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: iain@sandoe.co.uk Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780085765085130391 X-GMAIL-MSGID: 1780085765085130391 Tested on i686-darwin9, x86_64-darwin17,19,21 and x86_64-linux-gnu, pushed to master, thanks, Iain --- 8< --- This adds support for the minimum OS version data in assembler files. At present, we have no mechanism to detect the SDK version in use, and so that is omitted from build_versions. We follow the implementation in clang, '.build_version' is only emitted (where supported) for target macOS versions >= 10.14. For earlier macOS we fall back to using a '.macosx_version_min' directive. This latter is also emitted when the assembler supports it, but not build_version. gcc/ChangeLog: * config.in: Regenerate. * config/darwin.cc (darwin_file_start): Add assembler directives for the target OS version, where these are supported by the assembler. (darwin_override_options): Check for building >= macOS 10.14. * configure: Regenerate. * configure.ac: Check for assembler support of .build_version directives. Signed-off-by: Iain Sandoe --- gcc/config.in | 6 ++++++ gcc/config/darwin.cc | 34 ++++++++++++++++++++++++++++++++-- gcc/configure | 33 +++++++++++++++++++++++++++++++++ gcc/configure.ac | 8 ++++++++ 4 files changed, 79 insertions(+), 2 deletions(-) diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc index d8c8607892b..a80b6caf95a 100644 --- a/gcc/config/darwin.cc +++ b/gcc/config/darwin.cc @@ -3073,7 +3073,35 @@ darwin_asm_output_dwarf_offset (FILE *file, int size, const char * lab, void darwin_file_start (void) { - /* Nothing to do. */ +#ifdef HAVE_AS_MMACOSX_VERSION_MIN_OPTION + /* This should not happen with a well-formed command line, but the user could + invoke cc1* directly without it. */ + if (!darwin_macosx_version_min) + return; + /* This assumes that the version passed has been validated in the driver. */ + unsigned maj, min, tiny; + int count = sscanf (darwin_macosx_version_min, "%u.%u.%u", &maj, &min, &tiny); + if (count < 0) + return; + if (count < 3) + tiny = 0; + if (count < 2) + min = 0; + const char *directive; +#ifdef HAVE_AS_MACOS_BUILD_VERSION + /* We only handle macos, so far. */ + if (generating_for_darwin_version >= 18) + directive = "build_version macos, "; + else +#endif + directive = "macosx_version_min "; + if (count > 2 && tiny != 0) + fprintf (asm_out_file, "\t.%s %u, %u, %u\n", directive, maj, min, tiny); + else if (count > 1) + fprintf (asm_out_file, "\t.%s %u, %u\n", directive, maj, min); + else + fprintf (asm_out_file, "\t.%s %u, 0\n", directive, maj); +#endif } /* Called for the TARGET_ASM_FILE_END hook. @@ -3295,7 +3323,9 @@ darwin_override_options (void) /* Keep track of which (major) version we're generating code for. */ if (darwin_macosx_version_min) { - if (strverscmp (darwin_macosx_version_min, "10.7") >= 0) + if (strverscmp (darwin_macosx_version_min, "10.14") >= 0) + generating_for_darwin_version = 18; + else if (strverscmp (darwin_macosx_version_min, "10.7") >= 0) generating_for_darwin_version = 11; else if (strverscmp (darwin_macosx_version_min, "10.6") >= 0) generating_for_darwin_version = 10; diff --git a/gcc/configure.ac b/gcc/configure.ac index fb8e32f8ee5..c10e007f9bf 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -4374,6 +4374,14 @@ case "$target_os" in [-mmacosx-version-min=10.1], [.text],, [AC_DEFINE(HAVE_AS_MMACOSX_VERSION_MIN_OPTION, 1, [Define if your macOS assembler supports the -mmacos-version-min option.])]) + if test x$gcc_cv_as_mmacosx_version_min = "xyes"; then + gcc_GAS_CHECK_FEATURE([.build_version], + gcc_cv_as_darwin_build_version, + [-mmacosx-version-min=10.14], + [ .build_version macos, 10, 14 sdk_version 10, 14],, + [AC_DEFINE(HAVE_AS_MACOS_BUILD_VERSION, 1, + [Define if your macOS assembler supports .build_version directives])]) + fi ;; esac