Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KirillLykov/0d6d27748dfe522d8799bb024c6e6ad2 to your computer and use it in GitHub Desktop.
Save KirillLykov/0d6d27748dfe522d8799bb024c6e6ad2 to your computer and use it in GitHub Desktop.
How to set up a linker with rust

In order to speed up your linking stage, you can use a linker that takes advantage of multiple CPU cores.

Such linkers are lld and mold.

mold is considered more cutting edge, but it works for me.

Just add

[build]
rustflags = ["-C", "link-arg=-fuse-ld=mold"]

into ~/.cargo/config.toml.

Here are some additional details: https://nnethercote.github.io/perf-book/compile-times.html You can do it for a single repository, only, if you add it into .cargo/config.toml inside the repository folder. And changing mold to lld changes the linker. sudo apt install mold to get the right in the first place. At least on Debian and Ubuntu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment