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.

2 Likes

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.

2 Likes

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

1 Like

No problem!

1 Like

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.

2 Likes

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