about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-08-12 23:10:51 +0200
committerGitHub <noreply@github.com>2024-08-12 23:10:51 +0200
commit301a4cab68e032ef03baec8f08415b0e53df4354 (patch)
treeb2644975b4fd314ed639e279a809cc430b8c3174 /src
parent85eb465a1058251a09a549c3c7e87c13c9a1b473 (diff)
parent6839a8f6d55ebb00b1904cda37d03caf15144440 (diff)
downloadrust-301a4cab68e032ef03baec8f08415b0e53df4354.tar.gz
rust-301a4cab68e032ef03baec8f08415b0e53df4354.zip
Rollup merge of #129000 - RalfJung:miri-bootstrap-clear, r=onur-ozkan
bootstrap: clear miri ui-test deps when miri sysroot gets rebuilt

Second attempt after https://github.com/rust-lang/rust/pull/128683: seems like it's not the compiler changing that we care about, but the sysroot changing.

I did some local testing with sysroot rebuilds and it works fine for at least those cases I checked.

r? ``@onur-ozkan``
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/src/core/build_steps/test.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs
index 597d7733abe..6ed001d8fd5 100644
--- a/src/bootstrap/src/core/build_steps/test.rs
+++ b/src/bootstrap/src/core/build_steps/test.rs
@@ -434,7 +434,7 @@ impl Miri {
         builder: &Builder<'_>,
         compiler: Compiler,
         target: TargetSelection,
-    ) -> String {
+    ) -> PathBuf {
         let miri_sysroot = builder.out.join(compiler.host.triple).join("miri-sysroot");
         let mut cargo = builder::Cargo::new(
             builder,
@@ -467,7 +467,7 @@ impl Miri {
         // Output is "<sysroot>\n".
         let sysroot = stdout.trim_end();
         builder.verbose(|| println!("`cargo miri setup --print-sysroot` said: {sysroot:?}"));
-        sysroot.to_owned()
+        PathBuf::from(sysroot)
     }
 }
 
@@ -520,12 +520,14 @@ impl Step for Miri {
         builder.ensure(compile::Std::new(target_compiler, host));
         let host_sysroot = builder.sysroot(target_compiler);
 
-        // Miri has its own "target dir" for ui test dependencies. Make sure it gets cleared
-        // properly when rustc changes. Similar to `Builder::cargo`, we skip this in dry runs to
-        // make sure the relevant compiler has been set up properly.
+        // Miri has its own "target dir" for ui test dependencies. Make sure it gets cleared when
+        // the sysroot gets rebuilt, to avoid "found possibly newer version of crate `std`" errors.
         if !builder.config.dry_run() {
             let ui_test_dep_dir = builder.stage_out(host_compiler, Mode::ToolStd).join("miri_ui");
-            builder.clear_if_dirty(&ui_test_dep_dir, &builder.rustc(host_compiler));
+            // The mtime of `miri_sysroot` changes when the sysroot gets rebuilt (also see
+            // <https://github.com/RalfJung/rustc-build-sysroot/commit/10ebcf60b80fe2c3dc765af0ff19fdc0da4b7466>).
+            // We can hence use that directly as a signal to clear the ui test dir.
+            builder.clear_if_dirty(&ui_test_dep_dir, &miri_sysroot);
         }
 
         // Run `cargo test`.