Bug 110624 - Xcode 15 ld warns about -macosx_version_min
Summary: Xcode 15 ld warns about -macosx_version_min
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 14.0
: P3 normal
Target Milestone: 11.5
Assignee: Iain Sandoe
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-07-11 08:57 UTC by Rainer Orth
Modified: 2024-04-04 18:50 UTC (History)
2 users (show)

See Also:
Host: x86_64-apple-darwin23.0.0
Target: x86_64-apple-darwin23.0.0
Build: x86_64-apple-darwin23.0.0
Known to work:
Known to fail:
Last reconfirmed: 2023-07-11 00:00:00


Attachments
Patch for testing (742 bytes, patch)
2023-07-11 14:11 UTC, Iain Sandoe
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rainer Orth 2023-07-11 08:57:43 UTC
When bootstrapping current trunk on macOS 14.0 beta 3 with Xcode 15 beta 3,
every single link test in the testsuite fails with excess errors since ld now
warns

-macosx_version_min has been renamed to -macos_version_min

I'm currently working on patches to prune that message in the testsuite, plus
large additional patches to the gm2 testsuite to perform the pruning at all.

Ultimately, this should be handled in the driver, though: the warning is new
in Xcode 15 beta 3 (beta 2 didn't have it).  However, ld accepts the new form
back to at least Xcode 13 (haven't looked further yet), and it's the only one
documented in ld(1).
Comment 1 Iain Sandoe 2023-07-11 09:53:06 UTC
OK. (I do not have enough hardware to install 14 or xc15 at present).

I guess we just add a configuration test for it and then make the link line dependent; will have a go on D21+XC14.3
Comment 2 ro@CeBiTec.Uni-Bielefeld.DE 2023-07-11 09:57:14 UTC
> --- Comment #1 from Iain Sandoe <iains at gcc dot gnu.org> ---
> OK. (I do not have enough hardware to install 14 or xc15 at present).

You don't depend on macOS 14 here, fortunately: xc 15 still supports
macOS 13.4+.

I'm running in qemu btw., the only virtualization solution that does
support 13 and 14 at the moment.

> I guess we just add a configuration test for it and then make the link line
> dependent; will have a go on D21+XC14.3

I suspect so: older versions like xc 8 certainly don't support the new
form.
Comment 3 Iain Sandoe 2023-07-11 10:01:59 UTC
actually, we already have a config test for -platform_version, which is what clang passes to ld.  First, I'll take a look at enabling that (in which case the mmacosx_version_min is not needed).

I take it that clang -cc1as does not warn for  -mmacosx-version-min= ?
Comment 4 ro@CeBiTec.Uni-Bielefeld.DE 2023-07-11 10:55:15 UTC
> --- Comment #3 from Iain Sandoe <iains at gcc dot gnu.org> ---
> actually, we already have a config test for -platform_version, which is what
> clang passes to ld.  First, I'll take a look at enabling that (in which case
> the mmacosx_version_min is not needed).

That would be even easier indeed.

> I take it that clang -cc1as does not warn for  -mmacosx-version-min= ?

Right: the HAVE_AS_MMACOSX_VERSION_MIN_OPTION test succeeds.
Comment 5 Iain Sandoe 2023-07-11 14:11:24 UTC
Created attachment 55523 [details]
Patch for testing

I tested this (by bootstrapping GCC with it) on x86_64 darwin21 with Xcode 14.3.

FWIW; The reason I had not done this sooner, is that I do not have a sensible way to look up the SDK version at the moment (the second parameter), but AFAIK 0.0 is allowed as a "don't know", so we can improve on this at a later time

Here, I will test on some earlier Darwin versions - but would welcome confirmation that it fixes the XC15 issue.

-----

```
COLLECT_GCC_OPTIONS='-B' 'gcc' '-o' 'hc' '-v' '-save-temps' '-mmacosx-version-min=12.0.0'  '-nodefaultexport' '-mtune=core2' '-dumpdir' 'hc.'
 gcc/collect2 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/ -dynamic -arch x86_64 -platform_version macos 12.0.0 0.0 -o hc -Lgcc hc-hello.o -v -lemutls_w -lgcc -lSystem -no_compact_unwind
collect2 version 14.0.0 20230707 (experimental) [remotes/home/master revision r14-2384-gbb3b9c1c3ba8]
gcc/collect-ld -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/ -dynamic -arch x86_64 -platform_version macos 12.0.0 0.0 -o hc -Lgcc hc-hello.o -v -lemutls_w -lgcc -lSystem -no_compact_unwind
@(#)PROGRAM:ld  PROJECT:ld64-857.1

```
Comment 6 ro@CeBiTec.Uni-Bielefeld.DE 2023-07-13 08:57:44 UTC
> --- Comment #5 from Iain Sandoe <iains at gcc dot gnu.org> ---
> Here, I will test on some earlier Darwin versions - but would welcome
> confirmation that it fixes the XC15 issue.

I've done that now and could successfully bootstrap on macOS 14.0 beta 3
with Xcode 15 beta 4.  Thanks for the patch, especially since my patch
series to consistently prune the ld warning provded to be a can of worms.

I needed one patch to link m2/boot-bin/mklink with -static-libstdc++ (to
be submitted shortly).

However, there's an enormous number of issues compared to macOS 14.0
beta 2/Xcode 15 beta 2, in particular all (?) EH-related execution tests
failing, and all gfortran tests failing due to ld warnings about
duplicate libraries (will submit a PR for that).
Comment 7 GCC Commits 2023-07-13 19:15:10 UTC
The master branch has been updated by Iain D Sandoe <iains@gcc.gnu.org>:

https://gcc.gnu.org/g:032b5da1fc781bd3c23d9caa72fb09439e7f6f3a

commit r14-2506-g032b5da1fc781bd3c23d9caa72fb09439e7f6f3a
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Thu Jul 13 07:36:51 2023 +0100

    Darwin: Use -platform_version when available [PR110624].
    
    Later versions of the static linker support a more flexible flag to
    describe the OS, OS version and SDK used to build the code.  This
    replaces the functionality of '-mmacosx_version_min' (which is now
    deprecated, leading to the diagnostic described in the PR).
    
    We now use the platform_version flag when available which avoids the
    diagnostic.
    
    Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
    
            PR target/110624
    
    gcc/ChangeLog:
    
            * config/darwin.h (DARWIN_PLATFORM_ID): New.
            (LINK_COMMAND_A): Use DARWIN_PLATFORM_ID to pass OS, OS version
            and SDK data to the static linker.
Comment 8 Iain Sandoe 2023-07-13 19:19:36 UTC
so fixed by using the platform_version change.  If anyone runs into a problem because they have makefiles/etc that build stand-alone ld lines, I guess they will have to fix them anyway (nothing GCC can do about that).
Comment 9 GCC Commits 2023-07-19 08:08:03 UTC
The releases/gcc-13 branch has been updated by Iain D Sandoe <iains@gcc.gnu.org>:

https://gcc.gnu.org/g:4adf49a436429010ba928d4dc262625298e0d21a

commit r13-7587-g4adf49a436429010ba928d4dc262625298e0d21a
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Thu Jul 13 07:36:51 2023 +0100

    Darwin: Use -platform_version when available [PR110624].
    
    Later versions of the static linker support a more flexible flag to
    describe the OS, OS version and SDK used to build the code.  This
    replaces the functionality of '-mmacosx_version_min' (which is now
    deprecated, leading to the diagnostic described in the PR).
    
    We now use the platform_version flag when available which avoids the
    diagnostic.
    
    Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
    
            PR target/110624
    
    gcc/ChangeLog:
    
            * config/darwin.h (DARWIN_PLATFORM_ID): New.
            (LINK_COMMAND_A): Use DARWIN_PLATFORM_ID to pass OS, OS version
            and SDK data to the static linker.
    
    (cherry picked from commit 032b5da1fc781bd3c23d9caa72fb09439e7f6f3a)
Comment 10 GCC Commits 2024-04-04 18:50:57 UTC
The releases/gcc-12 branch has been updated by Iain D Sandoe <iains@gcc.gnu.org>:

https://gcc.gnu.org/g:a17f5a03e93d2cc6fd40cef6ab3930ba019f804a

commit r12-10310-ga17f5a03e93d2cc6fd40cef6ab3930ba019f804a
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Thu Jul 13 07:36:51 2023 +0100

    Darwin: Use -platform_version when available [PR110624].
    
    Later versions of the static linker support a more flexible flag to
    describe the OS, OS version and SDK used to build the code.  This
    replaces the functionality of '-mmacosx_version_min' (which is now
    deprecated, leading to the diagnostic described in the PR).
    
    We now use the platform_version flag when available which avoids the
    diagnostic.
    
    Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
    
            PR target/110624
    
    gcc/ChangeLog:
    
            * config/darwin.h (DARWIN_PLATFORM_ID): New.
            (LINK_COMMAND_A): Use DARWIN_PLATFORM_ID to pass OS, OS version
            and SDK data to the static linker.
    
    (cherry picked from commit 032b5da1fc781bd3c23d9caa72fb09439e7f6f3a)