From 5f0328fa7c294f157d65ee117b80cdab104da448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 19 Sep 2025 20:08:32 +0200 Subject: [PATCH 1/2] Add link to `-Zcodegen-backend` feature --- src/doc/src/guide/build-performance.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/doc/src/guide/build-performance.md b/src/doc/src/guide/build-performance.md index a9e46f673..51d1345cb 100644 --- a/src/doc/src/guide/build-performance.md +++ b/src/doc/src/guide/build-performance.md @@ -63,8 +63,10 @@ This will change the [`dev` profile](../reference/profiles.md#dev) to use the [C Trade-offs: - ✅ Faster code generation (`cargo build`) -- ❌ **Requires using nightly Rust and an unstable Cargo feature** +- ❌ **Requires using nightly Rust and an [unstable Cargo feature][codegen-backend-feature]** - ❌ Worse runtime performance of the generated code - Speeds up build part of `cargo test`, but might increase its test execution part - ❌ 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 \ No newline at end of file From a887a25565efbc2b7f4853101e8a9e5d2663fd45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 19 Sep 2025 20:08:45 +0200 Subject: [PATCH 2/2] Add parallel frontend to the build performance guide --- src/doc/src/guide/build-performance.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/doc/src/guide/build-performance.md b/src/doc/src/guide/build-performance.md index 51d1345cb..c321ee8a4 100644 --- a/src/doc/src/guide/build-performance.md +++ b/src/doc/src/guide/build-performance.md @@ -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 \ No newline at end of file +[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