Skip to content

bootstrap: forward -fdebug-prefix-map when using cc#159673

Open
paradoxicalguy wants to merge 1 commit into
rust-lang:mainfrom
paradoxicalguy:fix-cc-debuginfo-map-detection
Open

bootstrap: forward -fdebug-prefix-map when using cc#159673
paradoxicalguy wants to merge 1 commit into
rust-lang:mainfrom
paradoxicalguy:fix-cc-debuginfo-map-detection

Conversation

@paradoxicalguy

Copy link
Copy Markdown
Contributor

the existing clang/gcc checks don't match on systems where self.cc(target) resolves to cc, so -fdebug-prefix-map isn't forwarded to the C compiler.

this leaves local checkout paths in compiler-builtins DWARF.
recognize cc as well so the remapping flag is forwarded. confirmed remap-path-prefix-std passes, and inspecting the generated DWARF to verify that checkout paths are remapped.

r? @Urgau
cc @bjorn3

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jul 21, 2026
Comment thread src/bootstrap/src/lib.rs Outdated
if cc.ends_with("clang") || cc.ends_with("gcc") {
if cc.ends_with("clang")
|| cc.ends_with("gcc")
|| cc.file_name().is_some_and(|f| f == "cc")

@Urgau Urgau Jul 21, 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.

On my system, cc is just a symlink to gcc. Could we maybe resolve the symlink and check for clang/gcc?

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i instrumented it, and self.cc(target) is just cc rather than an absolute path (/usr/bin/cc.). so fs::canonicalize won't resolve it directly since it doesn't search PATH. do you have a preferred way to resolve the compiler first,
or is there already a helper in bootstrap that does this?

my shell:

which cc
# /usr/bin/cc

readlink -f "$(which cc)"
# /usr/bin/x86_64-linux-gnu-gcc-13

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.

Hum, that's annoying. Not sure what to do.

@Urgau

Urgau commented Jul 21, 2026

Copy link
Copy Markdown
Member

I'm not sure I'm the best reviewer for this bootstrap change.

r? bootstrap

@rustbot rustbot assigned Mark-Simulacrum and unassigned Urgau Jul 21, 2026
Comment thread src/bootstrap/src/lib.rs Outdated
let map = format!("{}={}", self.src.display(), map_to);
let cc = self.cc(target);
if cc.ends_with("clang") || cc.ends_with("gcc") {
if cc.ends_with("clang")

@Kobzol Kobzol Jul 24, 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.

This check is wrong anyway, you can have e.g. clang-18 or something. What about calling cc_tool instead and checking is_like_clang and is_like_gnu?

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

if let Some(map_to) = self.debuginfo_map_to(which, RemapScheme::NonCompiler) {
            let map = format!("{}={}", self.src.display(), map_to);
            let cc = self.cc_tool(target);
            if cc.is_like_clang() || cc.is_like_gnu() {
                base.push(format!("-fdebug-prefix-map={map}"));
            } else if cc.is_like_clang_cl() {
                base.push("-Xclang".into());
                base.push(format!("-fdebug-prefix-map={map}"));
            }
        }
        base   

passes locally in stage 2 also :)

@paradoxicalguy
paradoxicalguy force-pushed the fix-cc-debuginfo-map-detection branch from 7c90cef to 99ff7d2 Compare July 25, 2026 09:43
@Kobzol

Kobzol commented Jul 25, 2026

Copy link
Copy Markdown
Member

Even regardless of reproducibility, this is a good cleanup, thanks!

@bors r+

@rust-bors

rust-bors Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 99ff7d2 has been approved by Kobzol

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 25, 2026
@paradoxicalguy

Copy link
Copy Markdown
Contributor Author

yay :D

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 25, 2026
…, r=Kobzol

bootstrap: forward -fdebug-prefix-map when using cc



the existing `clang/gcc` checks don't match on systems where `self.cc(target)` resolves to `cc`, so `-fdebug-prefix-map` isn't forwarded to the `C` compiler.

this leaves local checkout paths in `compiler-builtins DWARF`.
recognize cc as well so the remapping flag is forwarded. confirmed `remap-path-prefix-std passes`, and inspecting the generated `DWARF` to verify that checkout paths are remapped.

r? @Urgau 
cc @bjorn3
@rust-bors rust-bors Bot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 25, 2026
@rust-bors

rust-bors Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

💔 Test for ef4e0b3 failed: CI

@Kobzol

Kobzol commented Jul 25, 2026

Copy link
Copy Markdown
Member

@bors retry Actions outage

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 25, 2026
@rust-bors

rust-bors Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

⌛ Testing commit 99ff7d2 with merge b9f688a...

Workflow: https://github.com/rust-lang/rust/actions/runs/30161634838

rust-bors Bot pushed a commit that referenced this pull request Jul 25, 2026
…, r=Kobzol

bootstrap: forward -fdebug-prefix-map when using cc



the existing `clang/gcc` checks don't match on systems where `self.cc(target)` resolves to `cc`, so `-fdebug-prefix-map` isn't forwarded to the `C` compiler.

this leaves local checkout paths in `compiler-builtins DWARF`.
recognize cc as well so the remapping flag is forwarded. confirmed `remap-path-prefix-std passes`, and inspecting the generated `DWARF` to verify that checkout paths are remapped.

r? @Urgau 
cc @bjorn3
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jul 25, 2026
…p-detection, r=Kobzol

bootstrap: forward -fdebug-prefix-map when using cc

the existing `clang/gcc` checks don't match on systems where `self.cc(target)` resolves to `cc`, so `-fdebug-prefix-map` isn't forwarded to the `C` compiler.

this leaves local checkout paths in `compiler-builtins DWARF`.
recognize cc as well so the remapping flag is forwarded. confirmed `remap-path-prefix-std passes`, and inspecting the generated `DWARF` to verify that checkout paths are remapped.

r? @Urgau
cc @bjorn3
@GuillaumeGomez

Copy link
Copy Markdown
Member

Part of #159905.

@bors yield

@rust-bors

rust-bors Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Auto build was cancelled. Cancelled workflows:

The next pull request likely to be tested is #159905.

rust-bors Bot pushed a commit that referenced this pull request Jul 25, 2026
Rollup of 23 pull requests

Successful merges:

 - #159673 (bootstrap: forward -fdebug-prefix-map when using cc)
 - #159720 (document #[global_allocator] constraints)
 - #159732 (optimization: don't look for diagnostic/canonical items without rustc_attrs enabled)
 - #159738 (implement `CovariantUnsafeCell`)
 - #159740 (reuse regular exported_non_generic_symbols logic in Miri)
 - #159780 (check `extern "custom"` function pointers)
 - #159786 (rustdoc-js: ignore editor temp files in test folder discovery)
 - #159819 (std::sync::poison: disable auto_cfg on PoisonError::new)
 - #155388 (stepping into where-clauses during normalization may be productive)
 - #155914 (when bailing on ambiguity, don't force other results to ambig)
 - #159204 (Add support to caller_location to rustc_public)
 - #159411 ([rustdoc] Correctly handle output options with --show-coverage)
 - #159439 (Fix(lib/fs/win): Fall back on Win32 delete for `Dir::remove_file`)
 - #159676 (Update wasm-component-ld to 0.5.27)
 - #159730 (allow accessing the contents of UnsafeCell without going through get)
 - #159809 (Avoid `#[target_features]`)
 - #159810 (Add tuple never coercion collection regression test)
 - #159826 (Remove redundant `#[rustc_paren_sugar]` feature gate)
 - #159853 (Updated expect messages for `CString` struct and method documentation)
 - #159878 (bootstrap: Remove obsolete option `build.compiletest-use-stage0-libtest`)
 - #159882 (Update expect messages in library/alloc/boxed.rs and library/alloc/string.rs to follow the style guide)
 - #159891 (Split multiline derives into std/rustc macros)
 - #159895 (rustc-dev-guide subtree update)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 25, 2026
…p-detection, r=Kobzol

bootstrap: forward -fdebug-prefix-map when using cc

the existing `clang/gcc` checks don't match on systems where `self.cc(target)` resolves to `cc`, so `-fdebug-prefix-map` isn't forwarded to the `C` compiler.

this leaves local checkout paths in `compiler-builtins DWARF`.
recognize cc as well so the remapping flag is forwarded. confirmed `remap-path-prefix-std passes`, and inspecting the generated `DWARF` to verify that checkout paths are remapped.

r? @Urgau
cc @bjorn3
rust-bors Bot pushed a commit that referenced this pull request Jul 25, 2026
…uwer

Rollup of 25 pull requests

Successful merges:

 - #138618 (Support using const pointers in asm `const` operand)
 - #157962 (Lower paths to functions in const args as ConstKind::Error)
 - #158404 (trait_solver: normalize next-gen region constraints)
 - #158709 (rustdoc: warn on improperly interleaved HTML/MD)
 - #159174 (Fix implicit_provenance_casts warnings on Xous)
 - #159179 (enable `unreachable_cfg_select_predicates` lint as part of `unused` lint group)
 - #159518 (iter: extend step_by specialization to cover StepBy<RangeIter<{integer}>>)
 - #159673 (bootstrap: forward -fdebug-prefix-map when using cc)
 - #159700 (Split non-local `semicolon_in_expressions_from_macros` into a separate lint)
 - #159720 (document #[global_allocator] constraints)
 - #159732 (optimization: don't look for diagnostic/canonical items without rustc_attrs enabled)
 - #159738 (implement `CovariantUnsafeCell`)
 - #159740 (reuse regular exported_non_generic_symbols logic in Miri)
 - #159780 (check `extern "custom"` function pointers)
 - #159785 (Share _Unwind_Exception definition between native and wasm)
 - #159786 (rustdoc-js: ignore editor temp files in test folder discovery)
 - #159819 (std::sync::poison: disable auto_cfg on PoisonError::new)
 - #155388 (stepping into where-clauses during normalization may be productive)
 - #155914 (when bailing on ambiguity, don't force other results to ambig)
 - #159204 (Add support to caller_location to rustc_public)
 - #159439 (Fix(lib/fs/win): Fall back on Win32 delete for `Dir::remove_file`)
 - #159676 (Update wasm-component-ld to 0.5.27)
 - #159695 (proc_macro: Fix cfg_attr inner attrs in file modules)
 - #159730 (allow accessing the contents of UnsafeCell without going through get)
 - #159809 (Avoid `#[target_features]`)
rust-bors Bot pushed a commit that referenced this pull request Jul 25, 2026
…uwer

Rollup of 25 pull requests

Successful merges:

 - #138618 (Support using const pointers in asm `const` operand)
 - #157962 (Lower paths to functions in const args as ConstKind::Error)
 - #158404 (trait_solver: normalize next-gen region constraints)
 - #158709 (rustdoc: warn on improperly interleaved HTML/MD)
 - #159174 (Fix implicit_provenance_casts warnings on Xous)
 - #159179 (enable `unreachable_cfg_select_predicates` lint as part of `unused` lint group)
 - #159518 (iter: extend step_by specialization to cover StepBy<RangeIter<{integer}>>)
 - #159673 (bootstrap: forward -fdebug-prefix-map when using cc)
 - #159700 (Split non-local `semicolon_in_expressions_from_macros` into a separate lint)
 - #159720 (document #[global_allocator] constraints)
 - #159732 (optimization: don't look for diagnostic/canonical items without rustc_attrs enabled)
 - #159738 (implement `CovariantUnsafeCell`)
 - #159740 (reuse regular exported_non_generic_symbols logic in Miri)
 - #159780 (check `extern "custom"` function pointers)
 - #159785 (Share _Unwind_Exception definition between native and wasm)
 - #159786 (rustdoc-js: ignore editor temp files in test folder discovery)
 - #159819 (std::sync::poison: disable auto_cfg on PoisonError::new)
 - #155388 (stepping into where-clauses during normalization may be productive)
 - #155914 (when bailing on ambiguity, don't force other results to ambig)
 - #159204 (Add support to caller_location to rustc_public)
 - #159439 (Fix(lib/fs/win): Fall back on Win32 delete for `Dir::remove_file`)
 - #159676 (Update wasm-component-ld to 0.5.27)
 - #159695 (proc_macro: Fix cfg_attr inner attrs in file modules)
 - #159730 (allow accessing the contents of UnsafeCell without going through get)
 - #159809 (Avoid `#[target_features]`)
rust-bors Bot pushed a commit that referenced this pull request Jul 25, 2026
…uwer

Rollup of 25 pull requests

Successful merges:

 - #138618 (Support using const pointers in asm `const` operand)
 - #157962 (Lower paths to functions in const args as ConstKind::Error)
 - #158404 (trait_solver: normalize next-gen region constraints)
 - #158709 (rustdoc: warn on improperly interleaved HTML/MD)
 - #159174 (Fix implicit_provenance_casts warnings on Xous)
 - #159179 (enable `unreachable_cfg_select_predicates` lint as part of `unused` lint group)
 - #159518 (iter: extend step_by specialization to cover StepBy<RangeIter<{integer}>>)
 - #159673 (bootstrap: forward -fdebug-prefix-map when using cc)
 - #159700 (Split non-local `semicolon_in_expressions_from_macros` into a separate lint)
 - #159720 (document #[global_allocator] constraints)
 - #159732 (optimization: don't look for diagnostic/canonical items without rustc_attrs enabled)
 - #159738 (implement `CovariantUnsafeCell`)
 - #159740 (reuse regular exported_non_generic_symbols logic in Miri)
 - #159780 (check `extern "custom"` function pointers)
 - #159785 (Share _Unwind_Exception definition between native and wasm)
 - #159786 (rustdoc-js: ignore editor temp files in test folder discovery)
 - #159819 (std::sync::poison: disable auto_cfg on PoisonError::new)
 - #155388 (stepping into where-clauses during normalization may be productive)
 - #155914 (when bailing on ambiguity, don't force other results to ambig)
 - #159204 (Add support to caller_location to rustc_public)
 - #159439 (Fix(lib/fs/win): Fall back on Win32 delete for `Dir::remove_file`)
 - #159676 (Update wasm-component-ld to 0.5.27)
 - #159695 (proc_macro: Fix cfg_attr inner attrs in file modules)
 - #159730 (allow accessing the contents of UnsafeCell without going through get)
 - #159809 (Avoid `#[target_features]`)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 25, 2026
…p-detection, r=Kobzol

bootstrap: forward -fdebug-prefix-map when using cc

the existing `clang/gcc` checks don't match on systems where `self.cc(target)` resolves to `cc`, so `-fdebug-prefix-map` isn't forwarded to the `C` compiler.

this leaves local checkout paths in `compiler-builtins DWARF`.
recognize cc as well so the remapping flag is forwarded. confirmed `remap-path-prefix-std passes`, and inspecting the generated `DWARF` to verify that checkout paths are remapped.

r? @Urgau
cc @bjorn3
rust-bors Bot pushed a commit that referenced this pull request Jul 25, 2026
…uwer

Rollup of 25 pull requests

Successful merges:

 - #159825 (codegen: handle OperandValue::Uninit in codegen_return_terminator)
 - #138618 (Support using const pointers in asm `const` operand)
 - #157962 (Lower paths to functions in const args as ConstKind::Error)
 - #158404 (trait_solver: normalize next-gen region constraints)
 - #158709 (rustdoc: warn on improperly interleaved HTML/MD)
 - #159174 (Fix implicit_provenance_casts warnings on Xous)
 - #159179 (enable `unreachable_cfg_select_predicates` lint as part of `unused` lint group)
 - #159518 (iter: extend step_by specialization to cover StepBy<RangeIter<{integer}>>)
 - #159673 (bootstrap: forward -fdebug-prefix-map when using cc)
 - #159700 (Split non-local `semicolon_in_expressions_from_macros` into a separate lint)
 - #159720 (document #[global_allocator] constraints)
 - #159732 (optimization: don't look for diagnostic/canonical items without rustc_attrs enabled)
 - #159738 (implement `CovariantUnsafeCell`)
 - #159740 (reuse regular exported_non_generic_symbols logic in Miri)
 - #159780 (check `extern "custom"` function pointers)
 - #159786 (rustdoc-js: ignore editor temp files in test folder discovery)
 - #159819 (std::sync::poison: disable auto_cfg on PoisonError::new)
 - #155388 (stepping into where-clauses during normalization may be productive)
 - #155914 (when bailing on ambiguity, don't force other results to ambig)
 - #159204 (Add support to caller_location to rustc_public)
 - #159439 (Fix(lib/fs/win): Fall back on Win32 delete for `Dir::remove_file`)
 - #159676 (Update wasm-component-ld to 0.5.27)
 - #159695 (proc_macro: Fix cfg_attr inner attrs in file modules)
 - #159730 (allow accessing the contents of UnsafeCell without going through get)
 - #159809 (Avoid `#[target_features]`)
rust-bors Bot pushed a commit that referenced this pull request Jul 25, 2026
…uwer

Rollup of 25 pull requests

Successful merges:

 - #159825 (codegen: handle OperandValue::Uninit in codegen_return_terminator)
 - #138618 (Support using const pointers in asm `const` operand)
 - #157962 (Lower paths to functions in const args as ConstKind::Error)
 - #158404 (trait_solver: normalize next-gen region constraints)
 - #158709 (rustdoc: warn on improperly interleaved HTML/MD)
 - #159174 (Fix implicit_provenance_casts warnings on Xous)
 - #159179 (enable `unreachable_cfg_select_predicates` lint as part of `unused` lint group)
 - #159518 (iter: extend step_by specialization to cover StepBy<RangeIter<{integer}>>)
 - #159673 (bootstrap: forward -fdebug-prefix-map when using cc)
 - #159700 (Split non-local `semicolon_in_expressions_from_macros` into a separate lint)
 - #159720 (document #[global_allocator] constraints)
 - #159732 (optimization: don't look for diagnostic/canonical items without rustc_attrs enabled)
 - #159738 (implement `CovariantUnsafeCell`)
 - #159740 (reuse regular exported_non_generic_symbols logic in Miri)
 - #159780 (check `extern "custom"` function pointers)
 - #159786 (rustdoc-js: ignore editor temp files in test folder discovery)
 - #159819 (std::sync::poison: disable auto_cfg on PoisonError::new)
 - #155388 (stepping into where-clauses during normalization may be productive)
 - #155914 (when bailing on ambiguity, don't force other results to ambig)
 - #159204 (Add support to caller_location to rustc_public)
 - #159439 (Fix(lib/fs/win): Fall back on Win32 delete for `Dir::remove_file`)
 - #159676 (Update wasm-component-ld to 0.5.27)
 - #159695 (proc_macro: Fix cfg_attr inner attrs in file modules)
 - #159730 (allow accessing the contents of UnsafeCell without going through get)
 - #159809 (Avoid `#[target_features]`)
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 26, 2026
…p-detection, r=Kobzol

bootstrap: forward -fdebug-prefix-map when using cc

the existing `clang/gcc` checks don't match on systems where `self.cc(target)` resolves to `cc`, so `-fdebug-prefix-map` isn't forwarded to the `C` compiler.

this leaves local checkout paths in `compiler-builtins DWARF`.
recognize cc as well so the remapping flag is forwarded. confirmed `remap-path-prefix-std passes`, and inspecting the generated `DWARF` to verify that checkout paths are remapped.

r? @Urgau
cc @bjorn3
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 26, 2026
…p-detection, r=Kobzol

bootstrap: forward -fdebug-prefix-map when using cc

the existing `clang/gcc` checks don't match on systems where `self.cc(target)` resolves to `cc`, so `-fdebug-prefix-map` isn't forwarded to the `C` compiler.

this leaves local checkout paths in `compiler-builtins DWARF`.
recognize cc as well so the remapping flag is forwarded. confirmed `remap-path-prefix-std passes`, and inspecting the generated `DWARF` to verify that checkout paths are remapped.

r? @Urgau
cc @bjorn3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants