Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 952925 - >=dev-lang/rust-1.84.0: should allow mold linker
Summary: >=dev-lang/rust-1.84.0: should allow mold linker
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal enhancement
Assignee: Randy Barlow
URL:
Whiteboard:
Keywords: PullRequest
Depends on:
Blocks:
 
Reported: 2025-03-30 07:49 UTC by Blacktea Hamburger
Modified: 2025-04-05 04:23 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Blacktea Hamburger 2025-03-30 07:49:25 UTC
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.
Comment 1 zyxhere 2025-04-04 07:15:48 UTC
(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"
Comment 2 Blacktea Hamburger 2025-04-04 14:08:54 UTC
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
Comment 3 Blacktea Hamburger 2025-04-04 14:21:34 UTC
I've been using these aggressive flag for a long time and haven't had any problems (except #951740, which has now been fixed).