Add parallel-frontend-threads to bootstrap.toml and enable multi-threaded parallel compilation
This commit is contained in:
parent
52618eb338
commit
929c9335dd
6 changed files with 30 additions and 1 deletions
|
|
@ -859,6 +859,14 @@
|
||||||
# Trigger a `DebugBreak` after an internal compiler error during bootstrap on Windows
|
# Trigger a `DebugBreak` after an internal compiler error during bootstrap on Windows
|
||||||
#rust.break-on-ice = true
|
#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
|
# Distribution options
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -340,6 +340,11 @@ o(
|
||||||
"don't truncate options when printing them in this configure script",
|
"don't truncate options when printing them in this configure script",
|
||||||
)
|
)
|
||||||
v("set", None, "set arbitrary key/value pairs in TOML configuration")
|
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):
|
def p(msg):
|
||||||
|
|
|
||||||
|
|
@ -679,6 +679,12 @@ impl Builder<'_> {
|
||||||
// cargo would implicitly add it, it was discover that sometimes bootstrap only use
|
// cargo would implicitly add it, it was discover that sometimes bootstrap only use
|
||||||
// `rustflags` without `cargo` making it required.
|
// `rustflags` without `cargo` making it required.
|
||||||
rustflags.arg("-Zunstable-options");
|
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 {
|
for (restricted_mode, name, values) in EXTRA_CHECK_CFGS {
|
||||||
if restricted_mode.is_none() || *restricted_mode == Some(mode) {
|
if restricted_mode.is_none() || *restricted_mode == Some(mode) {
|
||||||
rustflags.arg(&check_cfg_arg(name, *values));
|
rustflags.arg(&check_cfg_arg(name, *values));
|
||||||
|
|
|
||||||
|
|
@ -191,7 +191,6 @@ pub struct Config {
|
||||||
pub rust_optimize: RustOptimize,
|
pub rust_optimize: RustOptimize,
|
||||||
pub rust_codegen_units: Option<u32>,
|
pub rust_codegen_units: Option<u32>,
|
||||||
pub rust_codegen_units_std: Option<u32>,
|
pub rust_codegen_units_std: Option<u32>,
|
||||||
|
|
||||||
pub rustc_debug_assertions: bool,
|
pub rustc_debug_assertions: bool,
|
||||||
pub std_debug_assertions: bool,
|
pub std_debug_assertions: bool,
|
||||||
pub tools_debug_assertions: bool,
|
pub tools_debug_assertions: bool,
|
||||||
|
|
@ -222,6 +221,8 @@ pub struct Config {
|
||||||
pub rust_validate_mir_opts: Option<u32>,
|
pub rust_validate_mir_opts: Option<u32>,
|
||||||
pub rust_std_features: BTreeSet<String>,
|
pub rust_std_features: BTreeSet<String>,
|
||||||
pub rust_break_on_ice: bool,
|
pub rust_break_on_ice: bool,
|
||||||
|
pub rust_parallel_frontend_threads: Option<u32>,
|
||||||
|
|
||||||
pub llvm_profile_use: Option<String>,
|
pub llvm_profile_use: Option<String>,
|
||||||
pub llvm_profile_generate: bool,
|
pub llvm_profile_generate: bool,
|
||||||
pub llvm_libunwind_default: Option<LlvmLibunwind>,
|
pub llvm_libunwind_default: Option<LlvmLibunwind>,
|
||||||
|
|
@ -534,6 +535,7 @@ impl Config {
|
||||||
backtrace_on_ice: rust_backtrace_on_ice,
|
backtrace_on_ice: rust_backtrace_on_ice,
|
||||||
verify_llvm_ir: rust_verify_llvm_ir,
|
verify_llvm_ir: rust_verify_llvm_ir,
|
||||||
thin_lto_import_instr_limit: rust_thin_lto_import_instr_limit,
|
thin_lto_import_instr_limit: rust_thin_lto_import_instr_limit,
|
||||||
|
parallel_frontend_threads: rust_parallel_frontend_threads,
|
||||||
remap_debuginfo: rust_remap_debuginfo,
|
remap_debuginfo: rust_remap_debuginfo,
|
||||||
jemalloc: rust_jemalloc,
|
jemalloc: rust_jemalloc,
|
||||||
test_compare_mode: rust_test_compare_mode,
|
test_compare_mode: rust_test_compare_mode,
|
||||||
|
|
@ -1298,6 +1300,7 @@ impl Config {
|
||||||
rust_overflow_checks_std: rust_overflow_checks_std
|
rust_overflow_checks_std: rust_overflow_checks_std
|
||||||
.or(rust_overflow_checks)
|
.or(rust_overflow_checks)
|
||||||
.unwrap_or(rust_debug == Some(true)),
|
.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_generate: flags_rust_profile_generate.or(rust_profile_generate),
|
||||||
rust_profile_use: flags_rust_profile_use.or(rust_profile_use),
|
rust_profile_use: flags_rust_profile_use.or(rust_profile_use),
|
||||||
rust_randomize_layout: rust_randomize_layout.unwrap_or(false),
|
rust_randomize_layout: rust_randomize_layout.unwrap_or(false),
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ define_config! {
|
||||||
validate_mir_opts: Option<u32> = "validate-mir-opts",
|
validate_mir_opts: Option<u32> = "validate-mir-opts",
|
||||||
std_features: Option<BTreeSet<String>> = "std-features",
|
std_features: Option<BTreeSet<String>> = "std-features",
|
||||||
break_on_ice: Option<bool> = "break-on-ice",
|
break_on_ice: Option<bool> = "break-on-ice",
|
||||||
|
parallel_frontend_threads: Option<u32> = "parallel-frontend-threads",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -357,6 +358,7 @@ pub fn check_incompatible_options_for_ci_rustc(
|
||||||
validate_mir_opts: _,
|
validate_mir_opts: _,
|
||||||
frame_pointers: _,
|
frame_pointers: _,
|
||||||
break_on_ice: _,
|
break_on_ice: _,
|
||||||
|
parallel_frontend_threads: _,
|
||||||
} = ci_rust_config;
|
} = ci_rust_config;
|
||||||
|
|
||||||
// There are two kinds of checks for CI rustc incompatible options:
|
// There are two kinds of checks for CI rustc incompatible options:
|
||||||
|
|
|
||||||
|
|
@ -546,4 +546,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
|
||||||
severity: ChangeSeverity::Info,
|
severity: ChangeSeverity::Info,
|
||||||
summary: "The default value of the `gcc.download-ci-gcc` option has been changed to `true`.",
|
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…
Add table
Add a link
Reference in a new issue