Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

RUSTFLAGS="-C linker=clang -C link-arg=-fuse-ld=/path/to/mold" cargo build

or persitant in your project:

.cargo/config.toml

[target.x86_64-unknown-linux-gnu] linker = "clang" rustflags = ["-C", "link-arg=-fuse-ld=/PATH/TO/mold"]



-fuse-ld has been replaced by --ld-path in clang 12+


Good to know, thanks.

fuse-ld still works though.


I wonder -- "-fuse-ld" has some somewhat surprising behavior in how clang ends up discovering the linker. I think that even if clang has a sibling `lld` in the same distribution, "-fuse-ld=lld" will pick "ld.lld" from the $PATH if it's present in there before the directory where clang and lld are installed.

So maybe that "--ld-path" option helps resolve ambiguity by expecting an explicit path instead of a linker name.


Thank you. Will try it later




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: