Skip to content

minor improvements on running miri #140898

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
20 changes: 14 additions & 6 deletions src/bootstrap/src/core/build_steps/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,25 +118,33 @@ impl Step for Miri {
fn run(self, builder: &Builder<'_>) {
let host = builder.build.build;
let target = self.target;
let stage = builder.top_stage;

// `x run` uses stage 0 by default but miri does not work well with stage 0.
// Change the stage to 1 if it's not set explicitly.
let stage = if builder.config.is_explicit_stage() || builder.top_stage >= 1 {
builder.top_stage
} else {
1
};

if stage == 0 {
eprintln!("miri cannot be run at stage 0");
std::process::exit(1);
}

// This compiler runs on the host, we'll just use it for the target.
let target_compiler = builder.compiler(stage, host);
let host_compiler = tool::get_tool_rustc_compiler(builder, target_compiler);
let compiler = builder.compiler(stage, target);
let miri_build = builder.ensure(tool::Miri { compiler, target });

// Get a target sysroot for Miri.
let miri_sysroot = test::Miri::build_miri_sysroot(builder, target_compiler, target);
let miri_sysroot =
test::Miri::build_miri_sysroot(builder, miri_build.target_compiler, target);

// # Run miri.
// Running it via `cargo run` as that figures out the right dylib path.
// add_rustc_lib_path does not add the path that contains librustc_driver-<...>.so.
let mut miri = tool::prepare_tool_cargo(
builder,
host_compiler,
miri_build.build_compiler,
Mode::ToolRustc,
host,
Kind::Run,
Expand Down
Loading