Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions bootstrap.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,14 @@
# Trigger a `DebugBreak` after an internal compiler error during bootstrap on Windows
#rust.break-on-ice = true

# Set the number of threads for the compiler frontend used during compilation of Rust code (passed to `-Zthreads`).
# The valid options are:
# 0 - Set the number of threads according to the detected number of threads of the host system
# 1 - Use a single thread for compilation of Rust code (the default)
# N - Number of threads used for compilation of Rust code
#
#rust.parallel-frontend-threads = 1

# =============================================================================
# Distribution options
#
Expand Down
5 changes: 5 additions & 0 deletions src/bootstrap/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,11 @@ def v(*args):
"don't truncate options when printing them in this configure script",
)
v("set", None, "set arbitrary key/value pairs in TOML configuration")
v(
"parallel-frontend-threads",
"rust.parallel-frontend-threads",
"number of parallel threads for rustc compilation",
)


def p(msg):
Expand Down
6 changes: 6 additions & 0 deletions src/bootstrap/src/core/builder/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,12 @@ impl Builder<'_> {
// cargo would implicitly add it, it was discover that sometimes bootstrap only use
// `rustflags` without `cargo` making it required.
rustflags.arg("-Zunstable-options");

// Add parallel frontend threads configuration
if let Some(threads) = self.config.rust_parallel_frontend_threads {
rustflags.arg(&format!("-Zthreads={threads}"));
}

for (restricted_mode, name, values) in EXTRA_CHECK_CFGS {
if restricted_mode.is_none() || *restricted_mode == Some(mode) {
rustflags.arg(&check_cfg_arg(name, *values));
Expand Down
5 changes: 4 additions & 1 deletion src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ pub struct Config {
pub rust_optimize: RustOptimize,
pub rust_codegen_units: Option<u32>,
pub rust_codegen_units_std: Option<u32>,

pub rustc_debug_assertions: bool,
pub std_debug_assertions: bool,
pub tools_debug_assertions: bool,
Expand Down Expand Up @@ -222,6 +221,8 @@ pub struct Config {
pub rust_validate_mir_opts: Option<u32>,
pub rust_std_features: BTreeSet<String>,
pub rust_break_on_ice: bool,
pub rust_parallel_frontend_threads: Option<u32>,

pub llvm_profile_use: Option<String>,
pub llvm_profile_generate: bool,
pub llvm_libunwind_default: Option<LlvmLibunwind>,
Expand Down Expand Up @@ -534,6 +535,7 @@ impl Config {
backtrace_on_ice: rust_backtrace_on_ice,
verify_llvm_ir: rust_verify_llvm_ir,
thin_lto_import_instr_limit: rust_thin_lto_import_instr_limit,
parallel_frontend_threads: rust_parallel_frontend_threads,
remap_debuginfo: rust_remap_debuginfo,
jemalloc: rust_jemalloc,
test_compare_mode: rust_test_compare_mode,
Expand Down Expand Up @@ -1298,6 +1300,7 @@ impl Config {
rust_overflow_checks_std: rust_overflow_checks_std
.or(rust_overflow_checks)
.unwrap_or(rust_debug == Some(true)),
rust_parallel_frontend_threads: rust_parallel_frontend_threads.map(threads_from_config),
rust_profile_generate: flags_rust_profile_generate.or(rust_profile_generate),
rust_profile_use: flags_rust_profile_use.or(rust_profile_use),
rust_randomize_layout: rust_randomize_layout.unwrap_or(false),
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/src/core/config/toml/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ define_config! {
validate_mir_opts: Option<u32> = "validate-mir-opts",
std_features: Option<BTreeSet<String>> = "std-features",
break_on_ice: Option<bool> = "break-on-ice",
parallel_frontend_threads: Option<u32> = "parallel-frontend-threads",
}
}

Expand Down Expand Up @@ -357,6 +358,7 @@ pub fn check_incompatible_options_for_ci_rustc(
validate_mir_opts: _,
frame_pointers: _,
break_on_ice: _,
parallel_frontend_threads: _,
} = ci_rust_config;

// There are two kinds of checks for CI rustc incompatible options:
Expand Down
5 changes: 5 additions & 0 deletions src/bootstrap/src/utils/change_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,4 +546,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
severity: ChangeSeverity::Info,
summary: "The default value of the `gcc.download-ci-gcc` option has been changed to `true`.",
},
ChangeInfo {
change_id: 146458,
severity: ChangeSeverity::Info,
summary: "There is now a bootstrap option called `rust.parallel-frontend-threads`, which can be used to set the number of threads for the compiler frontend used during compilation of Rust code.",
},
];
Loading