From 33c4c8c67209aadecebe8bda908a44b74b9636b6 Mon Sep 17 00:00:00 2001 From: Sosuke Suzuki Date: Fri, 15 May 2026 14:24:06 +0900 Subject: [PATCH] build: enable parallel rustc frontend via -Zthreads=8 Cargo parallelizes across crates and rustc already parallelizes codegen across codegen-units, but each crate's frontend (parse, macro expansion, name resolution, type/borrow check, MIR) runs single-threaded by default. The workspace crate graph is a funnel: ~110 crates collapse into a few large leaf crates (bun_runtime, bun_css, bun_bundler) that cannot start until their transitive deps finish. The tail of every cargo build is one large crate's frontend pinned to a single core while the rest sit idle. -Zthreads=8 parallelizes that frontend. Nightly-only, but the toolchain is already pinned to nightly and the build already passes -Zbuild-std, -Zsanitizer, and -Zlocation-detail. --- scripts/build/rust.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/build/rust.ts b/scripts/build/rust.ts index e02b5922130e..2de9d7f5739f 100644 --- a/scripts/build/rust.ts +++ b/scripts/build/rust.ts @@ -412,6 +412,8 @@ export function emitRust(n: Ninja, cfg: Config, inputs: RustBuildInputs): string : // armv8-a+crc isn't a CPU name — closest LLVM model with CRC baseline: "cortex-a72"; rustflags.push(`-Ctarget-cpu=${cpuTarget}`); + // Parallelize the otherwise single-threaded rustc frontend (nightly-only). + rustflags.push("-Zthreads=8"); // `bun_core::build_options::ENABLE_ASAN = cfg!(bun_asan)` — must agree with // the C++ `ASAN_ENABLED` macro so Global::exit() picks the same libc exit // path (`exit` vs `quick_exit`) that c-bindings.cpp registered Bun__onExit on.