From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp002.apm-internet.net (smtp002.apm-internet.net [85.119.248.221]) by sourceware.org (Postfix) with ESMTPS id 88389385AE65 for ; Sat, 11 Jun 2022 19:46:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 88389385AE65 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sandoe.co.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=sandoe.co.uk Received: (qmail 12552 invoked from network); 11 Jun 2022 19:46:27 -0000 X-APM-Out-ID: 16549767871255 X-APM-Authkey: 257869/1(257869/1) 4 Received: from unknown (HELO ?192.168.1.95?) (81.138.1.83) by smtp002.apm-internet.net with SMTP; 11 Jun 2022 19:46:27 -0000 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Subject: Re: [PATCH] Fix PR target/104871 (macosx-version-min wrong for macOS >= Big Sur (darwin20)) From: Iain Sandoe In-Reply-To: Date: Sat, 11 Jun 2022 20:46:27 +0100 Cc: GCC Patches Content-Transfer-Encoding: quoted-printable Message-Id: <37EF542A-54C8-4932-82AE-676DBC402D38@sandoe.co.uk> References: <4DDF0FC0-A5C2-42F0-B0A8-7C8D2DC06784@sandoe.co.uk> To: Simon Wright X-Mailer: Apple Mail (2.3608.120.23.2.7) X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00, KAM_COUK, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no 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-List-Received-Date: Sat, 11 Jun 2022 19:46:32 -0000 Hi Simon, > On 11 Jun 2022, at 20:23, Simon Wright wrote: >=20 > On 11 Jun 2022, at 11:37, Iain Sandoe wrote: >>=20 >> Hi Simon, >>=20 >> thanks for the patch. >>=20 >>> On 11 Jun 2022, at 10:17, Simon Wright wrote: >>>=20 >>> (resent with correct address for Iain) >>>=20 >>> This is the same sort of problem as in PR80204: at present, GCC 11 & = 12 assume that if the=20 >>> OS version is >=3D 20, the compiler should see = --mmacosx-version-min=3D{major - 9}.{minor -1}.0,=20 >>> e.g. for OS version 21.3.0 that would be 12.2.0 (the linker sees = -macosx-version-min, same=20 >>> arguments). >>>=20 >>> 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=20 >>> the result of which is that linking an object file built with clang = and one built with gcc gives e.g. >>>=20 >>> ld: warning: object file (null.o) was built for newer macOS version = (12.2) than being linked (12.0) >>>=20 >>> I propose the following patch, which works fine for me (darwin = 21.3.0). >>=20 >> this LGTM - just need to sort out a couple of nits and an admin = point. >>=20 >> FWIW; the following are honoured in preserving the minor version (so = we still have scope for >> mismatches if some objects are built this way and others picking up = the kernel version) .. >>=20 >> clang -target x86_64-apple-macosx11.3 =E2=80=A6 >> clang -mmacosx-version-min=3D11.3 =E2=80=A6 >> MACOSX_DEPLOYMENT_TARGET=3D11.3 clang =E2=80=A6 (although this seems = on at least one version >> of xcodem to pass 12.3 to the linker.. hmmm). >=20 > Something on the lines of "the native compiler clang treats 21.3.0 as = 12.0.0 (unless overridden by e.g.=20 > MACOSX_DEPLOYMENT_TARGET=3D11.3 )"? >=20 > I did see in the otool -l report on a gcc 12.1.0 executable generated = as above (Darwin 21.5.0) >=20 > cmd LC_BUILD_VERSION > cmdsize 32 > platform 1 > minos 11.3 > sdk 10.17 >=20 > =E2=80=94 don=E2=80=99t know where the 10.17 comes from, That=E2=80=99s the version of the SDK in use (it=E2=80=99s embedded in = the plist of the SDK except in the very early ones). The full -platform_version command has a space for the SDK, perhaps ld64 = looks it up these days if not supplied on the command line. Odd that it=E2=80=99s named 10.17 instead = of 11.x (the latest sources for ld64 are quite old now, so can=E2=80=99t check = what newer versions of the linker are doing). > still there even without MACOSX_DEPLOYMENT_TARGET. > The SDK was Xcode 13.4.1. I also have CLT 13.4.0.0.1.1651278267. clang = tells ld=20 > "-platform_version macos 11.3.0 12.3", gcc just says = "-macosx_version_min 11.3". GCC does not implement the -platform_version command yet (we have a = configure scan for it but not needed to use it so far) - not sure if we really want to get into = parsing plist files to find the SDK version (or get tied to using more tools out of our control). >> I guess you do not have commit access?=20 >> if you do not have an FSF assignment for copyright, are you OK to = sign this off using the DCO? >>=20 >> https://gcc.gnu.org/dco.html >=20 > No commit access, but FSF assignment RT:1016382. Do I need to say this = in the patch email somewhere? no, that=E2=80=99s fine - we just need one (assignment) or the other = (DCO). >> for furture reference, please check that patches conform to GCC = coding style (this one has some >> whitespace glitches) >=20 > I don=E2=80=99t see the whitespace glitches? (I have missed a period = after ld in the second comment) sets of 8 leading spaces should be tabs. the source tree has some checking tools for commits (in contrib/ ), = which can be useful. It=E2=80=99s also quite handy to have the entire commit with the commit = message in one=E2=80=99s local repo and then just do =E2=80=9Cgit format-patch -1 xxxxxxxxxxx=E2=80=9D to get the = patch for posting (but, of course, everyone has their own favourite git workflow). OK, thanks, I think I=E2=80=99ve got everything needed to get this = applied, there=E2=80=99s no need to re-issue, I=E2=80=99ll tweak the commit message and the whitespace. Iain >=20 >>=20 >> thanks, >> Iain >>=20 >>=20 >>> gcc/ChangeLog: >>> =09 >>> 2022-06-02 Simon Wright >>> =09 >>> 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=E2=80=99s behaviour. >>>=20 >>>