Skip to content

Commit 7c4944d

Browse files
committed
bootstrap: respect POSIX jobserver
When bootstrapping rust, the `-j N` flag was passed to `cmake`, which was then forwarded to Ninja. This prevents the jobserver from being used, and as a result leads to oversubscription when rust is just one of the many packages built as part of a larger software stack. Since Cargo has long supported the jobserver, it would be good if also bootstrapping rust itself would participate in the protocol, leading to composable parallelism. Signed-off-by: Harmen Stoppels <me@harmenstoppels.nl>
1 parent 79a1e77 commit 7c4944d

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/bootstrap/src/core/build_steps/llvm.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,12 @@ fn configure_cmake(
773773
.define("CMAKE_CXX_COMPILER", sanitize_cc(&cxx))
774774
.define("CMAKE_ASM_COMPILER", sanitize_cc(&cc));
775775

776-
cfg.build_arg("-j").build_arg(builder.jobs().to_string());
776+
let has_jobserver =
777+
env::var("MAKEFLAGS").map(|flags| flags.contains("--jobserver-auth=")).unwrap_or(false);
778+
779+
if !has_jobserver {
780+
cfg.build_arg("-j").build_arg(builder.jobs().to_string());
781+
}
777782
let mut cflags = ccflags.cflags.clone();
778783
// FIXME(madsmtm): Allow `cmake-rs` to select flags by itself by passing
779784
// our flags via `.cflag`/`.cxxflag` instead.

src/bootstrap/src/core/builder/cargo.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -547,10 +547,6 @@ impl Builder<'_> {
547547
assert_eq!(target, compiler.host);
548548
}
549549

550-
// Remove make-related flags to ensure Cargo can correctly set things up
551-
cargo.env_remove("MAKEFLAGS");
552-
cargo.env_remove("MFLAGS");
553-
554550
cargo
555551
}
556552

0 commit comments

Comments
 (0)