https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=caea6d9760e3f9a67d6e9205ae6c176548b19927 forced lld. But after testing, the mold linker can also be used to compile rust.
(In reply to Blacktea Hamburger from comment #0) > https://gitweb.gentoo.org/repo/gentoo.git/commit/ > ?id=caea6d9760e3f9a67d6e9205ae6c176548b19927 forced lld. But after testing, > the mold linker can also be used to compile rust. Even when LTO is used? AFAIK and what the bug in the commit suggests that rust can't be built with LTO without lld as the linker https://bugs.gentoo.org/947697 https://bugs.gentoo.org/948027 Try with these rust flags and see if rust packages build: RUSTFLAGS="-C target-cpu=native -C linker=clang -C linker-plugin-lto -C link-arg=-fuse-ld=mold"
I build rust packages with the following flags: LDFLAGS="${LDFLAGS} -fuse-ld=mold -Wl,--lto-O3" RUSTFLAGS="-Ctarget-cpu=native -Clink-arg=-fuse-ld=mold -Clink-arg=-Wl,--lto-O3 -Clinker-plugin-lto=/usr/lib/llvm/20/lib64/LLVMgold.so -Zdylib-lto -Zlocation-detail=none" CARGO_PROFILE_RELEASE_OPT_LEVEL=3 CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1 CARGO_PROFILE_RELEASE_LTO="thin" CARGO_PROFILE_RELEASE_STRIP="symbols" CARGO_PROFILE_RELEASE_PANIC="abort" CC="clang" CXX="clang++" CPP="clang-cpp" AR="llvm-ar" NM="llvm-nm" RANLIB="llvm-ranlib" These packages build successfully: rust librsvg ripgrep zram-generator gstreamer ruff
I've been using these aggressive flag for a long time and haven't had any problems (except #951740, which has now been fixed).
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e04826591046b92f5a3fcd2f1d0f31c42f78b2d2 commit e04826591046b92f5a3fcd2f1d0f31c42f78b2d2 Author: blackteahamburger <blackteahamburger@outlook.com> AuthorDate: 2025-03-30 07:51:13 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2025-04-20 08:00:21 +0000 dev-lang/rust: allow building with mold Closes: https://bugs.gentoo.org/952925 Signed-off-by: blackteahamburger <blackteahamburger@outlook.com> Closes: https://github.com/gentoo/gentoo/pull/41387 Signed-off-by: Sam James <sam@gentoo.org> dev-lang/rust/rust-1.84.0-r1.ebuild | 11 ++++++++--- dev-lang/rust/rust-1.84.1-r1.ebuild | 11 ++++++++--- dev-lang/rust/rust-1.85.0-r1.ebuild | 11 ++++++++--- dev-lang/rust/rust-1.85.0.ebuild | 11 ++++++++--- dev-lang/rust/rust-1.85.1.ebuild | 11 ++++++++--- dev-lang/rust/rust-1.86.0-r1.ebuild | 11 ++++++++--- dev-lang/rust/rust-9999.ebuild | 11 ++++++++--- 7 files changed, 56 insertions(+), 21 deletions(-)