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

cargo miri test fails without RUSTC env var #3775

Closed
Nemo157 opened this issue Jul 30, 2024 · 3 comments
Closed

cargo miri test fails without RUSTC env var #3775

Nemo157 opened this issue Jul 30, 2024 · 3 comments

Comments

@Nemo157
Copy link
Member

Nemo157 commented Jul 30, 2024

> cargo miri test
thread 'main' panicked at src/tools/miri/cargo-miri/src/setup.rs:103:13:
assertion failed: env::var_os("RUSTC").is_some()
stack backtrace:
   0: rust_begin_unwind
             at /rustc/7c2012d0ec3aae89fefc40e5d6b317a0949cda36/library/std/src/panicking.rs:665:5
   1: core::panicking::panic_fmt
             at /rustc/7c2012d0ec3aae89fefc40e5d6b317a0949cda36/library/core/src/panicking.rs:74:14
   2: core::panicking::panic
             at /rustc/7c2012d0ec3aae89fefc40e5d6b317a0949cda36/library/core/src/panicking.rs:148:5
   3: cargo_miri::phases::phase_cargo_miri::<std::env::Args>
   4: cargo_miri::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

for some reason I'm forced to explicitly tell miri that yes, rustc is rustc, which it then promptly ignores

> RUSTC=rustc cargo miri test
Preparing a sysroot for Miri (target: x86_64-unknown-linux-gnu)... done
WARNING: Ignoring `RUSTC` environment variable; set `MIRI` if you want to control the binary used as the driver.
...
@RalfJung
Copy link
Member

RalfJung commented Jul 30, 2024

This assertion you are hitting is only active when RUSTC_STAGE is set. That environment variable should never be set outside of rustc bootstrap, I would expect. Any idea why it is set in your environment?

Various parts of Miri assume that if this is set, then we are in bootstrap, which requires some special behavior and is closely coupled to all the other env vars bootstrap sets. So you can expect a bunch of strange behavior in such an environment.

@Nemo157
Copy link
Member Author

Nemo157 commented Jul 30, 2024

Ah right, I do some strange things to try and avoid failures from nightly-detecting crates

# Some crates disable nightly feature detection when this is set
export RUSTC_STAGE=1

I guess I might need a cargo-miri wrapper that unsets that then 🤔

@RalfJung
Copy link
Member

RalfJung commented Jul 30, 2024

Ah, damn, that is an unfortunate clash.

I'm going to close this issue since there's not a bug here (and rust-lang/rust#128382 will make the error a bit less confusing). If you have ideas for how else Miri could detect that it runs inside bootstrap then please let us know. That said, the reason setting that variable helps is that it makes these crates think they are in rustc bootstrap, so...

Maybe you can set this in cargo env instead of the global environment? That should not affect Miri, I think. Though maybe that the confuses other things elsewhere...

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jul 30, 2024
cargo-miri: better error when we seem to run inside bootstrap but something is wrong

Cc rust-lang/miri#3775
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jul 30, 2024
cargo-miri: better error when we seem to run inside bootstrap but something is wrong

Cc rust-lang/miri#3775
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jul 31, 2024
Rollup merge of rust-lang#128382 - RalfJung:cargo-miri-assert, r=oli-obk

cargo-miri: better error when we seem to run inside bootstrap but something is wrong

Cc rust-lang/miri#3775
github-actions bot pushed a commit that referenced this issue Aug 2, 2024
cargo-miri: better error when we seem to run inside bootstrap but something is wrong

Cc #3775
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants