Skip to content

Commit cc6439d

Browse files
committed
Auto merge of rust-lang#2415 - RalfJung:cargo-miri, r=oli-obk
support MIRI_HOST_SYSROOT env var for stage 0 builds Together with a [patch on the rustc side](rust-lang#99599), this makes `./x.py test src/tools/miri --stage 0` work again. :) r? `@oli-obk`
2 parents 595cad9 + 83cbbd7 commit cc6439d

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,8 @@ binaries, and as such worth documenting:
445445
crate currently being compiled.
446446
* `MIRI_VERBOSE` when set to any value tells the various `cargo-miri` phases to
447447
perform verbose logging.
448+
* `MIRI_HOST_SYSROOT` is set by bootstrap to tell `cargo-miri` which sysroot to use for *host*
449+
operations.
448450

449451
[testing-miri]: CONTRIBUTING.md#testing-the-miri-driver
450452

cargo-miri/bin.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,9 @@ fn phase_cargo_miri(mut args: impl Iterator<Item = String>) {
721721
// hope that all they do is ask for the version number -- things could quickly go downhill from here.
722722
// In `main`, we need the value of `RUSTC` to distinguish RUSTC_WRAPPER invocations from rustdoc
723723
// or TARGET_RUNNER invocations, so we canonicalize it here to make it exceedingly unlikely that
724-
// there would be a collision.
724+
// there would be a collision with other invocations of cargo-miri (as rustdoc or as runner).
725+
// We explicitly do this even if RUSTC_STAGE is set, since for these builds we do *not* want the
726+
// bootstrap `rustc` thing in our way! Instead, we have MIRI_HOST_SYSROOT to use for host builds.
725727
cmd.env("RUSTC", &fs::canonicalize(find_miri()).unwrap());
726728

727729
let runner_env_name =
@@ -929,9 +931,9 @@ fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
929931
} else {
930932
// For host crates (but not when we are printing), we might still have to set the sysroot.
931933
if !print {
932-
// When we're running `cargo-miri` from `x.py` we need to pass the sysroot explicitly as rustc
933-
// can't figure out the sysroot on its own unless it's from rustup.
934-
if let Some(sysroot) = std::env::var_os("SYSROOT") {
934+
// When we're running `cargo-miri` from `x.py` we need to pass the sysroot explicitly
935+
// due to bootstrap complications.
936+
if let Some(sysroot) = std::env::var_os("MIRI_HOST_SYSROOT") {
935937
cmd.arg("--sysroot").arg(sysroot);
936938
}
937939
}

0 commit comments

Comments
 (0)