Hi,
Thanks for the suggestion, William. I tried sccache[1] and it reduced the build time of the whole project to half of the time. We might consider adding it to GitHub Actions[2].
Regards,
Imo
[1] https://github.com/mozilla/sccache
[2] https://github.com/mozilla/sccache/blob/main/docs/GHA.md
________________________________
De: William Brown <william.brown@suse.com>
Enviado: jueves, 27 de abril de 2023 23:04
Para: Imobach Gonzalez Sosa <IGonzalezSosa@suse.com>
Cc: YaST-devel <yast-devel@lists.opensuse.org>
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:
Hi all,
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[1]. 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[2] and mold[3], 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.
Regards,
Imo
[1] Bear in mind that a complete rebuild takes around 35-40 seconds if the dependencies are already downloaded, but that's a different history.
[2] https://lld.llvm.org/
[3] https://github.com/rui314/mold
--
Sincerely,
William Brown
Senior Software Engineer,
Identity and Access Management
SUSE Labs, Australia