Skip to content

miri: make --stage 0 testing work #99599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,9 @@ impl Step for Miri {
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() });
Expand All @@ -483,6 +486,10 @@ impl Step for Miri {
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);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it expected that I need to call ensure and sysroot, i.e., that calling sysroot does not implicitly ensure anything?

Copy link
Member

@jyn514 jyn514 Jul 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It ensures the directory exists. It doesn't build the standard library, a) because it doesn't know what target you want and b) because this is also called when building Std so we can copy the newly built artifacts into the sysroot, so building Std at that time would lead to a dependency cycle

if let (Some(miri), Some(_cargo_miri)) = (miri, cargo_miri) {
let mut cargo =
builder.cargo(compiler, Mode::ToolRustc, SourceType::Submodule, host, "install");
Expand Down Expand Up @@ -562,6 +569,7 @@ impl Step for Miri {

// 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);

Expand Down