When bootstrapping Gentoo Prefix on macOS 13.2 (Ventura) on an Apple M1 system, it will fail at stage2 due to a GCC build failure because GCC 12.1 is incompatible with macOS 13. make[2]: Entering directory '/Users/apple/gentoo/tmp/var/tmp/portage/sys-devel/gcc-12.1.0/work/build/gcc' /Users/apple/Gentoo/tmp/var/tmp/portage/sys-devel/gcc-12.1.0/work/build/./gcc/xgcc -B/Users/apple/Gentoo/tmp/var/tmp/portage/sys-devel/g cc-12.1.0/work/build/./gcc/ -xc++ -nostdinc /dev/null -S -o /dev/null -fself-test=/Users/apple/Gentoo/tmp/var/tmp/portage/sys-devel/gcc- 12.1.0/work/gcc-12-branch-gcc-12.1-darwin-r0/gcc/testsuite/selftests <built-in>: error: unknown value '13.0' of '-mmacosx-version-min' This problem can be fixed by applying the upstream patch * Darwin: Future-proof -mmacosx-version-min > f18cbc1ee1f4 (2021-12-18) updated various parts of gcc to not impose a > Darwin or macOS version maximum of the current known release. [...] However, > f18cbc1ee1f4 missed config/darwin-c.c (now .cc), which continued to impose a > maximum of macOS 12 on the -mmacosx-version-min compiler driver argument. https://github.com/gcc-mirror/gcc/commit/6725f186cb70d48338f69456864bf469a12ee5be.patch However, there's another separate name collision bug in fs_path.h of libstdc++ that will produce another error, similar to the following (I lost the original logs, this is copied from an issue I found online). In file included from /private/tmp/gccA10-20221211-4993-1miwm67/gcc-10.4.0/build/x86_64-apple-darwin22/libstdc++-v3/include/filesystem:45, from ../../../../../libstdc++-v3/src/c++17/fs_dir.cc:30: /private/tmp/gccA10-20221211-4993-1miwm67/gcc-10.4.0/build/x86_64-apple-darwin22/libstdc++-v3/include/bits/fs_path.h:133:30: error: abstract declarator 'std::filesystem::__cxx11::__detail::<unnamed struct>' used as declaration 133 | struct __null_terminated { }; To fix this problem, the following upstream patch must be applied: * libstdc++: Rename __null_terminated to avoid collision with Apple SDK > The macOS 13 SDK (and equivalent-version iOS and other Apple OS SDKs) > contain this definition in <sys/cdefs.h>: "#define __null_terminated" This > collides with the use of __null_terminated in libstdc++'s experimental > fs_path.h. https://github.com/gcc-mirror/gcc/commit/d1201dbf55a11d391030914985ba6b443e59baa5.patch Fixing both problems allow successful compile of sys-devel/gcc-12.1.0 in stage2 and stage3. Note that sys-devel/gcc-12.2.0 has its own bugs that prevents bootstrapping from happening. My recommendation is fixing sys-devel/gcc-12.1.0 for now, and masking sys-devel/gcc-12.2.0 until the problem has been throughoutly investigated.
For patches, I just created a Pull Request on GitHub: https://github.com/gentoo/prefix/pull/17
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=d3ca44544e61178286f5c979fed2d4f36f3332b3 commit d3ca44544e61178286f5c979fed2d4f36f3332b3 Author: Yifeng Li <tomli@tomli.me> AuthorDate: 2023-02-18 22:42:05 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2023-02-19 18:53:03 +0000 sys-devel/gcc-12.1.0: patch to fix macOS 13 build. When bootstrapping Gentoo Prefix on macOS 13.2 (Ventura) on an Apple M1 system, it will fail at stage2 due to a GCC build failure because GCC 12.1 is incompatible with macOS 13. make[2]: Entering directory '/Users/apple/gentoo/tmp/var/tmp/portage/sys-devel/gcc-12.1.0/work/build/gcc' /Users/apple/Gentoo/tmp/var/tmp/portage/sys-devel/gcc-12.1.0/work/build/./gcc/xgcc -B/Users/apple/Gentoo/tmp/var/tmp/portage/sys-devel/g cc-12.1.0/work/build/./gcc/ -xc++ -nostdinc /dev/null -S -o /dev/null -fself-test=/Users/apple/Gentoo/tmp/var/tmp/portage/sys-devel/gcc- 12.1.0/work/gcc-12-branch-gcc-12.1-darwin-r0/gcc/testsuite/selftests <built-in>: error: unknown value '13.0' of '-mmacosx-version-min' This problem can be fixed by applying the upstream patch * Darwin: Future-proof -mmacosx-version-min > f18cbc1ee1f4 (2021-12-18) updated various parts of gcc to not impose a > Darwin or macOS version maximum of the current known release. [...] However, > f18cbc1ee1f4 missed config/darwin-c.c (now .cc), which continued to impose a > maximum of macOS 12 on the -mmacosx-version-min compiler driver argument. https://github.com/gcc-mirror/gcc/commit/6725f186cb70d48338f69456864bf469a12ee5be.patch However, there's another separate name collision bug in fs_path.h of libstdc++ that will produce another error, similar to the following (I lost the original logs, this is copied from an issue I found online). In file included from /private/tmp/gccA10-20221211-4993-1miwm67/gcc-10.4.0/build/x86_64-apple-darwin22/libstdc++-v3/include/filesystem:45, from ../../../../../libstdc++-v3/src/c++17/fs_dir.cc:30: /private/tmp/gccA10-20221211-4993-1miwm67/gcc-10.4.0/build/x86_64-apple-darwin22/libstdc++-v3/include/bits/fs_path.h:133:30: error: abstract declarator 'std::filesystem::__cxx11::__detail::<unnamed struct>' used as declaration 133 | struct __null_terminated { }; To fix this problem, the following upstream patch must be applied: * libstdc++: Rename __null_terminated to avoid collision with Apple SDK > The macOS 13 SDK (and equivalent-version iOS and other Apple OS SDKs) > contain this definition in <sys/cdefs.h>: "#define __null_terminated" This > collides with the use of __null_terminated in libstdc++'s experimental > fs_path.h. https://github.com/gcc-mirror/gcc/commit/d1201dbf55a11d391030914985ba6b443e59baa5.patch Fixing both problems allow successful compile of sys-devel/gcc-12.1.0 in stage2 and stage3. This commit fixes Gentoo bug 895332 [1]. Note that sys-devel/gcc-12.2.0 has its own bugs (Gentoo bug 895334) that prevents bootstrapping from happening. My recommendation is fixing sys-devel/gcc-12.1.0 for now, and masking sys-devel/gcc-12.2.0 until the problem has been thoroughly investigated. Closes: https://bugs.gentoo.org/895332 Signed-off-by: Yifeng Li <tomli@tomli.me> Closes: https://github.com/gentoo/prefix/pull/17 Signed-off-by: Sam James <sam@gentoo.org> ...rminated-name-collision-with-macos-13-sdk.patch | 85 ++++++++++++++++++++++ ...ognize-mmacosx-version-min-13.0-and-newer.patch | 54 ++++++++++++++ sys-devel/gcc/gcc-12.1.0.ebuild | 4 + 3 files changed, 143 insertions(+)