Skip to content

Commit

Permalink
./miri run: directly run binary instead of using 'cargo run'
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Sep 13, 2024
1 parent c0fb1a7 commit b6b8e29
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 55 deletions.
2 changes: 1 addition & 1 deletion ci/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ time ./miri install
# We enable all features to make sure the Stacked Borrows consistency check runs.
echo "Building debug version of Miri"
export CARGO_EXTRA_FLAGS="$CARGO_EXTRA_FLAGS --all-features"
time ./miri build --all-targets # the build that all the `./miri test` below will use
time ./miri build # the build that all the `./miri test` below will use

endgroup

Expand Down
118 changes: 88 additions & 30 deletions miri-script/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions miri-script/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ xshell = "0.2.6"
rustc_version = "0.4"
dunce = "1.0.4"
directories = "5"
serde_json = "1"
19 changes: 9 additions & 10 deletions miri-script/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,23 +494,21 @@ impl Command {
flags: Vec<String>,
) -> Result<()> {
let mut e = MiriEnv::new()?;

// Preparation: get a sysroot, and get the miri binary.
let miri_sysroot = e.build_miri_sysroot(/* quiet */ !verbose, target.as_deref())?;
let miri_bin =
e.build_get_binary(".").context("failed to get filename of miri executable")?;

// More flags that we will pass before `flags`
// (because `flags` may contain `--`).
let mut early_flags = Vec::<OsString>::new();

// Add target, edition to flags.
if let Some(target) = &target {
early_flags.push("--target".into());
early_flags.push(target.into());
}
if verbose {
early_flags.push("--verbose".into());
}
early_flags.push("--edition".into());
early_flags.push(edition.as_deref().unwrap_or("2021").into());

// Prepare a sysroot, add it to the flags. (Also builds cargo-miri, which we need.)
let miri_sysroot = e.build_miri_sysroot(/* quiet */ !verbose, target.as_deref())?;
early_flags.push("--sysroot".into());
early_flags.push(miri_sysroot.into());

Expand All @@ -523,18 +521,19 @@ impl Command {
let run_miri = |e: &MiriEnv, seed_flag: Option<String>| -> Result<()> {
// The basic command that executes the Miri driver.
let mut cmd = if dep {
// We invoke the test suite as that has all the logic for running with dependencies.
e.cargo_cmd(".", "test")
.args(&["--test", "ui"])
.args(quiet_flag)
.arg("--")
.args(&["--miri-run-dep-mode"])
} else {
e.cargo_cmd(".", "run").args(quiet_flag).arg("--")
cmd!(e.sh, "{miri_bin}")
};
cmd.set_quiet(!verbose);
// Add Miri flags
let mut cmd = cmd.args(&miri_flags).args(&seed_flag).args(&early_flags).args(&flags);
// For `--dep` we also need to set the env var.
// For `--dep` we also need to set the target in the env var.
if dep {
if let Some(target) = &target {
cmd = cmd.env("MIRI_TEST_TARGET", target);
Expand Down
Loading

0 comments on commit b6b8e29

Please sign in to comment.