Skip to content

stage1 compiler has some debuginfo with misleading library paths #142050

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
cuviper opened this issue Jun 5, 2025 · 2 comments
Open

stage1 compiler has some debuginfo with misleading library paths #142050

cuviper opened this issue Jun 5, 2025 · 2 comments
Labels
A-contributor-roadblock Area: Makes things more difficult for new or seasoned contributors to Rust A-dist-components Area: dist components, e.g. `rustc-dev`, `rustc-src`, etc. A-path-remapping Area: path remapping, --remap-path-prefix, --remap-cwd-prefix, --remap-diagnostics-scope etc. C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@cuviper
Copy link
Member

cuviper commented Jun 5, 2025

I tried debugging stage1/bin/rustc, and when stepping into parts of the standard library, I noticed that gdb was showing file contents from the local library/ path, even though the stage1 compiler is now built with stage0's standard library.

While a lot of the library paths are /rust/{hash}/... prefixed, some are still relative, and the debugger dutifully opens the local file that doesn't actually match.

$ gdb --args ./build/host/stage1/bin/rustc -Vv
...
rustc_driver_impl::main () at compiler/rustc_driver_impl/src/lib.rs:1527
1527        let start_time = Instant::now();
(gdb) s
std::time::Instant::now () at library/std/src/time.rs:289
289             Instant(time::Instant::now())

In this brief example, it doesn't really matter because time.rs hasn't changed, but in deeper debugging sessions I saw completely bogus lines, like in the middle of a large comment block. I can make a local edit on this file and gdb will still show that next time:

(gdb) s
std::time::Instant::now () at library/std/src/time.rs:289
289             // what are you looking at?

When the stage0 library path is properly remapped, it looks more like this:

rustc_data_structures::profiling::get_resident_set_size () at compiler/rustc_data_structures/src/profiling.rs:919
919                 let contents = fs::read("/proc/self/statm").ok()?;
(gdb) s
std::fs::read<&str> (path=...) at /rustc/95597e848d27a82b8864c677ab807e9f0be1f68c/library/std/src/fs.rs:293
warning: 293    /rustc/95597e848d27a82b8864c677ab807e9f0be1f68c/library/std/src/fs.rs: No such file or directory

(We could potentially find that file with rust-src and rust-gdb matching the stage0 compiler.)

Meta

Tried on master as of commit 61413aea937d9663d01b62902535f8d4ec85cc95.

@cuviper cuviper added the C-bug Category: This is a bug. label Jun 5, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 5, 2025
@jyn514
Copy link
Member

jyn514 commented Jun 5, 2025

I'm going to provisionally mark this as a bootstrap bug until someone investigates and shows otherwise. The most likely cause IMO is that we are passing --remap-path-prefix inconsistently when building dist artifacts.

@rustbot label T-bootstrap A-path-remapping A-contributor-roadblock A-dist-components

@rustbot rustbot added A-contributor-roadblock Area: Makes things more difficult for new or seasoned contributors to Rust A-dist-components Area: dist components, e.g. `rustc-dev`, `rustc-src`, etc. A-path-remapping Area: path remapping, --remap-path-prefix, --remap-cwd-prefix, --remap-diagnostics-scope etc. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jun 5, 2025
@jyn514
Copy link
Member

jyn514 commented Jun 5, 2025

(note that failing to remap is a pre-existing bug, but it got substantially worse after the stage0 redesign because we are now using the beta standard library instead of the in-tree standard library, and the spans may not match.)

@onur-ozkan onur-ozkan removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-contributor-roadblock Area: Makes things more difficult for new or seasoned contributors to Rust A-dist-components Area: dist components, e.g. `rustc-dev`, `rustc-src`, etc. A-path-remapping Area: path remapping, --remap-path-prefix, --remap-cwd-prefix, --remap-diagnostics-scope etc. C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

No branches or pull requests

4 participants