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
Created attachment 873471 [details] stage2.log
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.
and we should probably look into trying https://github.com/iains/gcc-13-branch
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?
Is there any workaround for this?
currently not, sorry
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?
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.
Created attachment 879454 [details] The gcc-build-logs.tar.xz with above patch applied.
Created attachment 879455 [details] gcc-13.2-build-logs.tar.xz I tested version 13.2.0, but encountered the same issue.
Created attachment 879456 [details] gcc-13.2.0.ebuild
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
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 ```
Ryan, would you mind making a PR to https://github.com/gentoo/prefix?
(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.
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.
Created attachment 881158 [details] build.log from trying to build gcc-12.2.0 with -mmacosx-version-min=12.0
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.
I get the feeling GCC shouldn't force a macos version, our ld-wrapper should set the appropriate one.
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(-)
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(+)
Thanks! How do I get bootstrap-prefix.sh to pick up these changes?
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.
with tomorrow's snapshot we can succeed the bootstrap (confirmed locally) when meson is in dev-build.
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(-)
(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
Created attachment 882449 [details] gcc-build-logs darwin x64-23