Skip to content

stage1 compiler has some debuginfo with misleading library paths #142050

Open
@cuviper

Description

@cuviper

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-contributor-roadblockArea: Makes things more difficult for new or seasoned contributors to RustA-dist-componentsArea: dist components, e.g. `rustc-dev`, `rustc-src`, etc.A-path-remappingArea: path remapping, --remap-path-prefix, --remap-cwd-prefix, --remap-diagnostics-scope etc.C-bugCategory: This is a bug.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions