From 83cbbd7bce12684f044b3c9d6c321723b0a737e7 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 21 Jul 2022 16:49:41 -0400 Subject: [PATCH] support MIRI_HOST_SYSROOT env var for stage 0 builds Together with a patch on the rustc side, this makes './x.py test src/tools/miri --stage 0' work again. :) --- README.md | 2 ++ cargo-miri/bin.rs | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2214bcf4c59c..0741f373bb67 100644 --- a/README.md +++ b/README.md @@ -445,6 +445,8 @@ binaries, and as such worth documenting: crate currently being compiled. * `MIRI_VERBOSE` when set to any value tells the various `cargo-miri` phases to perform verbose logging. +* `MIRI_HOST_SYSROOT` is set by bootstrap to tell `cargo-miri` which sysroot to use for *host* + operations. [testing-miri]: CONTRIBUTING.md#testing-the-miri-driver diff --git a/cargo-miri/bin.rs b/cargo-miri/bin.rs index 8b60d90520ab..bb2eb54ffebc 100644 --- a/cargo-miri/bin.rs +++ b/cargo-miri/bin.rs @@ -721,7 +721,9 @@ fn phase_cargo_miri(mut args: impl Iterator) { // hope that all they do is ask for the version number -- things could quickly go downhill from here. // In `main`, we need the value of `RUSTC` to distinguish RUSTC_WRAPPER invocations from rustdoc // or TARGET_RUNNER invocations, so we canonicalize it here to make it exceedingly unlikely that - // there would be a collision. + // there would be a collision with other invocations of cargo-miri (as rustdoc or as runner). + // We explicitly do this even if RUSTC_STAGE is set, since for these builds we do *not* want the + // bootstrap `rustc` thing in our way! Instead, we have MIRI_HOST_SYSROOT to use for host builds. cmd.env("RUSTC", &fs::canonicalize(find_miri()).unwrap()); let runner_env_name = @@ -929,9 +931,9 @@ fn phase_rustc(mut args: impl Iterator, phase: RustcPhase) { } else { // For host crates (but not when we are printing), we might still have to set the sysroot. if !print { - // When we're running `cargo-miri` from `x.py` we need to pass the sysroot explicitly as rustc - // can't figure out the sysroot on its own unless it's from rustup. - if let Some(sysroot) = std::env::var_os("SYSROOT") { + // When we're running `cargo-miri` from `x.py` we need to pass the sysroot explicitly + // due to bootstrap complications. + if let Some(sysroot) = std::env::var_os("MIRI_HOST_SYSROOT") { cmd.arg("--sysroot").arg(sysroot); } }