Skip to content

stage1 compiler has some debuginfo with misleading library paths #142050

@cuviper

Description

@cuviper
Member

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.

Activity

added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Jun 5, 2025
jyn514

jyn514 commented on Jun 5, 2025

@jyn514
Member

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

added
A-contributor-roadblockArea: Makes things more difficult for new or seasoned contributors to Rust
A-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.
T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
on Jun 5, 2025
jyn514

jyn514 commented on Jun 5, 2025

@jyn514
Member

(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.)

removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

        Participants

        @cuviper@jyn514@onur-ozkan@rustbot

        Issue actions

          stage1 compiler has some debuginfo with misleading library paths · Issue #142050 · rust-lang/rust