-
Notifications
You must be signed in to change notification settings - Fork 353
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
fix ./x.py test miri #2407
fix ./x.py test miri #2407
Conversation
cargo-miri/bin.rs
Outdated
@@ -668,7 +668,10 @@ fn phase_cargo_miri(mut args: env::Args) { | |||
"WARNING: Ignoring `RUSTC` environment variable; set `MIRI` if you want to control the binary used as the driver." | |||
); | |||
} | |||
cmd.env_remove("RUSTC"); | |||
|
|||
if env::var_os("RUSTC_STAGE").is_none() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment. Note the comment above:
Having both
RUSTC_WRAPPER
andRUSTC
set does some odd things, so let's avoid that.
cargo-miri/bin.rs
Outdated
@@ -1181,6 +1190,13 @@ fn main() { | |||
let binary = Path::new(arg); | |||
if binary.exists() { | |||
assert!(!arg.starts_with("--")); // not a flag | |||
if let Some(rustc) = std::env::var_os("RUSTC") { | |||
if rustc == arg { | |||
// In bootstrap we can't rely on rustc just being named rustc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh yeah I think this is exactly why we did env_remove("RUSTC")
above. I'm a bit worried we might get some weird mixup here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without RUSTC
cargo would call rustc
which doesn't exist on rust's CI. It needs to use the rustc set in RUSTC
by rust's build system, not the system rustc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the problem is that we need to be able to specify a specific rustc with the RUSTC
env var, as cargo just invokes the env var or rustc
when doing -vV
. Unfortunately we can only set it to a binary, not a script or similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without RUSTC cargo would call rustc which doesn't exist on rust's CI. It needs to use the rustc set in RUSTC by rust's build system, not the system rustc.
cargo-miri should never invoke rustc. It should always only invoke miri itself, including when it needs rustc. That's what all that MIRI_BE_RUSTC stuff is for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We used to invoke both miri and rustc but that leads to strange errors very quickly when those two are not exactly in sync. It's much better to ensure that everything goes through the same binary, miri
, which can do both compilation and interpretation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cargo just invokes the env var or rustc when doing -vV
Oh wait it ignores RUSTC_WRAPPER for that? That sounds like a cargo bug to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might need something like this
Lines 480 to 486 in 88ad9ca
let cargo_miri_path = std::env::current_exe().expect("current executable path invalid"); | |
if env::var_os("RUSTC_STAGE").is_some() { | |
command.env("RUSTC_REAL", &cargo_miri_path); | |
} else { | |
command.env("RUSTC", &cargo_miri_path); | |
} | |
command.env("MIRI_CALLED_FROM_XARGO", "1"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure how that helps. we're not invoking the bootstrap rustc
thingy that forwards to RUSTC_REAL
, if RUSTC
is empty, cargo literally invokes rustc -vV
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wait it ignores RUSTC_WRAPPER for that? That sounds like a cargo bug to me.
yea, I found no way to influence that binary other than via the RUSTC
env var
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah IMO that's definitely a cargo bug. Reported as rust-lang/cargo#10885.
I guess you could set RUSTC to the underlying Miri driver? For -vV
that'll be fine and thanks to the RUSTC_WRAPPER all the other calls should end up in the right spot. Let's use an absolute canonical path for this so it should not be possible to have confusion in the phase selection logic in main
.
uuh... what happened to our CI, something seems to be out of disk space |
Seems to work again? At least the linux builder. |
Some("rustc") => phase_rustc(args, RustcPhase::Build), | ||
// Work around a cargo bug where it ignores `RUSTC_WRAPPER`, so we get | ||
// called ourselves and handle the special case for `rustc -vV`. | ||
Some("-vV") => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I tried this, cargo miri test
in our test-cargo-miri failed because the libc build script invokes RUSTC --version
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh... it works in the ui test suite, I didn't check test-cargo-miri
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it fails that way on CI now
error: failed to run custom build command for
libc v0.2.126
☔ The latest upstream changes (presumably #2409) made this pull request unmergeable. Please resolve the merge conflicts. |
Ok, this one works now. I had to manually remove
.cargo/bin
from my path to reproduce the rustc failure, and then figure out a few shenanigans around how cargo forwards arguments.