mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-26 13:01:27 +03:00
Add parallel-frontend-threads to bootstrap.toml and enable multi-threaded parallel compilation
This commit is contained in:
@@ -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
|
||||
#
|
||||
|
||||
@@ -340,6 +340,11 @@ o(
|
||||
"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):
|
||||
|
||||
@@ -679,6 +679,12 @@ fn cargo(
|
||||
// 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));
|
||||
|
||||
@@ -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,
|
||||
@@ -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>,
|
||||
@@ -534,6 +535,7 @@ pub(crate) fn parse_inner(
|
||||
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,
|
||||
@@ -1298,6 +1300,7 @@ pub(crate) fn parse_inner(
|
||||
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),
|
||||
|
||||
@@ -66,6 +66,7 @@ struct Rust {
|
||||
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",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,6 +358,7 @@ macro_rules! warn {
|
||||
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:
|
||||
|
||||
@@ -546,4 +546,9 @@ pub fn human_readable_changes(changes: &[ChangeInfo]) -> String {
|
||||
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.",
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user