mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-25 11:14:46 +00:00
Add parallel frontend to the build performance guide
This commit is contained in:
parent
5f0328fa7c
commit
a887a25565
@ -69,4 +69,23 @@ Trade-offs:
|
||||
- ❌ Only available for [certain targets](https://github.com/rust-lang/rustc_codegen_cranelift?tab=readme-ov-file#platform-support)
|
||||
- ❌ Might not support all Rust features (e.g. unwinding)
|
||||
|
||||
[codegen-backend-feature]: ../reference/unstable.md#codegen-backend
|
||||
[codegen-backend-feature]: ../reference/unstable.md#codegen-backend
|
||||
|
||||
### Enable the experimental parallel frontend
|
||||
|
||||
Recommendation: Add to your `.cargo/config.toml`:
|
||||
|
||||
```toml
|
||||
[build]
|
||||
rustflags = "-Zthreads=8"
|
||||
```
|
||||
|
||||
This [`rustflags`][build.rustflags] will enable the [parallel frontend][parallel-frontend-blog] of the Rust compiler, and tell it to use `n` threads. The value of `n` should be chosen according to the number of cores available on your system, although there are diminishing returns. We recommend using at most `8` threads.
|
||||
|
||||
Trade-offs:
|
||||
- ✅ Faster build times
|
||||
- ❌ **Requires using nightly Rust and an [unstable Rust feature][parallel-frontend-issue]**
|
||||
|
||||
[parallel-frontend-blog]: https://blog.rust-lang.org/2023/11/09/parallel-rustc/
|
||||
[parallel-frontend-issue]: https://github.com/rust-lang/rust/issues/113349
|
||||
[build.rustflags]: ../reference/config.md#buildrustflags
|
||||
|
Loading…
x
Reference in New Issue
Block a user