]> git.lizzy.rs Git - rust.git/commitdiff
support MIRI_HOST_SYSROOT env var for stage 0 builds
authorRalf Jung <post@ralfj.de>
Thu, 21 Jul 2022 20:49:41 +0000 (16:49 -0400)
committerRalf Jung <post@ralfj.de>
Fri, 22 Jul 2022 12:35:12 +0000 (08:35 -0400)
Together with a patch on the rustc side, this makes './x.py test src/tools/miri --stage 0' work again. :)

README.md
cargo-miri/bin.rs

index 2214bcf4c59cb4cc62de2db1bef1a4aca0e95200..0741f373bb6774da51919dc2aa74522b66093c95 100644 (file)
--- 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
 
index 8b60d90520ab2f394c4831f6548b56f8010d7f39..bb2eb54ffebcac172e6dff81f5c4b2861e3e3c84 100644 (file)
@@ -721,7 +721,9 @@ fn phase_cargo_miri(mut args: impl Iterator<Item = String>) {
     // 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 out_filename(prefix: &str, suffix: &str) -> PathBuf {
     } 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);
             }
         }