diff --git a/ci/ci.sh b/ci/ci.sh index 8e6e31bee4..5da83a1623 100755 --- a/ci/ci.sh +++ b/ci/ci.sh @@ -18,7 +18,7 @@ export RUSTFLAGS="-D warnings" export CARGO_INCREMENTAL=0 export CARGO_EXTRA_FLAGS="--locked" -# Determine configuration for installed build (used by test-cargo-miri). +# Determine configuration for installed build (used by test-cargo-miri and `./miri bench`). echo "Installing release version of Miri" time ./miri install @@ -73,7 +73,7 @@ function run_tests { fi if [ -n "${TEST_BENCH-}" ]; then # Check that the benchmarks build and run, but only once. - time HYPERFINE="hyperfine -w0 -r1" ./miri bench $TARGET_FLAG + time HYPERFINE="hyperfine -w0 -r1 --show-output" ./miri bench $TARGET_FLAG --no-install fi # Smoke-test `./miri run --dep`. ./miri run $TARGET_FLAG --dep tests/pass-dep/getrandom.rs diff --git a/miri-script/src/commands.rs b/miri-script/src/commands.rs index 4b1cfffd4f..55005d8634 100644 --- a/miri-script/src/commands.rs +++ b/miri-script/src/commands.rs @@ -179,7 +179,8 @@ impl Command { Command::Doc { flags } => Self::doc(flags), Command::Fmt { flags } => Self::fmt(flags), Command::Clippy { flags } => Self::clippy(flags), - Command::Bench { target, benches } => Self::bench(target, benches), + Command::Bench { target, no_install, benches } => + Self::bench(target, no_install, benches), Command::Toolchain { flags } => Self::toolchain(flags), Command::RustcPull { commit } => Self::rustc_pull(commit.clone()), Command::RustcPush { github_user, branch } => Self::rustc_push(github_user, branch), @@ -378,7 +379,7 @@ impl Command { Ok(()) } - fn bench(target: Option, benches: Vec) -> Result<()> { + fn bench(target: Option, no_install: bool, benches: Vec) -> Result<()> { // The hyperfine to use let hyperfine = env::var("HYPERFINE"); let hyperfine = hyperfine.as_deref().unwrap_or("hyperfine -w 1 -m 5 --shell=none"); @@ -386,8 +387,10 @@ impl Command { let Some((program_name, args)) = hyperfine.split_first() else { bail!("expected HYPERFINE environment variable to be non-empty"); }; - // Make sure we have an up-to-date Miri installed and selected the right toolchain. - Self::install(vec![])?; + if !no_install { + // Make sure we have an up-to-date Miri installed and selected the right toolchain. + Self::install(vec![])?; + } let sh = Shell::new()?; sh.change_dir(miri_dir()?); diff --git a/miri-script/src/main.rs b/miri-script/src/main.rs index a329f62790..e1bf3c1862 100644 --- a/miri-script/src/main.rs +++ b/miri-script/src/main.rs @@ -69,6 +69,8 @@ pub enum Command { /// Runs the benchmarks from bench-cargo-miri in hyperfine. hyperfine needs to be installed. Bench { target: Option, + /// When `true`, skip the `./miri install` step. + no_install: bool, /// List of benchmarks to run. By default all benchmarks are run. benches: Vec, }, @@ -121,9 +123,11 @@ install`. Sets up the rpath such that the installed binary should work in any working directory. Note that the binaries are placed in the `miri` toolchain sysroot, to prevent conflicts with other toolchains. -./miri bench [--target ] : +./miri bench [--target ] [--no-install] : Runs the benchmarks from bench-cargo-miri in hyperfine. hyperfine needs to be installed. can explicitly list the benchmarks to run; by default, all of them are run. +By default, this runs `./miri install` to ensure the latest local Miri is being benchmarked; +`--no-install` can be used to skip that step. ./miri toolchain : Update and activate the rustup toolchain 'miri' to the commit given in the @@ -218,16 +222,19 @@ fn main() -> Result<()> { Some("bench") => { let mut target = None; let mut benches = Vec::new(); + let mut no_install = false; loop { if let Some(val) = args.get_long_opt("target")? { target = Some(val); + } else if args.get_long_flag("no-install")? { + no_install = true; } else if let Some(flag) = args.get_other() { benches.push(flag); } else { break; } } - Command::Bench { target, benches } + Command::Bench { target, benches, no_install } } Some("toolchain") => Command::Toolchain { flags: args.remainder() }, Some("rustc-pull") => {