I was wondering why rust-analyzer does random hickups and switching to lld finally fixed it. The choice of linker inherits from matching Rust environment of macOS, which does use LLVM ld, and never experienced similar glitches. This even happened sometimes with 9950X desktop.
So for any Rust installation in Linux I'd first and foremost always add this to .cargo/config.toml before anything else:
[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = ["-C", "link-arg=-fuse-ld=/usr/bin/lld"]
Installation:
1. In Fedora: dnf install lld
2. In Debian: apt install lld
AFAIK, by de-facto it probably uses GNU ld, and also some flashier newer ones do not provide glitch-free result with rust-analyzer (i.e. mold and wild).
#rust #llvm