move parallel_compiler handling into prepare_tool_cargo so that it is done everywhere

This commit is contained in:
Ralf Jung 2024-03-30 13:52:32 +01:00
parent 7ac5f604c1
commit 288daeb14f
3 changed files with 11 additions and 16 deletions

View File

@ -1130,12 +1130,6 @@ pub fn rustc_cargo_env(
cargo.env("CFG_DEFAULT_LINKER", s);
}
if builder.config.rustc_parallel {
// keep in sync with `bootstrap/lib.rs:Build::rustc_features`
// `cfg` option for rustc, `features` option for cargo, for conditional compilation
cargo.rustflag("--cfg=parallel_compiler");
cargo.rustdocflag("--cfg=parallel_compiler");
}
if builder.config.rust_verify_llvm_ir {
cargo.env("RUSTC_VERIFY_LLVM_IR", "1");
}

View File

@ -469,7 +469,7 @@ fn run(self, builder: &Builder<'_>) -> PathBuf {
features.push("jemalloc".to_string());
}
let mut cargo = prepare_tool_cargo(
let cargo = prepare_tool_cargo(
builder,
build_compiler,
Mode::ToolRustc,
@ -480,10 +480,6 @@ fn run(self, builder: &Builder<'_>) -> PathBuf {
features.as_slice(),
);
if builder.config.rustc_parallel {
cargo.rustflag("--cfg=parallel_compiler");
}
let _guard = builder.msg_tool(
Mode::ToolRustc,
"rustdoc",
@ -732,7 +728,7 @@ fn run(self, builder: &Builder<'_>) -> PathBuf {
builder.ensure(compile::Std::new(self.compiler, self.compiler.host));
builder.ensure(compile::Rustc::new(self.compiler, self.target));
let mut cargo = prepare_tool_cargo(
let cargo = prepare_tool_cargo(
builder,
self.compiler,
Mode::ToolRustc,
@ -743,10 +739,6 @@ fn run(self, builder: &Builder<'_>) -> PathBuf {
&self.extra_features,
);
if builder.config.rustc_parallel {
cargo.rustflag("--cfg=parallel_compiler");
}
builder.run(&mut cargo.into());
let tool_out = builder

View File

@ -2100,6 +2100,15 @@ fn cargo(
rustflags.arg("-Zinline-mir");
}
if builder.config.rustc_parallel
&& matches!(mode, Mode::ToolRustc | Mode::Rustc | Mode::Codegen)
{
// keep in sync with `bootstrap/lib.rs:Build::rustc_features`
// `cfg` option for rustc, `features` option for cargo, for conditional compilation
rustflags.arg("--cfg=parallel_compiler");
rustdocflags.arg("--cfg=parallel_compiler");
}
// set rustc args passed from command line
let rustc_args =
self.config.cmd.rustc_args().iter().map(|s| s.to_string()).collect::<Vec<_>>();