Skip to content

Commit 7d0a55b

Browse files
committed
Auto merge of #99599 - RalfJung:miri-stage-0, r=RalfJung
miri: make --stage 0 testing work This needs rust-lang/miri#2415 or it'll break Miri entirely. also fixes #99589
2 parents ed793d8 + 2564a08 commit 7d0a55b

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/bootstrap/test.rs

+8
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,9 @@ impl Step for Miri {
475475
let stage = self.stage;
476476
let host = self.host;
477477
let compiler = builder.compiler(stage, host);
478+
// We need the stdlib for the *next* stage, as it was built with this compiler that also built Miri.
479+
// Except if we are at stage 2, the bootstrap loop is complete and we can stick with our current stage.
480+
let compiler_std = builder.compiler(if stage < 2 { stage + 1 } else { stage }, host);
478481

479482
let miri =
480483
builder.ensure(tool::Miri { compiler, target: self.host, extra_features: Vec::new() });
@@ -483,6 +486,10 @@ impl Step for Miri {
483486
target: self.host,
484487
extra_features: Vec::new(),
485488
});
489+
// The stdlib we need might be at a different stage. And just asking for the
490+
// sysroot does not seem to populate it, so we do that first.
491+
builder.ensure(compile::Std::new(compiler_std, host));
492+
let sysroot = builder.sysroot(compiler_std);
486493
if let (Some(miri), Some(_cargo_miri)) = (miri, cargo_miri) {
487494
let mut cargo =
488495
builder.cargo(compiler, Mode::ToolRustc, SourceType::Submodule, host, "install");
@@ -562,6 +569,7 @@ impl Step for Miri {
562569

563570
// miri tests need to know about the stage sysroot
564571
cargo.env("MIRI_SYSROOT", miri_sysroot);
572+
cargo.env("MIRI_HOST_SYSROOT", sysroot);
565573
cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
566574
cargo.env("MIRI", miri);
567575

0 commit comments

Comments
 (0)