From d6e2eb5d1fab5d912a2c97410d9ac66b1502c69a Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Fri, 28 Nov 2025 15:19:37 -0500 Subject: [PATCH] Reduce optimization level Mostly trying to see what the delta in build time vs. runtime performance is on our perf suite, I think it's unlikely we'd want to land this. --- Cargo.toml | 3 +++ src/bootstrap/src/core/builder/cargo.rs | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 67c7a9d67edc8..1d19e3f8185b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,6 +59,9 @@ exclude = [ "obj", ] +[profile.release] +opt-level = 1 + [profile.release.package.rustc_thread_pool] # The rustc fork of Rayon has deadlock detection code which intermittently # causes overflows in the CI (see https://github.com/rust-lang/rust/issues/90227) diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index 093a754f1a4b7..f5e7d47c8d094 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -1387,6 +1387,10 @@ impl Builder<'_> { rustflags.arg("-Zmir_strip_debuginfo=locals-in-tiny-functions"); } + if !matches!(mode, Mode::Std) { + cargo.env(cargo_profile_var("OPT_LEVEL", &self.config), "1"); + } + // take target-specific extra rustflags if any otherwise take `rust.rustflags` let extra_rustflags = self .config