Skip to content
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

"./x.py run miri --stage 1" no longer works #126233

Closed
RalfJung opened this issue Jun 10, 2024 · 5 comments · Fixed by #126238
Closed

"./x.py run miri --stage 1" no longer works #126233

RalfJung opened this issue Jun 10, 2024 · 5 comments · Fixed by #126238
Labels
A-contributor-roadblock Area: Makes things more difficult for new contributors to rust itself C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@RalfJung
Copy link
Member

This used to work fine at some point, but now leads to some strange errors:

$ ./x.py run miri --stage 1 -- src/tools/miri/tests/pass/hello.rs
Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.02s
Building stage0 library artifacts (x86_64-unknown-linux-gnu)
    Finished `release` profile [optimized + debuginfo] target(s) in 0.07s
Building compiler artifacts (stage0 -> stage1, x86_64-unknown-linux-gnu)
    Finished `release` profile [optimized + debuginfo] target(s) in 0.11s
Creating a sysroot for stage1 compiler (use `rustup toolchain link 'name' build/host/stage1`)
Building stage0 tool lld-wrapper (x86_64-unknown-linux-gnu)
    Finished `release` profile [optimized + debuginfo] target(s) in 0.06s
Building tool miri (stage0 -> stage1, x86_64-unknown-linux-gnu)
    Finished `release` profile [optimized + debuginfo] target(s) in 0.07s
Building tool cargo-miri (stage0 -> stage1, x86_64-unknown-linux-gnu)
    Finished `release` profile [optimized + debuginfo] target(s) in 0.07s
Building stage1 miri sysroot (x86_64-unknown-linux-gnu)
A sysroot for Miri is already available in `/home/r/src/rust/rustc.3/build/x86_64-unknown-linux-gnu/miri-sysroot`.
    Finished `release` profile [optimized + debuginfo] target(s) in 0.07s
     Running `build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/miri --target x86_64-unknown-linux-gnu src/tools/miri/tests/pass/hello.rs`
error[E0786]: found invalid metadata files for crate `std`
  |
  = note: corrupt metadata encountered in /home/r/src/rust/rustc.3/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-e9d12b2c234bc463.rlib
  = note: corrupt metadata encountered in /home/r/src/rust/rustc.3/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-e9d12b2c234bc463.so
  = note: corrupt metadata encountered in /home/r/src/rust/rustc.3/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-ec2a734cf29b8414.rlib

error: cannot find macro `eprintln` in this scope
 --> src/tools/miri/tests/pass/hello.rs:3:5
  |
3 |     eprintln!("Hello, error!");
  |     ^^^^^^^^

error: cannot find macro `println` in this scope
 --> src/tools/miri/tests/pass/hello.rs:2:5
  |
2 |     println!("Hello, world!");
  |     ^^^^^^^

error: requires `sized` lang_item

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0786`.
Build completed unsuccessfully in 0:00:01
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 10, 2024
@Noratrieb
Copy link
Member

somehow Miri searches for its sysroot in stage0-sysroot instead of its own built sysroot?

@Noratrieb Noratrieb added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) C-bug Category: This is a bug. A-contributor-roadblock Area: Makes things more difficult for new contributors to rust itself and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jun 10, 2024
@Noratrieb
Copy link
Member

When executing Miri:

[src/tools/miri/src/bin/miri.rs:359:5] std::env::var("MIRI_SYSROOT") = Ok(
    "/home/nora/projects/rust/build/x86_64-unknown-linux-gnu/miri-sysroot",
)
[src/tools/miri/src/bin/miri.rs:360:5] std::env::args().collect::<Vec<_>>() = [
    "build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/miri",
    "--target",
    "x86_64-unknown-linux-gnu",
    "uwu2.rs",
]

I thought the sysroot was passed to the process with --sysroot, but I cannot find such an argument... how exactly does it find stage0-sysroot from this... I don't really understand how that works. But this may help.

@Noratrieb
Copy link
Member

I see, it gets the sysroot because librustc_driver.so is in stage0-sysroot. Slightly strange, that sysroot is not really one it can use. Why is it linked from there? But either way, the sysroot we want to use for Miri here is an entirely different one that needs to be override manually. How did that work previously?

@Noratrieb
Copy link
Member

oh lol, this was almost certainly broken by rust-lang/miri#3411, in which you even specifically mentioned x.py run, looks like you forgot about it :D

@RalfJung
Copy link
Member Author

RalfJung commented Jun 10, 2024 via email

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jun 13, 2024
Fix Miri sysroot for `x run`

Miri no longer (after rust-lang/miri#3411) respects `MIRI_SYSROOT` and wants to be treated like a REAL rustc, with `--sysroot`. \*pats Miri\* sure Miri, just for you :3.

fixes rust-lang#126233

r? RalfJung (or whoever else feels like it)
@bors bors closed this as completed in 24c94f0 Jun 14, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jun 14, 2024
Rollup merge of rust-lang#126238 - Nilstrieb:run,miri,run, r=RalfJung

Fix Miri sysroot for `x run`

Miri no longer (after rust-lang/miri#3411) respects `MIRI_SYSROOT` and wants to be treated like a REAL rustc, with `--sysroot`. \*pats Miri\* sure Miri, just for you :3.

fixes rust-lang#126233

r? RalfJung (or whoever else feels like it)
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 contributors to rust itself 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

Successfully merging a pull request may close this issue.

3 participants