commit:     1684174109750be2a0d96eba93d45ddea6f3c39e
Author:     Yifeng Li <tomli <AT> tomli <DOT> me>
AuthorDate: Mon Apr 24 05:50:09 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Apr 24 20:11:53 2023 +0000
URL:        https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=16841741

bootstrap-prefix.sh: use --disable-darwin-at-rpath in stage2

During Gentoo prefix bootstrap stage2, GCC is built with
"--disable-bootstrap". For Darwin, it means that rather than letting
GCC to eventually build itself using multiple passes, we're forcing
it to build with the host LLVM/clang toolchain in a single pass.
It's not officially supported, but practically it worked. However,
since >=gcc-12.2.0, in order to support the new embedded rpath
feature on Darwin, two incompatible options, "-nodefaultrpaths" and
"-nodefaultexport" are introduced. This causes linking failures,
since these options are only recognized by GCC and are unknown to
LLVM/clang (hypothetically, using an older GCC possibly causes the
same problem as well).

Thus, embedded rpath should be disabled during prefix bootstrap stage2
via --disable-darwin-at-rpath in EXTRA_ECONF.

Bug: https://bugs.gentoo.org/895334
Signed-off-by: Yifeng Li <tomli <AT> tomli.me>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 scripts/bootstrap-prefix.sh | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/scripts/bootstrap-prefix.sh b/scripts/bootstrap-prefix.sh
index c032f7424a..392d2f9a3c 100755
--- a/scripts/bootstrap-prefix.sh
+++ b/scripts/bootstrap-prefix.sh
@@ -1893,13 +1893,37 @@ bootstrap_stage2() {
        EXTRA_ECONF=$(rapx --with-sysroot=/) \
        emerge_pkgs --nodeps ${linker} || return 1
 
+       # During Gentoo prefix bootstrap stage2, GCC is built with
+       # "--disable-bootstrap". For Darwin, it means that rather than letting
+       # GCC to eventually build itself using multiple passes, we're forcing
+       # it to build with the host LLVM/clang toolchain in a single pass.
+       # It's not officially supported, but practically it worked. However,
+       # since >=gcc-12.2.0, in order to support the new embedded rpath
+       # feature on Darwin, two incompatible options, "-nodefaultrpaths" and
+       # "-nodefaultexport" are introduced. This causes linking failures,
+       # since these options are only recognized by GCC and are unknown to
+       # LLVM/clang (hypothetically, using an older GCC possibly causes the
+       # same problem as well).
+       #
+       # Thus, embedded rpath should be disabled during prefix bootstrap stage2
+       # and passed into EXTRA_ECONF.
+       # https://bugs.gentoo.org/895334
+       if [[ ${CHOST} == *-darwin* ]] ;
+       then
+               local disable_darwin_rpath="--disable-darwin-at-rpath"
+       else
+               local disable_darwin_rpath=""
+       fi
+
        for pkg in ${compiler_stage1} ; do
                # <glibc-2.5 does not understand .gnu.hash, use
                # --hash-style=both to produce also sysv hash.
                # GCC apparently drops CPPFLAGS at some point, which makes it
                # not find things like gmp which we just installed, so force it
                # to find our prefix
-               EXTRA_ECONF="--disable-bootstrap $(rapx 
--with-linker-hash-style=both) --with-local-prefix=${ROOT}" \
+               # For >=gcc-12.2.0, rpath needs to be disabled in stage2 on
+               # Darwin, see above.
+               EXTRA_ECONF="--disable-bootstrap $(rapx 
--with-linker-hash-style=both) --with-local-prefix=${ROOT} 
${disable_darwin_rpath}" \
                MYCMAKEARGS="-DCMAKE_USE_SYSTEM_LIBRARY_LIBUV=OFF" \
                GCC_MAKE_TARGET=all \
                OVERRIDE_CXXFLAGS="${CPPFLAGS} -O2 -pipe" \

Reply via email to