commit:     941cc3c5faae01bff0045d92e62da0a9689a0358
Author:     Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 16 00:17:38 2022 +0000
Commit:     Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
CommitDate: Fri Sep 16 00:46:12 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=941cc3c5

dev-lang/rust: fix bootstrap on musl systems without gcc_s

After extensive debug session we can bootstrap rust with
upstream tarball on clang-musl-no-gcc system

Thanks-to: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache.Org>
Thanks-to: Sam James <sam <AT> gentoo.org>
Closes: https://bugs.gentoo.org/870280
Signed-off-by: Georgy Yakovlev <gyakovlev <AT> gentoo.org>

 dev-lang/rust/rust-1.63.0-r1.ebuild | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/dev-lang/rust/rust-1.63.0-r1.ebuild 
b/dev-lang/rust/rust-1.63.0-r1.ebuild
index 6031ffd57528..2fdf93de9880 100644
--- a/dev-lang/rust/rust-1.63.0-r1.ebuild
+++ b/dev-lang/rust/rust-1.63.0-r1.ebuild
@@ -253,8 +253,29 @@ pkg_setup() {
        fi
 }
 
+
+esetup_unwind_hack() {
+       # https://bugs.gentoo.org/870280
+       # this is a hack needed to bootstrap with libgcc_s linked tarball on 
llvm-libunwind system
+       # it should trigger for internal bootstrap or system-bootstrap with 
rust-bin
+       # the whole idea is for stage0 to bootstrap with fake libgcc_s
+       # final stage will receive -L${T}/lib but not -lgcc_s args, producing 
clean compiler.
+       local fakelib="${T}/fakelib"
+       mkdir -p "${fakelib}" || die
+       # we need both symlinks, one for cargo runtime, other for linker.
+       ln -s "${ESYSROOT}/usr/lib/libunwind.so" "${fakelib}/libgcc_s.so.1" || 
die
+       ln -s "${ESYSROOT}/usr/lib/libunwind.so" "${fakelib}/libgcc_s.so" || die
+       export LD_LIBRARY_PATH="${fakelib}"
+       export RUSTFLAGS+=" -L${fakelib}"
+       # this is a literally magic variable that gets through cargo cache, 
without it some
+       # crates ignore RUSTFLAGS
+       # this variable can not contain leading space
+       export MAGIC_EXTRA_RUSTFLAGS+="${MAGIC_EXTRA_RUSTFLAGS:+ }-L${fakelib}"
+}
+
 src_prepare() {
        if ! use system-bootstrap; then
+               has_version sys-devel/gcc || esetup_unwind_hack
                local rust_stage0_root="${WORKDIR}"/rust-stage0
                local rust_stage0="rust-${RUST_STAGE0_VERSION}-$(rust_abi)"
 
@@ -551,6 +572,7 @@ src_configure() {
        echo RUSTFLAGS="${RUSTFLAGS:-}"
        echo RUSTFLAGS_BOOTSTRAP="${RUSTFLAGS_BOOTSTRAP:-}"
        echo RUSTFLAGS_NOT_BOOTSTRAP="${RUSTFLAGS_NOT_BOOTSTRAP:-}"
+       echo MAGIC_EXTRA_RUSTFLAGS="${MAGIC_EXTRA_RUSTFLAGS:-}"
        env | grep "CARGO_TARGET_.*_RUSTFLAGS="
        cat "${S}"/config.env || die
        echo

Reply via email to