Improve Rust Link Time with lld
Today I start to experiment with the WebGPU API, and I choose to use the wgpu-rs implementation in Rust. I am happy with the experience overall, but one difficulty I met is the long iterative compilation time:
For some applications, slow compile-time is OK. Coding some hard algorithms requires extensive thinking, and if they compile and pass unit tests, they are likely correct.
By contrast, for graphics and game programming, iteration time is paramount. A lot of the time, there are no right or wrong answer to a problem, instead, we need to do a lot of small tweakings.
Fortunately, a person (user Rukai) on the Graphics Programming Discord provides a solution.
What I need to do is to create a config file
rustflags = [
This flag sets
lld to the linker, which is way faster than Rust's default linker.
And I also need to install
lld on my computer.
And this simple change magically makes my iterative compilation time under 3s. It is still not ideal from my perspective, but at least I can enjoy doing this project again.