From 62175e94a5b9c19e85bd96739e836887daa94e41 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 31 May 2023 11:00:34 +0200 Subject: [PATCH 1/2] CI: test ./miri bench --- ci.sh | 21 ++++++++++----------- miri | 9 +++++---- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/ci.sh b/ci.sh index b5b3b211b0..a8aae524e7 100755 --- a/ci.sh +++ b/ci.sh @@ -17,11 +17,11 @@ begingroup "Building Miri" echo "Installing release version of Miri" export RUSTFLAGS="-D warnings" export CARGO_INCREMENTAL=0 -./miri install # implicitly locked +export CARGO_EXTRA_FLAGS="--locked" +./miri install # Prepare debug build for direct `./miri` invocations echo "Building debug version of Miri" -export CARGO_EXTRA_FLAGS="--locked" ./miri check --no-default-features # make sure this can be built ./miri check --all-features # and this, too ./miri build --all-targets # the build that all the `./miri test` below will use @@ -39,8 +39,11 @@ function run_tests { ## ui test suite ./miri test if [ -z "${MIRI_TEST_TARGET+exists}" ]; then - # Only for host architecture: tests with optimizations (`-O` is what cargo passes, but crank MIR - # optimizations up all the way, too). + # Host-only tests: running these on all targets is unlikely to catch more problems and would + # cost a lot of CI time. + + # Tests with optimizations (`-O` is what cargo passes, but crank MIR optimizations up all the + # way, too). # Optimizations change diagnostics (mostly backtraces), so we don't check # them. Also error locations change so we don't run the failing tests. # We explicitly enable debug-assertions here, they are disabled by -O but we have tests @@ -51,6 +54,9 @@ function run_tests { for FILE in tests/many-seeds/*.rs; do MIRI_SEEDS=64 CARGO_EXTRA_FLAGS="$CARGO_EXTRA_FLAGS -q" ./miri many-seeds ./miri run "$FILE" done + + # Check that the benchmarks build and run, but without actually benchmarking. + HYPERFINE="bash -c" ./miri bench fi ## test-cargo-miri @@ -75,13 +81,6 @@ function run_tests { unset RUSTC MIRI rm -rf .cargo - # Ensure that our benchmarks all work, but only on Linux hosts. - if [ -z "${MIRI_TEST_TARGET+exists}" ] && [ "$HOST_TARGET" = x86_64-unknown-linux-gnu ] ; then - for BENCH in $(ls "bench-cargo-miri"); do - cargo miri run --manifest-path bench-cargo-miri/$BENCH/Cargo.toml - done - fi - endgroup } diff --git a/miri b/miri index 48a46a76a1..ce3fcbba11 100755 --- a/miri +++ b/miri @@ -184,6 +184,8 @@ many-seeds) exit 0 ;; bench) + # The hyperfine to use + HYPERFINE=${HYPERFINE:-hyperfine -w 1 -m 5 --shell=none} # Make sure we have an up-to-date Miri installed "$0" install # Run the requested benchmarks @@ -193,7 +195,7 @@ bench) BENCHES=("$@") fi for BENCH in "${BENCHES[@]}"; do - hyperfine -w 1 -m 5 --shell=none "cargo +$TOOLCHAIN miri run --manifest-path $MIRIDIR/bench-cargo-miri/$BENCH/Cargo.toml" + $HYPERFINE "cargo +$TOOLCHAIN miri run --manifest-path $MIRIDIR/bench-cargo-miri/$BENCH/Cargo.toml" done exit 0 ;; @@ -280,10 +282,9 @@ find_sysroot() { # Run command. case "$COMMAND" in install) - # "--locked" to respect the Cargo.lock file if it exists. # Install binaries to the miri toolchain's sysroot so they do not interact with other toolchains. - $CARGO install $CARGO_EXTRA_FLAGS --path "$MIRIDIR" --force --locked --root "$SYSROOT" "$@" - $CARGO install $CARGO_EXTRA_FLAGS --path "$MIRIDIR"/cargo-miri --force --locked --root "$SYSROOT" "$@" + $CARGO install $CARGO_EXTRA_FLAGS --path "$MIRIDIR" --force --root "$SYSROOT" "$@" + $CARGO install $CARGO_EXTRA_FLAGS --path "$MIRIDIR"/cargo-miri --force --root "$SYSROOT" "$@" ;; check) # Check, and let caller control flags. From ad079dcd9baf4be0864a84f101d7ff03705f1555 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Fri, 5 May 2023 18:37:19 +0200 Subject: [PATCH 2/2] miri-script: Transform Windows paths to unix. python3 snippet used to fill $MIRIDIR variable returns native paths. Down the line in `bench` subcommand this leads to benchmark setup failure, preventing contributors from running benchmarks on Windows hosts. This commit replaces usage of native os.path module with pathlib, which explicitly converts paths to Unix flavour. --- miri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miri b/miri index ce3fcbba11..7cda995879 100755 --- a/miri +++ b/miri @@ -77,7 +77,7 @@ if [ -z "$COMMAND" ]; then fi shift # macOS does not have a useful readlink/realpath so we have to use Python instead... -MIRIDIR=$(python3 -c 'import os, sys; print(os.path.dirname(os.path.realpath(sys.argv[1])))' "$0") +MIRIDIR=$(python3 -c 'import pathlib, sys; print(pathlib.Path(sys.argv[1]).resolve().parent.as_posix())' "$0") # Used for rustc syncs. JOSH_FILTER=":rev(75dd959a3a40eb5b4574f8d2e23aa6efbeb33573:prefix=src/tools/miri):/src/tools/miri" # Needed for `./miri bench`.