]> git.lizzy.rs Git - rust.git/blobdiff - src/bootstrap/test.rs
Rollup merge of #99595 - nikic:thumbv6m-atomics, r=nagisa
[rust.git] / src / bootstrap / test.rs
index 6be3da552919d734100af0f56a44357b022073a2..078207d85fe46c062a36bde9b6e47ae8c4a9fe16 100644 (file)
@@ -475,6 +475,9 @@ fn run(self, builder: &Builder<'_>) {
         let stage = self.stage;
         let host = self.host;
         let compiler = builder.compiler(stage, host);
+        // We need the stdlib for the *next* stage, as it was built with this compiler that also built Miri.
+        // Except if we are at stage 2, the bootstrap loop is complete and we can stick with our current stage.
+        let compiler_std = builder.compiler(if stage < 2 { stage + 1 } else { stage }, host);
 
         let miri =
             builder.ensure(tool::Miri { compiler, target: self.host, extra_features: Vec::new() });
@@ -483,6 +486,10 @@ fn run(self, builder: &Builder<'_>) {
             target: self.host,
             extra_features: Vec::new(),
         });
+        // The stdlib we need might be at a different stage. And just asking for the
+        // sysroot does not seem to populate it, so we do that first.
+        builder.ensure(compile::Std::new(compiler_std, host));
+        let sysroot = builder.sysroot(compiler_std);
         if let (Some(miri), Some(_cargo_miri)) = (miri, cargo_miri) {
             let mut cargo =
                 builder.cargo(compiler, Mode::ToolRustc, SourceType::Submodule, host, "install");
@@ -562,6 +569,7 @@ fn run(self, builder: &Builder<'_>) {
 
             // miri tests need to know about the stage sysroot
             cargo.env("MIRI_SYSROOT", miri_sysroot);
+            cargo.env("MIRI_HOST_SYSROOT", sysroot);
             cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
             cargo.env("MIRI", miri);
 
@@ -673,7 +681,7 @@ fn run(self, builder: &Builder<'_>) {
         }
 
         if !builder.config.cmd.bless() {
-            std::process::exit(1);
+            crate::detail_exit(1);
         }
 
         let mut cargo = builder.cargo(compiler, Mode::ToolRustc, SourceType::InTree, host, "run");
@@ -1021,7 +1029,7 @@ fn run(self, builder: &Builder<'_>) {
                     PATH = inferred_rustfmt_dir.display(),
                     CHAN = builder.config.channel,
                 );
-                std::process::exit(1);
+                crate::detail_exit(1);
             }
             crate::format::format(&builder, !builder.config.cmd.bless(), &[]);
         }
@@ -1251,7 +1259,7 @@ fn run(self, builder: &Builder<'_>) {
 help: to test the standard library, use `--stage 0 library/std` instead
 note: if you're sure you want to do this, please open an issue as to why. In the meantime, you can override this with `COMPILETEST_FORCE_STAGE0=1`."
             );
-            std::process::exit(1);
+            crate::detail_exit(1);
         }
 
         let compiler = self.compiler;