From 6a1953465be958adbbda3b1923bbe52f34e8451b Mon Sep 17 00:00:00 2001 From: paradoxicalguy Date: Tue, 5 May 2026 11:03:59 +0000 Subject: [PATCH 1/2] fix: remap ci-llvm debug paths via `-fdebug-prefix-map` ci-llvm include paths were leaking into debuginfo of `librustc_driver` via C/C++ compilation in rustc_llvm, causing non-determinism across stage2 builds. extend debug path remapping to the C/C++ build in rustc_llvm by converting RUSTC_DEBUGINFO_MAP into corresponding -fdebug-prefix-map flags and passing them through cc::Build. --- compiler/rustc_llvm/build.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs index 38c16fb1cd6d5..2d248c6991a52 100644 --- a/compiler/rustc_llvm/build.rs +++ b/compiler/rustc_llvm/build.rs @@ -273,6 +273,15 @@ fn main() { cfg.flag(&*flag); } + // Remap ci-llvm include paths in debug info for reproducible builds. + if let Some(maps) = tracked_env_var_os("RUSTC_DEBUGINFO_MAP") + && let Some(maps_str) = maps.to_str() + { + for map in maps_str.split('\t') { + cfg.flag(&format!("-fdebug-prefix-map={map}")); + } + } + for component in &components { let mut flag = String::from("LLVM_COMPONENT_"); flag.push_str(&component.to_uppercase()); From fc6b9c862636794917d502d5f19c37dfe26a8847 Mon Sep 17 00:00:00 2001 From: abhinav srivastav <136164196+paradoxicalguy@users.noreply.github.com> Date: Tue, 5 May 2026 22:13:25 +0530 Subject: [PATCH 2/2] updating flag with `flag_if_supported` Co-authored-by: Urgau <3616612+Urgau@users.noreply.github.com> --- compiler/rustc_llvm/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs index 2d248c6991a52..ed1b75bea29d9 100644 --- a/compiler/rustc_llvm/build.rs +++ b/compiler/rustc_llvm/build.rs @@ -278,7 +278,7 @@ fn main() { && let Some(maps_str) = maps.to_str() { for map in maps_str.split('\t') { - cfg.flag(&format!("-fdebug-prefix-map={map}")); + cfg.flag_if_supported(&format!("-ffile-prefix-map={map}")); } }