From b8b260f2b004d9501c6efc6bdfcae5136e9e80b1 Mon Sep 17 00:00:00 2001 From: Deepesh Varatharajan Date: Wed, 4 Mar 2026 07:09:59 -0800 Subject: [PATCH] Respect RUSTC_LINK_STD_INTO_RUSTC_DRIVER=0 in link_std_into_rustc_driver Allow users to opt out of statically linking std into rustc_driver by setting RUSTC_LINK_STD_INTO_RUSTC_DRIVER=0. If unset or set to any other value, the function falls back to the default, linking std into rustc_driver on all platforms except Windows. Signed-off-by: Deepesh Varatharajan --- src/bootstrap/src/core/builder/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs index ae91b20406295..5e3e369cf9b63 100644 --- a/src/bootstrap/src/core/builder/mod.rs +++ b/src/bootstrap/src/core/builder/mod.rs @@ -1125,6 +1125,12 @@ impl<'a> Builder<'a> { /// Returns if `std` should be statically linked into `rustc_driver`. /// It's currently not done on `windows-gnu` due to linker bugs. pub fn link_std_into_rustc_driver(&self, target: TargetSelection) -> bool { + // Respect explicit environment variable override + if let Ok(val) = std::env::var("RUSTC_LINK_STD_INTO_RUSTC_DRIVER") + && val == "0" + { + return false; + } !target.triple.ends_with("-windows-gnu") }