Skip to content

compiler-builtins: remap RUSTC_DEBUGINFO_MAP paths via -ffile-prefix-map#1236

Closed
paradoxicalguy wants to merge 1 commit into
rust-lang:mainfrom
paradoxicalguy:fix-comp-dir-remap
Closed

compiler-builtins: remap RUSTC_DEBUGINFO_MAP paths via -ffile-prefix-map#1236
paradoxicalguy wants to merge 1 commit into
rust-lang:mainfrom
paradoxicalguy:fix-comp-dir-remap

Conversation

@paradoxicalguy

Copy link
Copy Markdown

libcompiler_builtins.rlib leaks the local build path into DW_AT_comp_dir for C-compiled units (compiler-rt), even with rust-lang/rust's rust.remap-debuginfo = true.
existing -ffile-prefix-map={root}=. only covers the compiler-rt source root, not comp_dir.

fix: iterate RUSTC_DEBUGINFO_MAP and apply each mapping via -ffile-prefix-map, mirroring rustc_llvm's build.rs.

before: DW_AT_comp_dir ("/rustc/08f62523b1c3262cc2f0288a3369b760ab4bda45/library/compiler-builtins/compiler-builtins")
after: DW_AT_comp_dir ("/rustc/08f62523b1c3262cc2f0288a3369b760ab4bda45")

see discussion

r? @Urgau
cc @tgross35

@rustbot

rustbot commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Failed to set assignee to Urgau: invalid assignee

Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.

@rustbot

rustbot commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @Urgau (or someone else) some time within the next two weeks.

//
// 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.

@tgross35

Copy link
Copy Markdown
Contributor

Sounds like this may be something to update elsewhere, rust-lang/rust#156570 (comment)

@paradoxicalguy

Copy link
Copy Markdown
Author

closing this
fixed via bootstrap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants