Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 916291 - sys-devel/gcc-12.2.0-r2: bootstrap-prefix.sh stage2 fails (ld: unknown options: -sdk_version) on macOS 14.1 (Sonoma), Xcode 15.0.1
Summary: sys-devel/gcc-12.2.0-r2: bootstrap-prefix.sh stage2 fails (ld: unknown option...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: Prefix Support (show other bugs)
Hardware: All OS X
: Normal blocker with 2 votes (vote)
Assignee: Gentoo Prefix
URL: https://gcc.gnu.org/bugzilla/show_bug...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-10-26 05:25 UTC by Ronie Henrich
Modified: 2024-01-17 07:06 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
stage2.log (stage2.log.xz,347.00 KB, application/x-xz)
2023-10-26 05:27 UTC, Ronie Henrich
Details
The gcc-build-logs.tar.xz with above patch applied. (gcc-build-logs.tar.xz,172.77 KB, application/x-xz)
2023-12-14 23:54 UTC, Ryan Tsien
Details
gcc-13.2-build-logs.tar.xz (gcc-build-logs.tar.xz,183.80 KB, application/x-xz)
2023-12-15 01:35 UTC, Ryan Tsien
Details
gcc-13.2.0.ebuild (gcc-13.2.0.ebuild,4.93 KB, text/plain)
2023-12-15 01:36 UTC, Ryan Tsien
Details
build.log from trying to build gcc-12.2.0 with -mmacosx-version-min=12.0 (build.log.gz,231.67 KB, application/x-gzip)
2024-01-01 04:08 UTC, *
Details
gcc-build-logs darwin x64-23 (gcc-build-logs.tar.xz,6.95 KB, application/x-xz)
2024-01-17 07:06 UTC, Ronie Henrich
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ronie Henrich 2023-10-26 05:25:56 UTC
On macOS 14.1 (Sonoma) with Xcode 15.0.1, stage2 fails to emerge sys-devel/gcc-12.2.0-r2 with the following error:

> -macosx_version_min has been renamed to -macos_version_min
> ld: warning: -single_module is obsolete
> ld: unknown options: -sdk_version 
> collect2: error: ld returned 1 exit status
> make[2]: *** [Makefile:995: libgcc_s.dylib] Error 1
> make[2]: Leaving directory '/Users/ronie/tmp/shm/portage/sys-devel/gcc-12.2.0-r2/work/build/x86_64-apple-darwin23/libgcc'
> make[1]: *** [Makefile:12999: all-target-libgcc] Error 2
> make: *** [Makefile:1035: all] Error 2
>  * ERROR: sys-devel/gcc-12.2.0-r2::gentoo_prefix failed (compile phase):
>  *   emake failed


Reproducible: Always

Steps to Reproduce:
1. Run the bootstrap-prefix.sh on macOS 14.1 (Sonoma) with Xcode 15.0.1



This bug seems to have been fixed upstream for gcc-13 and later
  https://gcc.gnu.org/bugzilla//show_bug.cgi?id=110624
Comment 1 Ronie Henrich 2023-10-26 05:27:45 UTC
Created attachment 873471 [details]
stage2.log
Comment 2 Fabian Groffen gentoo-dev 2023-10-26 07:20:18 UTC
Interesting, without our wrapper this obviously doesn't get fixed.  There is a gcc commit that actually fixes this, perhaps we need to get that into our 12.2 to avoid this problem.
Comment 3 Fabian Groffen gentoo-dev 2023-10-26 07:23:12 UTC
and we should probably look into trying https://github.com/iains/gcc-13-branch
Comment 4 r7l 2023-11-15 12:32:00 UTC
Having the same error on an M1 Mac. I see GCC 13 being mention as a possible solution here. It is considered stable in Portage for normal Gentoo. Did anyone try using it for the bootstrap process?
Comment 5 Dylan 2023-12-05 12:28:21 UTC
Is there any workaround for this?
Comment 6 Fabian Groffen gentoo-dev 2023-12-05 12:29:49 UTC
currently not, sorry
Comment 7 Ryan Tsien 2023-12-14 23:09:05 UTC
I have the same issue here, is there any plan to solve this problem or bump the version?

Or can you tell me the gcc commit that has fixed this?
Comment 8 Ryan Tsien 2023-12-14 23:44:55 UTC
If you're referring to this commit https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=4adf49a436429010ba928d4dc262625298e0d21a, I've already applied it to the current gcc-12, but with no effect.
Comment 9 Ryan Tsien 2023-12-14 23:54:29 UTC
Created attachment 879454 [details]
The gcc-build-logs.tar.xz with above patch applied.
Comment 10 Ryan Tsien 2023-12-15 01:35:49 UTC
Created attachment 879455 [details]
gcc-13.2-build-logs.tar.xz

I tested version 13.2.0, but encountered the same issue.
Comment 11 Ryan Tsien 2023-12-15 01:36:56 UTC
Created attachment 879456 [details]
gcc-13.2.0.ebuild
Comment 12 Ryan Tsien 2023-12-15 13:30:59 UTC
I may have identified the cause of the problem. gcc always sets the macosx-version-min to 11.0 in the libgcc/config/aarch64/t-darwin file. The ldwrapper then uses this argument to override the darwin_dt variable, which generates the darwin_dt_ver. This is used to select either the -platform_version or the -sdk_version.

Therefore, when used with Sonoma, it will always fail.

Am I right?

See also: https://bugs.gentoo.org/910277
Comment 13 Ryan Tsien 2023-12-15 15:01:12 UTC
gcc-13.2 compiled successfully with the following patch, the patch for /libgcc/config/aarch64/t-darwin may not be necessary due to the macosx-version-min flag from libgcc/config/aarch64/t-heap-trampoline appended to it.

```
diff --git a/libgcc/config/aarch64/t-darwin b/libgcc/config/aarch64/t-darwin
index f6ecda7b6..3bb7012b5 100644
--- a/libgcc/config/aarch64/t-darwin
+++ b/libgcc/config/aarch64/t-darwin
@@ -1,6 +1,6 @@
 # Ensure we have a suitable minimum OS version.

-HOST_LIBGCC2_CFLAGS += -mmacosx-version-min=11.0
+HOST_LIBGCC2_CFLAGS += -mmacosx-version-min=12.0

 LIB2_SIDITI_CONV_FUNCS = yes

diff --git a/libgcc/config/aarch64/t-heap-trampoline b/libgcc/config/aarch64/t-heap-trampoline
index 3f70c2cd0..ca36560c8 100644
--- a/libgcc/config/aarch64/t-heap-trampoline
+++ b/libgcc/config/aarch64/t-heap-trampoline
@@ -17,4 +17,4 @@
 # <http://www.gnu.org/licenses/>.

 LIB2ADD += $(srcdir)/config/aarch64/heap-trampoline.c
-HOST_LIBGCC2_CFLAGS += -mmacosx-version-min=11.0
+HOST_LIBGCC2_CFLAGS += -mmacosx-version-min=12.0
```
Comment 14 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-12-20 08:43:41 UTC
Ryan, would you mind making a PR to https://github.com/gentoo/prefix?
Comment 15 Ryan Tsien 2023-12-20 08:52:13 UTC
(In reply to Sam James from comment #14)
> Ryan, would you mind making a PR to https://github.com/gentoo/prefix?

I think the above patch is not the proper method to solve this problem, it's just a workaround, I'm not sure if this change (-mmacosx-version-min=11.0 -> 12.0) affects old macOS or not, so I'd prefer to solve this inside the ldwrapper.c file, but I haven't found a suitable way yet, maybe grobian will have a better idea.
Comment 16 * 2024-01-01 04:07:53 UTC
I tried using that patch, but both before and after, I'm getting a different error:

```
In file included from /opt/gentoo/tmp/var/tmp/portage/sys-devel/gcc-12.2.0-r2/work/gcc-12-branch-gcc-12.2-darwin-r0/libgcc/unwind-dw2.c:412:
./md-unwind-support.h: In function 'aarch64_cie_signed_with_b_key':
./md-unwind-support.h:45:27: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
   45 |           char *aug_str = cie->augmentation;
      |                           ^~~
make[2]: Leaving directory '/opt/gentoo/tmp/var/tmp/portage/sys-devel/gcc-12.2.0-r2/work/build/arm64-apple-darwin23/libgcc'
make[1]: *** [Makefile:12999: all-target-libgcc] Error 2
make: *** [Makefile:1035: all] Error 2
```

I don't have a working system, because the bootstrap fails, but I'll attach the build.log.
Comment 17 * 2024-01-01 04:08:35 UTC
Created attachment 881158 [details]
build.log from trying to build gcc-12.2.0 with -mmacosx-version-min=12.0
Comment 18 fosslinux 2024-01-01 11:04:18 UTC
I can repro this on my macOS 13 x86_64 system.

I'm pretty sure this is introduced by the linker changes in Xcode 15, related to the changes introduced in #910277.

Those changes should trigger here, bypassing this error. I'm not really certain *why* it is that these binutils-config changes do not seem to appear in stage2. Perhaps a dev can shed some light onto that. Does it have to do with the mmacos-version-min setting @Ryan Qian is seeing? If so, I'm pretty sure the code path for macOS 12 should be a compile-time codepath, rather than a runtime code path...

When I force binutils-config's ldwrapper.c into using those changes (just removing checks, forcing the macOS 12 changes into the newargv code path), I gain much more success (still not complete, but well into stage3); after also;

running into this bug https://forums.developer.apple.com/forums/thread/737707 and thus modifying ldwrapper.c to force -ld_classic into the newargv.
Comment 19 Fabian Groffen gentoo-dev 2024-01-11 20:12:32 UTC
I get the feeling GCC shouldn't force a macos version, our ld-wrapper should set the appropriate one.
Comment 20 Larry the Git Cow gentoo-dev 2024-01-13 14:29:12 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=fbcb941fc6fe8c31ceb219dc56127e62906ae520

commit fbcb941fc6fe8c31ceb219dc56127e62906ae520
Author:     Fabian Groffen <grobian@gentoo.org>
AuthorDate: 2024-01-13 14:22:50 +0000
Commit:     Fabian Groffen <grobian@gentoo.org>
CommitDate: 2024-01-13 14:22:50 +0000

    sys-devel/binutils-config: make ld arguments depending on OS release
    
    This is somewhat shady, because we'd need the target ld's version, but
    it's better to use the current platform version rather than the
    requested platform version since the latter has nothing to do with which
    linker is being used.
    
    Not bumping the version, since existing installs don't have this issue,
    and only new installs on Sanoma suffer from this, which never managed to
    succeed, so basically don't exist yet.
    
    Bug: https://bugs.gentoo.org/916291
    Signed-off-by: Fabian Groffen <grobian@gentoo.org>

 sys-devel/binutils-config/files/ldwrapper.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Comment 21 Larry the Git Cow gentoo-dev 2024-01-13 14:33:39 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=1469562b0aad1ca8f2a9a130df50df2ca15aa5a3

commit 1469562b0aad1ca8f2a9a130df50df2ca15aa5a3
Author:     Fabian Groffen <grobian@gentoo.org>
AuthorDate: 2024-01-13 14:32:16 +0000
Commit:     Fabian Groffen <grobian@gentoo.org>
CommitDate: 2024-01-13 14:32:16 +0000

    sys-devel/gcc-13.2.0: version bump
    
    Compiles and works on Darwin x64-17, arm64-23.  Non-Darwin use untested.
    
    Bug: https://bugs.gentoo.org/916291
    Signed-off-by: Fabian Groffen <grobian@gentoo.org>

 sys-devel/gcc/Manifest                             |   4 +
 .../gcc/files/gcc-13-fix-cross-fixincludes.patch   |  19 +++
 sys-devel/gcc/gcc-13.2.0.ebuild                    | 153 +++++++++++++++++++++
 3 files changed, 176 insertions(+)
Comment 22 * 2024-01-13 20:29:19 UTC
Thanks! How do I get bootstrap-prefix.sh to pick up these changes?
Comment 23 Fabian Groffen gentoo-dev 2024-01-14 08:06:22 UTC
I'm currently testing them, if it succeeds now I'll bump the snapshot.  If you're eager then export LATEST_TREE_YES=1 in your environment before calling bootstrap-prefix.sh script.

Yesterday I came up to stage3 zstd which failed because it is using meson.  meson-1.3.1 should work in that regard, so I hope I can come further today.
Comment 24 Fabian Groffen gentoo-dev 2024-01-14 20:27:31 UTC
with tomorrow's snapshot we can succeed the bootstrap (confirmed locally) when meson is in dev-build.
Comment 25 Larry the Git Cow gentoo-dev 2024-01-15 07:10:25 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=f9c3b2bb44c074d4747ca3b3f25af2dc5748c3bd

commit f9c3b2bb44c074d4747ca3b3f25af2dc5748c3bd
Author:     Fabian Groffen <grobian@gentoo.org>
AuthorDate: 2024-01-15 07:08:18 +0000
Commit:     Fabian Groffen <grobian@gentoo.org>
CommitDate: 2024-01-15 07:08:18 +0000

    scripts/bootstrap-prefix: bump snapshot for macOS Sanoma and pkgmove
    
    Snapshot and script now match the pkgmoves to dev-build
    Support for macOS Sanoma via GCC-13.
    
    Closes: https://bugs.gentoo.org/916291
    Closes: https://bugs.gentoo.org/914828
    Signed-off-by: Fabian Groffen <grobian@gentoo.org>

 scripts/bootstrap-prefix.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 26 Ronie Henrich 2024-01-17 07:02:04 UTC
(In reply to Fabian Groffen from comment #24)
> with tomorrow's snapshot we can succeed the bootstrap (confirmed locally)
> when meson is in dev-build.

stage2 succeeded on Darwin x64-23, however now stage3 fails. I wasn't able to identify the cause of this errors yet.

> gcc version 13.2.0 (Gentoo 13.2.0 p7) 
> configure:4414: $? = 0
> configure:4403: x86_64-apple-darwin23-gcc -V >&5
> x86_64-apple-darwin23-gcc: error: unrecognized command-line option '-V'
> x86_64-apple-darwin23-gcc: fatal error: no input files
> compilation terminated.
> configure:4414: $? = 1
> configure:4403: x86_64-apple-darwin23-gcc -qversion >&5
> x86_64-apple-darwin23-gcc: error: unrecognized command-line option '-qversion'; did you mean '--version'?
> x86_64-apple-darwin23-gcc: fatal error: no input files
> compilation terminated.
> configure:4414: $? = 1
> configure:4434: checking whether the C compiler works
> configure:4456: x86_64-apple-darwin23-gcc -march=native -pipe -O2   conftest.c  >&5
> ld: unknown option: -platform_version
> collect2: error: ld returned 1 exit status
> configure:4460: $? = 1
> configure:4498: result: no
> configure: failed program was:
> | /* confdefs.h */
> | #define PACKAGE_NAME ""
> | #define PACKAGE_TARNAME ""
> | #define PACKAGE_VERSION ""
> | #define PACKAGE_STRING ""
> | #define PACKAGE_BUGREPORT ""
> | #define PACKAGE_URL ""
> | /* end confdefs.h.  */
> | 
> | int
> | main ()
> | {
> | 
> |   ;
> |   return 0;
> | }
> configure:4503: error: in `/Users/ronie/tmp/shm/portage/sys-devel/gcc-13.2.0/work/build':
> configure:4505: error: C compiler cannot create executables
Comment 27 Ronie Henrich 2024-01-17 07:06:56 UTC
Created attachment 882449 [details]
gcc-build-logs darwin x64-23