Skip to content

Commit f55c670

Browse files
committed
Auto merge of #3881 - RalfJung:miri-run, r=RalfJung
./miri run: directly run binary instead of using 'cargo run' This avoids re-building miri without dev dependencies, so it makes `./miri run` a lot faster if `./miri test` was already executed before.
2 parents 11da987 + b6b8e29 commit f55c670

File tree

5 files changed

+144
-55
lines changed

5 files changed

+144
-55
lines changed

ci/ci.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ time ./miri install
2626
# We enable all features to make sure the Stacked Borrows consistency check runs.
2727
echo "Building debug version of Miri"
2828
export CARGO_EXTRA_FLAGS="$CARGO_EXTRA_FLAGS --all-features"
29-
time ./miri build --all-targets # the build that all the `./miri test` below will use
29+
time ./miri build # the build that all the `./miri test` below will use
3030

3131
endgroup
3232

miri-script/Cargo.lock

Lines changed: 88 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

miri-script/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ xshell = "0.2.6"
2323
rustc_version = "0.4"
2424
dunce = "1.0.4"
2525
directories = "5"
26+
serde_json = "1"

miri-script/src/commands.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -494,23 +494,21 @@ impl Command {
494494
flags: Vec<String>,
495495
) -> Result<()> {
496496
let mut e = MiriEnv::new()?;
497+
498+
// Preparation: get a sysroot, and get the miri binary.
499+
let miri_sysroot = e.build_miri_sysroot(/* quiet */ !verbose, target.as_deref())?;
500+
let miri_bin =
501+
e.build_get_binary(".").context("failed to get filename of miri executable")?;
502+
497503
// More flags that we will pass before `flags`
498504
// (because `flags` may contain `--`).
499505
let mut early_flags = Vec::<OsString>::new();
500-
501-
// Add target, edition to flags.
502506
if let Some(target) = &target {
503507
early_flags.push("--target".into());
504508
early_flags.push(target.into());
505509
}
506-
if verbose {
507-
early_flags.push("--verbose".into());
508-
}
509510
early_flags.push("--edition".into());
510511
early_flags.push(edition.as_deref().unwrap_or("2021").into());
511-
512-
// Prepare a sysroot, add it to the flags. (Also builds cargo-miri, which we need.)
513-
let miri_sysroot = e.build_miri_sysroot(/* quiet */ !verbose, target.as_deref())?;
514512
early_flags.push("--sysroot".into());
515513
early_flags.push(miri_sysroot.into());
516514

@@ -523,18 +521,19 @@ impl Command {
523521
let run_miri = |e: &MiriEnv, seed_flag: Option<String>| -> Result<()> {
524522
// The basic command that executes the Miri driver.
525523
let mut cmd = if dep {
524+
// We invoke the test suite as that has all the logic for running with dependencies.
526525
e.cargo_cmd(".", "test")
527526
.args(&["--test", "ui"])
528527
.args(quiet_flag)
529528
.arg("--")
530529
.args(&["--miri-run-dep-mode"])
531530
} else {
532-
e.cargo_cmd(".", "run").args(quiet_flag).arg("--")
531+
cmd!(e.sh, "{miri_bin}")
533532
};
534533
cmd.set_quiet(!verbose);
535534
// Add Miri flags
536535
let mut cmd = cmd.args(&miri_flags).args(&seed_flag).args(&early_flags).args(&flags);
537-
// For `--dep` we also need to set the env var.
536+
// For `--dep` we also need to set the target in the env var.
538537
if dep {
539538
if let Some(target) = &target {
540539
cmd = cmd.env("MIRI_TEST_TARGET", target);

0 commit comments

Comments
 (0)