Conversation

Jarkko Sakkinen

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
1
2
0

@jarkko what glitches were you experiencing? I’ve had some recent problems where accepting an autocomplete suggestion actually interpolates a different value into the file, and I was wondering if it’s a mold problem

1
0
0
@johnbchron Eating up too much memory and whole session freezing.

This happened with GNU ld (default), mold and wild. LLVM ld seems to be only that is kind of "steady performer". Just my experience but sticking to what works (for me)...
1
0
0
@johnbchron With other linkers Zed performs the best but launching e.g. Helix takes down the whole fucking GNOME session 🤷 And this has been going on for two months. Even buying 9950X based desktop did not cure the issue. I'm still happy that I got it because it does help with compiling Rust, which can be more heavy on CPU than e.g. compiling an operating system image with BuildRoot.
0
0
0