From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1698) id AB7D93858D32; Wed, 15 Jun 2022 19:17:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AB7D93858D32 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Iain D Sandoe To: gcc-cvs@gcc.gnu.org Subject: [gcc r10-10848] Darwin: Truncate kernel-provided version to OS major for Darwin >= 20. X-Act-Checkin: gcc X-Git-Author: Simon Wright X-Git-Refname: refs/heads/releases/gcc-10 X-Git-Oldrev: f335ab5b77230590618f80f76a5e83626909b8ee X-Git-Newrev: 82b771fd6cab421d92cc074a79f98389ac8569c3 Message-Id: <20220615191750.AB7D93858D32@sourceware.org> Date: Wed, 15 Jun 2022 19:17:50 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2022 19:17:50 -0000 https://gcc.gnu.org/g:82b771fd6cab421d92cc074a79f98389ac8569c3 commit r10-10848-g82b771fd6cab421d92cc074a79f98389ac8569c3 Author: Simon Wright Date: Sun Jun 12 17:01:22 2022 +0100 Darwin: Truncate kernel-provided version to OS major for Darwin >= 20. In common with system tools, GCC uses a version obtained from the kernel as the prevailing macOS target, when that is not overridden by command line or environment versions (i.e. mmacosx-version-min=, MACOSX_DEPLOYMENT_TARGET). Presently, GCC assumes that if the OS version is >= 20, the value used should include both major and minium version identifiers. However the system tools (for those versions) truncate the value to the major version - this leads to link errors when combining objects built with clang and GCC for example: ld: warning: object file (null.o) was built for newer macOS version (12.2) than being linked (12.0) The change here truncates the values GCC uses to the major version. gcc/ChangeLog: PR target/104871 * config/darwin-driver.c (darwin_find_version_from_kernel): If the OS version is darwin20 (macOS 11) or greater, truncate the version to the major number. (cherry picked from commit add1adaa17a294ea25918ffb4fdd40f115362632) Diff: --- gcc/config/darwin-driver.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/gcc/config/darwin-driver.c b/gcc/config/darwin-driver.c index b2e3afdad0d..f96af2c0262 100644 --- a/gcc/config/darwin-driver.c +++ b/gcc/config/darwin-driver.c @@ -160,19 +160,13 @@ darwin_find_version_from_kernel (void) goto parse_failed; /* Darwin20 sees a transition to macOS 11. In this, it seems that the - mapping to macOS minor version is now shifted to the kernel minor - version - 1 (at least for the initial releases). */ + mapping to macOS minor version and patch level is now always 0, 0 + (at least for macOS 11 and 12). */ if (major_vers >= 20) { - int minor_vers = *version_p++ - '0'; - if (ISDIGIT (*version_p)) - minor_vers = minor_vers * 10 + (*version_p++ - '0'); - if (*version_p++ != '.') - goto parse_failed; - if (minor_vers > 0) - minor_vers -= 1; /* Kernel 20.3 => macOS 11.2. */ - /* It's not yet clear whether patch level will be considered. */ - asprintf (&new_flag, "%d.%02d.00", major_vers - 9, minor_vers); + /* Apple clang doesn't include the minor version or the patch level + in the object file, nor does it pass it to ld */ + asprintf (&new_flag, "%d.00.00", major_vers - 9); } else if (major_vers - 4 <= 4) /* On 10.4 and earlier, the old linker is used which does not