stage1 compiler has some debuginfo with misleading library paths
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with stage1/bin/rustc under gdb, stepping from compiler/rustc_driver_impl/src/lib.rs into library/std/src/time.rs. Compare those relative paths with the /rust/... path shown for compiler/rustc_data_structures/src/profiling.rs, then trace the stage1 build's debuginfo path handling. Done means stage0 standard-library locations no longer resolve to mismatched local library files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100