Skip to content

Commit 653790f

Browse files
Rollup merge of #160422 - RalfJung:miri-mir-opt-tests, r=Kobzol
move mir-opt miri tests to CI logic It is useful to run Miri tests with mir-opts as that sometimes finds miscompilations. However, doing so on every `./x test miri` is annoying as it makes that take a lot longer, and it is inconsistent with `./miri test` in the Miri repo. So remove this logic there, and instead have the check-miri script in CI invoke the test suite a 2nd time with mir-opts enabled. Cc @rust-lang/miri
2 parents d734ccb + a91590b commit 653790f

2 files changed

Lines changed: 13 additions & 36 deletions

File tree

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -769,30 +769,6 @@ impl CommandLineStep for Miri {
769769
let _time = helpers::timeit(builder);
770770
cargo.run(builder);
771771
}
772-
773-
// Run it again for mir-opt-level 4 to catch some miscompilations.
774-
if builder.config.test_args().is_empty() {
775-
cargo.env(
776-
"MIRIFLAGS",
777-
format!(
778-
"{} -O -Zmir-opt-level=4 -Cdebug-assertions=yes",
779-
env::var("MIRIFLAGS").unwrap_or_default()
780-
),
781-
);
782-
// Optimizations can change backtraces
783-
cargo.env("MIRI_SKIP_UI_CHECKS", "1");
784-
// `MIRI_SKIP_UI_CHECKS` and `RUSTC_BLESS` are incompatible
785-
cargo.env_remove("RUSTC_BLESS");
786-
// Optimizations can change error locations and remove UB so don't run `fail` tests.
787-
cargo.args(["tests/pass", "tests/panic"]);
788-
789-
{
790-
let _guard =
791-
builder.msg_test("miri (mir-opt-level 4)", target, target_compiler.stage);
792-
let _time = helpers::timeit(builder);
793-
cargo.run(builder);
794-
}
795-
}
796772
}
797773
}
798774

src/ci/docker/host-x86_64/x86_64-gnu-miri/check-miri.sh

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
# ignore-tidy-file-linelength
33

44
set -eu
@@ -15,6 +15,8 @@ if [ -z "${PR_CI_JOB:-}" ]; then
1515
else
1616
python3 "$X_PY" test --stage 2 miri cargo-miri
1717
fi
18+
# Run the test suite again with mir optimizations, to catch some miscompilations.
19+
MIRIFLAGS="-O -Zmir-opt-level=4 -Cdebug-assertions=yes" MIRI_SKIP_UI_CHECKS=1 python3 "$X_PY" test --stage 2 miri -- tests/{pass,panic}
1820
# We natively run this script on x86_64-unknown-linux-gnu and x86_64-pc-windows-msvc.
1921
# Also cover some other targets via cross-testing, in particular all tier 1 targets.
2022
case $HOST_TARGET in
@@ -23,13 +25,12 @@ case $HOST_TARGET in
2325
# Fully test all main OSes, and all main architectures.
2426
python3 "$X_PY" test --stage 2 miri cargo-miri --target aarch64-apple-darwin
2527
python3 "$X_PY" test --stage 2 miri cargo-miri --target i686-pc-windows-msvc
26-
# Only run "pass" tests for the remaining targets, which is quite a bit faster.
27-
# We have to use `miri` instead of `src/tools/miri` here to avoid also running the cargo-miri
28-
# tests.
29-
python3 "$X_PY" test --stage 2 miri --target x86_64-pc-windows-gnu --test-args pass
30-
python3 "$X_PY" test --stage 2 miri --target i686-unknown-linux-gnu --test-args pass
31-
python3 "$X_PY" test --stage 2 miri --target aarch64-unknown-linux-gnu --test-args pass
32-
python3 "$X_PY" test --stage 2 miri --target s390x-unknown-linux-gnu --test-args pass
28+
# Only run "pass" tests for the remaining targets, which is a bit faster. We have to use `miri`
29+
# instead of `src/tools/miri` here to avoid also running the cargo-miri tests.
30+
python3 "$X_PY" test --stage 2 miri --target x86_64-pc-windows-gnu -- tests/pass
31+
python3 "$X_PY" test --stage 2 miri --target i686-unknown-linux-gnu -- tests/pass
32+
python3 "$X_PY" test --stage 2 miri --target aarch64-unknown-linux-gnu -- tests/pass
33+
python3 "$X_PY" test --stage 2 miri --target s390x-unknown-linux-gnu -- tests/pass
3334
;;
3435
x86_64-pc-windows-msvc)
3536
# Strangely, Linux targets do not work here. cargo always says
@@ -38,7 +39,7 @@ case $HOST_TARGET in
3839
#FIXME: Re-enable this once CI issues are fixed
3940
# See <https://github.com/rust-lang/rust/issues/127883>
4041
# For now, these tests are moved to `x86_64-msvc-ext2` in `src/ci/github-actions/jobs.yml`.
41-
#python3 "$X_PY" test --stage 2 miri --target x86_64-apple-darwin --test-args pass
42+
#python3 "$X_PY" test --stage 2 miri --target x86_64-apple-darwin -- pass
4243
;;
4344
*)
4445
echo "FATAL: unexpected host $HOST_TARGET"
@@ -50,7 +51,7 @@ esac
5051

5152
#FIXME: Re-enable this for msvc once CI issues are fixed
5253
if [ "$HOST_TARGET" != "x86_64-pc-windows-msvc" ]; then
53-
python3 "$X_PY" miri --stage 2 library/core --test-args notest
54-
python3 "$X_PY" miri --stage 2 library/alloc --test-args notest
55-
python3 "$X_PY" miri --stage 2 library/std --test-args notest
54+
python3 "$X_PY" miri --stage 2 library/core -- notest
55+
python3 "$X_PY" miri --stage 2 library/alloc -- notest
56+
python3 "$X_PY" miri --stage 2 library/std -- notest
5657
fi

0 commit comments

Comments
 (0)