Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion compiler-builtins/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,22 @@ mod c {
// Support deterministic builds by remapping the __FILE__ prefix if the
// compiler supports it. This fixes the nondeterminism caused by the
// use of that macro in lib/builtins/int_util.h in compiler-rt.
build.flag_if_supported(&format!("-ffile-prefix-map={}=.", root.display()));

// `RUSTC_DEBUGINFO_MAP` is a bootstrap-specific env var (not a general
// Cargo/rustc mechanism) containing the `--remap-path-prefix` mappings
// bootstrap passes to rustc via its rustc shim. Bootstrap uses this
// instead of RUSTFLAGS because Cargo doesn't always forward RUSTFLAGS to
// build scripts and proc-macros (rust-lang/cargo#4423).
//
// Apply each mapping via -ffile-prefix-map, mirroring rustc_llvm's
// build.rs for the same env var.
if let Some(maps) = env::var_os("RUSTC_DEBUGINFO_MAP")

@Mark-Simulacrum Mark-Simulacrum Jul 19, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a fan of this living outside of rust-lang/rust. That usually leads to confusion and pain when we want to change the interface.

Can you say more about what information is missing in Cargo to allow reproducible artifacts from compiler-builtins? If root.display() above is not enough, what would be enough?

Somewhat relatedly, if rust-lang/rust's bootstrap feels this should be threaded down, why can't it use CFLAGS / CXXFLAGS to do so, rather than a custom env variable?

View changes since the review

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

root.display() only covers the compiler-rt source root, it doesn't cover this crate's own directory (CARGO_MANIFEST_DIR), which is what DW_AT_comp_dir was leaking.

on CFLAGS/CXXFLAGS, i don't know why bootstrap uses a custom env var instead of that. i'll check with @Urgau , who was explaining the RUSTFLAGS-forwarding issue (rust-lang/cargo#4423) that led to RUSTC_DEBUGINFO_MAP existing in the first place. not sure if the same limitation applies to CFLAGS/CXXFLAGS.

happy to move this into rust-lang/rust directly if that's preferred. wasn't sure which repo was the right home for it given compiler-builtins is developed separately.

&& let Some(maps_str) = maps.to_str()
{
for map in maps_str.split('\t') {
build.flag_if_supported(&format!("-ffile-prefix-map={map}"));
}
}

// Include out-of-line atomics for aarch64, which are all generated by supplying different
// sets of flags to the same source file.
Expand Down
Loading