Skip to content

Commit

Permalink
move parallel_compiler handling into prepare_tool_cargo so that it is…
Browse files Browse the repository at this point in the history
… done everywhere
  • Loading branch information
RalfJung committed Mar 30, 2024
1 parent c0477d5 commit 1dd0f30
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
6 changes: 0 additions & 6 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
12 changes: 2 additions & 10 deletions src/bootstrap/src/core/build_steps/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ impl Step for Rustdoc {
features.push("jemalloc".to_string());
}

let mut cargo = prepare_tool_cargo(
let cargo = prepare_tool_cargo(
builder,
build_compiler,
Mode::ToolRustc,
Expand All @@ -480,10 +480,6 @@ impl Step for Rustdoc {
features.as_slice(),
);

if builder.config.rustc_parallel {
cargo.rustflag("--cfg=parallel_compiler");
}

let _guard = builder.msg_tool(
Mode::ToolRustc,
"rustdoc",
Expand Down Expand Up @@ -732,7 +728,7 @@ impl Step for LlvmBitcodeLinker {
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,
Expand All @@ -743,10 +739,6 @@ impl Step for LlvmBitcodeLinker {
&self.extra_features,
);

if builder.config.rustc_parallel {
cargo.rustflag("--cfg=parallel_compiler");
}

builder.run(&mut cargo.into());

let tool_out = builder
Expand Down
7 changes: 7 additions & 0 deletions src/bootstrap/src/core/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2098,6 +2098,13 @@ impl<'a> Builder<'a> {
rustflags.arg("-Zinline-mir");
}

if 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<_>>();
Expand Down

0 comments on commit 1dd0f30

Please sign in to comment.