Skip to content

Commit 4e4f041

Browse files
committed
Auto merge of #112244 - RalfJung:miri, r=oli-obk
update Miri Also adjust Miri's compiletest a little: in pre-subtree days we added `-A unused -Astable-features` to have the Miri toolstate break less often. But nowadays it just causes confusion when Miri CI works in rustc but fails on the Miri side so let's get rid of this difference. r? `@oli-obk`
2 parents 398fa21 + ca720fd commit 4e4f041

19 files changed

+218
-108
lines changed

Diff for: src/tools/miri/ci.sh

+10-11
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

Diff for: src/tools/miri/miri

+6-5
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.

Diff for: src/tools/miri/rust-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8b4b20836b832e91aa605a2faf5e2a55190202c8
1+
33c3d101280c8eb3cd8af421bfb56a8afcc3881d

Diff for: src/tools/miri/src/borrow_tracker/tree_borrows/diagnostics.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl HistoryData {
9292
{
9393
// NOTE: `transition_range` is explicitly absent from the error message, it has no significance
9494
// to the user. The meaningful one is `access_range`.
95-
self.events.push((Some(span.data()), format!("{this} then transitioned {transition} due to a {rel} {access_kind} at offsets {access_range:?}", rel = if is_foreign { "foreign" } else { "child" })));
95+
self.events.push((Some(span.data()), format!("{this} later transitioned to {endpoint} due to a {rel} {access_kind} at offsets {access_range:?}", endpoint = transition.endpoint(), rel = if is_foreign { "foreign" } else { "child" })));
9696
self.events.push((None, format!("this corresponds to {}", transition.summary())));
9797
}
9898
}
@@ -212,12 +212,13 @@ impl History {
212212

213213
/// Reconstruct the history relevant to `error_offset` by filtering
214214
/// only events whose range contains the offset we are interested in.
215-
fn extract_relevant(&self, error_offset: u64) -> Self {
215+
fn extract_relevant(&self, error_offset: u64, error_kind: TransitionError) -> Self {
216216
History {
217217
events: self
218218
.events
219219
.iter()
220220
.filter(|e| e.transition_range.contains(&error_offset))
221+
.filter(|e| e.transition.is_relevant(error_kind))
221222
.cloned()
222223
.collect::<Vec<_>>(),
223224
created: self.created,
@@ -303,7 +304,7 @@ impl TbError<'_> {
303304
history.extend(self.accessed_info.history.forget(), "accessed", false);
304305
}
305306
history.extend(
306-
self.conflicting_info.history.extract_relevant(self.error_offset),
307+
self.conflicting_info.history.extract_relevant(self.error_offset, self.error_kind),
307308
conflicting_tag_name,
308309
true,
309310
);

0 commit comments

Comments
 (0)