Skip to content

Commit eadeab5

Browse files
committed
Auto merge of #2908 - RalfJung:bench, r=oli-obk
CI: test ./miri bench
2 parents 2e03c34 + ad079dc commit eadeab5

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

ci.sh

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ begingroup "Building Miri"
1717
echo "Installing release version of Miri"
1818
export RUSTFLAGS="-D warnings"
1919
export CARGO_INCREMENTAL=0
20-
./miri install # implicitly locked
20+
export CARGO_EXTRA_FLAGS="--locked"
21+
./miri install
2122

2223
# Prepare debug build for direct `./miri` invocations
2324
echo "Building debug version of Miri"
24-
export CARGO_EXTRA_FLAGS="--locked"
2525
./miri check --no-default-features # make sure this can be built
2626
./miri check --all-features # and this, too
2727
./miri build --all-targets # the build that all the `./miri test` below will use
@@ -39,8 +39,11 @@ function run_tests {
3939
## ui test suite
4040
./miri test
4141
if [ -z "${MIRI_TEST_TARGET+exists}" ]; then
42-
# Only for host architecture: tests with optimizations (`-O` is what cargo passes, but crank MIR
43-
# optimizations up all the way, too).
42+
# Host-only tests: running these on all targets is unlikely to catch more problems and would
43+
# cost a lot of CI time.
44+
45+
# Tests with optimizations (`-O` is what cargo passes, but crank MIR optimizations up all the
46+
# way, too).
4447
# Optimizations change diagnostics (mostly backtraces), so we don't check
4548
# them. Also error locations change so we don't run the failing tests.
4649
# We explicitly enable debug-assertions here, they are disabled by -O but we have tests
@@ -51,6 +54,9 @@ function run_tests {
5154
for FILE in tests/many-seeds/*.rs; do
5255
MIRI_SEEDS=64 CARGO_EXTRA_FLAGS="$CARGO_EXTRA_FLAGS -q" ./miri many-seeds ./miri run "$FILE"
5356
done
57+
58+
# Check that the benchmarks build and run, but without actually benchmarking.
59+
HYPERFINE="bash -c" ./miri bench
5460
fi
5561

5662
## test-cargo-miri
@@ -75,13 +81,6 @@ function run_tests {
7581
unset RUSTC MIRI
7682
rm -rf .cargo
7783

78-
# Ensure that our benchmarks all work, but only on Linux hosts.
79-
if [ -z "${MIRI_TEST_TARGET+exists}" ] && [ "$HOST_TARGET" = x86_64-unknown-linux-gnu ] ; then
80-
for BENCH in $(ls "bench-cargo-miri"); do
81-
cargo miri run --manifest-path bench-cargo-miri/$BENCH/Cargo.toml
82-
done
83-
fi
84-
8584
endgroup
8685
}
8786

miri

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ if [ -z "$COMMAND" ]; then
7777
fi
7878
shift
7979
# macOS does not have a useful readlink/realpath so we have to use Python instead...
80-
MIRIDIR=$(python3 -c 'import os, sys; print(os.path.dirname(os.path.realpath(sys.argv[1])))' "$0")
80+
MIRIDIR=$(python3 -c 'import pathlib, sys; print(pathlib.Path(sys.argv[1]).resolve().parent.as_posix())' "$0")
8181
# Used for rustc syncs.
8282
JOSH_FILTER=":rev(75dd959a3a40eb5b4574f8d2e23aa6efbeb33573:prefix=src/tools/miri):/src/tools/miri"
8383
# Needed for `./miri bench`.
@@ -184,6 +184,8 @@ many-seeds)
184184
exit 0
185185
;;
186186
bench)
187+
# The hyperfine to use
188+
HYPERFINE=${HYPERFINE:-hyperfine -w 1 -m 5 --shell=none}
187189
# Make sure we have an up-to-date Miri installed
188190
"$0" install
189191
# Run the requested benchmarks
@@ -193,7 +195,7 @@ bench)
193195
BENCHES=("$@")
194196
fi
195197
for BENCH in "${BENCHES[@]}"; do
196-
hyperfine -w 1 -m 5 --shell=none "cargo +$TOOLCHAIN miri run --manifest-path $MIRIDIR/bench-cargo-miri/$BENCH/Cargo.toml"
198+
$HYPERFINE "cargo +$TOOLCHAIN miri run --manifest-path $MIRIDIR/bench-cargo-miri/$BENCH/Cargo.toml"
197199
done
198200
exit 0
199201
;;
@@ -280,10 +282,9 @@ find_sysroot() {
280282
# Run command.
281283
case "$COMMAND" in
282284
install)
283-
# "--locked" to respect the Cargo.lock file if it exists.
284285
# Install binaries to the miri toolchain's sysroot so they do not interact with other toolchains.
285-
$CARGO install $CARGO_EXTRA_FLAGS --path "$MIRIDIR" --force --locked --root "$SYSROOT" "$@"
286-
$CARGO install $CARGO_EXTRA_FLAGS --path "$MIRIDIR"/cargo-miri --force --locked --root "$SYSROOT" "$@"
286+
$CARGO install $CARGO_EXTRA_FLAGS --path "$MIRIDIR" --force --root "$SYSROOT" "$@"
287+
$CARGO install $CARGO_EXTRA_FLAGS --path "$MIRIDIR"/cargo-miri --force --root "$SYSROOT" "$@"
287288
;;
288289
check)
289290
# Check, and let caller control flags.

0 commit comments

Comments
 (0)