From: Simon Wright <simon@pushface.org>
To: gcc-patches@gcc.gnu.org
Cc: iain@codesourcery.com
Subject: [PATCH] Fix PR target/104871 (macosx-version-min wrong for macOS >= Big Sur (darwin20))
Date: Wed, 8 Jun 2022 12:18:38 +0100 [thread overview]
Message-ID: <E1DD6C55-788E-42E3-9CAD-B0DC45742E9E@pushface.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 1111 bytes --]
(resent with commit message format update)
This is the same sort of problem as in PR80204: at present, GCC 11 & 12 assume that if the
OS version is >= 20, the compiler should see --mmacosx-version-min={major - 9}.{minor -1}.0,
e.g. for OS version 21.3.0 that would be 12.2.0 (the linker sees -macosx-version-min, same
arguments).
However, the native compiler clang treats 21.3.0 as 12.0.0: the compiler sees
-triple x86_64-apple-macosx12.0.0
and the linker sees
-platform_version macos 12.0.0
the result of which is that linking an object file built with clang and one built with gcc gives e.g.
ld: warning: object file (null.o) was built for newer macOS version (12.2) than being linked (12.0)
I propose the following patch, which works fine for me (darwin 21.3.0).
gcc/ChangeLog:
2022-06-02 Simon Wright <simon@pushface.org>
PR target/104871
* config/darwin-driver.cc (darwin_find_version_from_kernel): If the OS version is
20 (macOS 11) or greater, report the minor version and the patch level as 0
to match Apple clang’s behaviour.
[-- Attachment #2: pr104871.diff --]
[-- Type: application/octet-stream, Size: 1323 bytes --]
diff --git a/gcc/config/darwin-driver.cc b/gcc/config/darwin-driver.cc
index 30e0e64f280..c47599e3fcb 100644
--- a/gcc/config/darwin-driver.cc
+++ b/gcc/config/darwin-driver.cc
@@ -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
next reply other threads:[~2022-06-08 11:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-08 11:18 Simon Wright [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-06-11 9:17 Simon Wright
2022-06-11 10:37 ` Iain Sandoe
2022-06-11 19:23 ` Simon Wright
2022-06-11 19:46 ` Iain Sandoe
2022-06-04 18:37 Simon Wright
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1DD6C55-788E-42E3-9CAD-B0DC45742E9E@pushface.org \
--to=simon@pushface.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=iain@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).