Alternative linkers: gold, mold?

Is anyone using GitHub - rui314/mold: mold: A Modern Linker or gold (linker) - Wikipedia to speed up rustc linker time ?

If so, what are the results like and how did you set it up ?

1 Like

I've been trying to use mold on NixOS. The speed gain is a bliss, especially when you need to produce a big binary like a GUI executable.

However, compatibility is still a problem. You may need project specific .cargo/config.toml. Where mold does not work, gold as a fallback does.

Below is a config using mold.

[target.x86_64-unknown-linux-gnu]
linker = "/nix/store/52w8z9p8m5idz4fsh9y1znmms59da8ba-clang-wrapper-13.0.0/bin/clang"
rustflags = [
  "-C", "link-arg=-fuse-ld=/nix/store/bpm6y6q12r2zh51g0kw6p12kc8mx47nz-mold-0.9.6/bin/mold"
  # "-C", "link-arg=-fuse-ld=/nix/store/icvw360v0nqbizr2a5abaz1ss207bgf9-lld-13.0.0/bin/lld"
  # "-C", "link-arg=-fuse-ld=gold"
]
1 Like

How does gold compare to lld? I thought lld was faster

Right, lld is generally faster. Unfortunately, it suffers from the same problem as mold regarding compatibility on my machine.

@Congee What was the compatibility problem?

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.