I'm using lld as my linker currently for Rust, but recently encountered the mold project, which is faster than lld. I'd like to try it for Rust compilation, but I'm not sure how to pass it in as my linker. In my .cargo/config
file I've got:
[target.x86_64-unknown-linux-gnu]
rustflags = [
"-C", "link-arg=-fuse-ld=lld",
]
But I can't just change that lld
to mold
, or provide the path to the mold
executable. Is there a way to get gcc to accept a path to a linker?
-Clinker
“controls which linkerrustc
invokes to link your code. It takes a path to the linker executable.” – Maggymold
, and therefore other options may also need to be set (if indeed it’s compatible with rustc at all). – Maggy.cargo/config:
[target.x86_64-unknown-linux-gnu] linker = "/usr/bin/mold" `. But just like @eggyal, I don't know mold either to guess if it will work. – Tepefy