Need suggestions about library linking speed

Hi there!

I am developing a web application with actix-web framework. I have lots of other dependencies. cargo run outputs a binary about in size of ~170MB. When I change something and recompile the code, it took a long time on linking the libraries.

In order to avoid spending time on ld, I want to prelink all the libraries beforehand, just build my own crate without other dependencies linked, and dynamically link prelinked libraries and my crate at startup.

Here is my question, is it possible to do something similar to this, or do you have any other ideas about increasing compilation speed? I hope there is away to pass these linking steps.

Thanks!

Try linking with LLD, it is much faster. It's described in https://github.com/rust-lang/rust/issues/39915, but RUSTFLAGS="-C link-arg=-fuse-ld=lld" should just work nowadays.

@jschievink thanks for tip, whole compilation time decreased like 40% for a small change in code. What about prelinking the libraries? imo, It should be possible, however cargo's build structure may not allow it. Can some scripts do the job?

Update: nvm, I think linking time is so much shortened, that linking libraries beforehand does not worth.

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.