Could rustc compile dependencies in parallel?

#1

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.

0 Likes

#2

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

#3

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

0 Likes

#4

No problem!

0 Likes

#5

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