Thanks for the suggestion, William. I tried sccache and it reduced the build time of the whole project to half of the time. We might consider adding it to GitHub Actions.
________________________________ De: William Brown firstname.lastname@example.org Enviado: jueves, 27 de abril de 2023 23:04 Para: Imobach Gonzalez Sosa IGonzalezSosa@suse.com Cc: YaST-devel email@example.com Asunto: Re: Trying a faster linker for Rust
You can also setup sccache both locally and in OBS - they help a ton.
With GNU ld and no sccache a Rust compiler build takes ~2 hours on my 8 core xeon
With lld and no sccache it takes ~1 hour.
With sccache warmed it takes 10 minutes.
It's worth looking into :)
On 27 Apr 2023, at 15:59, Imobach Gonzalez Sosa IGonzalezSosa@suse.com wrote:
When working with a compiled language (like Rust, in this case), you must often rebuild the project to test your changes. On my system, after a small change, rebuilding Agama takes around 4 seconds. TIL that most of the time is spent by the linker, and you can switch to a faster one if you wish. In my case, the build time was reduced to around 1.6 seconds.
AFAIK, you have two options: lld and mold, and both of them are available in openSUSE Tumbleweed.
You need to install "clang" and "lld" or "mold" packages. Then, add the following lines to your ~/.cargo/config.toml file:
[target.x86_64-unknown-linux-gnu] rustflags = ["-C", "linker=clang", "-C", "link-arg=-fuse-ld=lld"]
Replace "lld" with "mold" if you prefer. And that's all 🙂
PS: you can want to know how much time it takes to compile each crate, try "cargo build --timings" and check the generated report.
 Bear in mind that a complete rebuild takes around 35-40 seconds if the dependencies are already downloaded, but that's a different history.  https://lld.llvm.org/  https://github.com/rui314/mold
Senior Software Engineer, Identity and Access Management SUSE Labs, Australia