about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2023-05-12 14:54:12 +0200
committerRalf Jung <post@ralfj.de>2023-05-12 15:07:24 +0200
commit18fd17d2cd88c8ecd250ca8dbb20a29ad79b30b3 (patch)
treeed951c028f936d2c1871719cb0f8ac7d6603b622
parentb1574380cc8c8e39362d3923eeb3600d17aa6880 (diff)
downloadrust-18fd17d2cd88c8ecd250ca8dbb20a29ad79b30b3.tar.gz
rust-18fd17d2cd88c8ecd250ca8dbb20a29ad79b30b3.zip
run miri tests with MIR opts in rustc CI
-rw-r--r--src/bootstrap/test.rs21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs
index 854b7f5bd3a..374b6cafcac 100644
--- a/src/bootstrap/test.rs
+++ b/src/bootstrap/test.rs
@@ -613,6 +613,21 @@ impl Step for Miri {
             builder.run(&mut cargo);
         }
 
+        // Run it again for mir-opt-level 4 to catch some miscompilations.
+        if builder.config.test_args().is_empty() {
+            cargo.env("MIRIFLAGS", "-O -Zmir-opt-level=4 -Cdebug-assertions=yes");
+            // Optimizations can change backtraces
+            cargo.env("MIRI_SKIP_UI_CHECKS", "1");
+            // Optimizations can change error locations and remove UB so don't run `fail` tests.
+            cargo.args(&["tests/pass", "tests/panic"]);
+
+            let mut cargo = prepare_cargo_test(cargo, &[], &[], "miri", compiler, target, builder);
+            {
+                let _time = util::timeit(&builder);
+                builder.run(&mut cargo);
+            }
+        }
+
         // # Run `cargo miri test`.
         // This is just a smoke test (Miri's own CI invokes this in a bunch of different ways and ensures
         // that we get the desired output), but that is sufficient to make sure that the libtest harness
@@ -644,8 +659,10 @@ impl Step for Miri {
         cargo.env("RUST_BACKTRACE", "1");
 
         let mut cargo = Command::from(cargo);
-        let _time = util::timeit(&builder);
-        builder.run(&mut cargo);
+        {
+            let _time = util::timeit(&builder);
+            builder.run(&mut cargo);
+        }
     }
 }