Could rustc compile dependencies in parallel?

I’m just wondering if it would be possible to compile several crates (that don’t depend on each other) simultaneously. I guess that this would speed up the first debug and release build a lot. However, I don’t know too much about how rustc/LLVM works.

1 Like

Cargo already does this. If you watch the progress bar as it builds, the list to the right of the bar are the ones building parallel. You can also look in your system’s process monitor to see multiple rustc at once.

1 Like

Oh, I wasn’t aware of this. Sorry to waste your time.

No problem!

rustc also divides large crates into smaller chunks and compiles these chunks in parallel, so it can use multiple CPU cores even when compiling a single crate. However, only certain phases of compilation can be parallelized in this way. Other phases are still largely single-threaded.

1 Like

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