Actix simple program take very long time to compile

I am trying the actix-web. I am so disapointed that my program takes almost 6 min to compile each time. the command used is cargo build.

Link to the coode : Rust Playground

Please advise.



It is normal, that build times in rust take a long time. The compilation time depends on your CPU.
Rust uses incremental compilation, which should speed up any cargo build after the first one.

You can run cargo check, if you only want to check for compiler errors and cargo run to directly run the command.

The actix-web project has a lot of (transitive) dependencies, and all of those need to be compiled.

To further speed up incremental changes there are a couple of tips here:


That raises the question why lld isn't the default linker in the first place.

Off the top of my head, two good reasons not to use LLD:

  • It is much less permissive than e.g. GNU ld, so some links which work with your usual linker will not work with lld without extra fiddling.
  • You are using an OS other than Linux, where LLD support ranges for meh to bad.

Not sure if either of those apply to linking Rust programs on linux, though... AFAIK, rustc itself uses lld correctly, so only non-Rust dependencies like C libs which may or may not be lld-compatible might be a problem.

1 Like

Sometimes disabling some of create features might help a lot, though you will need to understand what takes a long time to compile. In general build times were sped up with latest developments though it is still very active area, so if you discover that some specific dependencies take long to compile that is a good idea to submit issue in library repository directly. There is new feature of nightly compiler which allows to dissect build times and find which library takes too long or which one blocks parallel compilation: -Z timings, more information provided in this thread


There is an open issue on that:

I haven't read it thoroughly, but I'm pretty sure that they are working on getting Rust ready to make LLD the default linker on windows, too.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.