Faster incremental builds on Windows with LLD, not anymore?

I'm on Windows 10 x64 with:
rustup 1.25.1 (bb60b1e89 2022-07-12)
rustc 1.66.1 (90743e729 2023-01-10)
MSVC v143 installed with Visual Studio Installer from Microsoft.

If I open a Rust project and change a simple char in code (eg: a variable value from 1 to 2) it re-builds the project (using watchexec) in 12 seconds.

I installed llvm and used this in global cargo config file (C:/Users/<username>/.cargo/config)

[target.x86_64-pc-windows-msvc]
linker = "lld-link.exe"

After a cargo clean and an initial re-build (debug mode, 2 minutes, the same as without lld) the time is the same (maybe even worse than 1 second).

So no change with or without LLD.

Can you confirm or am I wrong?

How to get faster incremental (development) builds?

Just to make sure that the target is correct, what output do you get from rustc -V -v?

You can use the compiler's self profiling support to see how much time is actually spent in linking the final artifact. If this isn't a meaningful portion of the incremental compilation time, it isn't possible for switching linkers to have a meaningful impact on incremental compilation time.

Additionally, it looks like the performance of the default-used link.exe may have improved recently, shrinking the performance gap between the default and using lld.

Separately, you might have more luck installing the Rust vendored copy of lld via cargo-binutils and linking with "rust-lld.exe" instead; the Rust-specific copy of lld may have some Rust-specific fixes and/or be better at working with the version of LLVM which the Rust compiler is using.

2 Likes
rustc 1.66.1 (90743e729 2023-01-10)
binary: rustc
commit-hash: 90743e7298aca107ddaa0c202a4d3604e29bfeb6
commit-date: 2023-01-10
host: x86_64-pc-windows-msvc
release: 1.66.1
LLVM version: 15.0.2

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.