Skip to content

Commit 8488795

Browse files
committed
Add unstable feature link and cargo config example
1 parent 9a63dd7 commit 8488795

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/doc/src/guide/build-performance.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,25 @@ Trade-offs:
7171

7272
### Enable the experimental parallel frontend
7373

74-
Recommendation: Add `-Zthreads=n` to the `RUSTFLAGS` environment variable[^rustflags], for example:
74+
Recommendation: Add `-Zthreads=n` to the `RUSTFLAGS` environment variable, for example:
7575

7676
```console
77-
$ RUSTFLAGS="-Zthreads=8" cargo build
77+
$ RUSTFLAGS="-Zthreads=8" cargo +nightly build
7878
```
7979

80-
This will enable the [parallel frontend][parallel-frontend] 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 to set at most `8` threads.
80+
You can configure `RUSTFLAGS` using [Cargo config](../reference/config.md#buildrustflags), so that you do not have to pass the flag on every cargo invocation manually:
81+
82+
```toml
83+
# .cargo/config.toml
84+
[build]
85+
rustflags = "-Zthreads=8"
86+
```
87+
88+
This 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.
8189

8290
Trade-offs:
8391
- ✅ Faster build times
84-
-**Requires using nightly Rust and an unstable Cargo feature**
85-
86-
[^rustflags]: You can configure `RUSTFLAGS` either as an environment variable when running Cargo, or through the [Cargo config](../reference/config.md#targettriplerustflags).
92+
-**Requires using nightly Rust and an [unstable Rust feature][parallel-frontend-issue]**
8793

88-
[parallel-frontend]: https://blog.rust-lang.org/2023/11/09/parallel-rustc/
94+
[parallel-frontend-blog]: https://blog.rust-lang.org/2023/11/09/parallel-rustc/
95+
[parallel-frontend-issue]: https://github.com/rust-lang/rust/issues/113349

0 commit comments

Comments
 (0)