about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2025-06-29 12:11:19 +0200
committerRalf Jung <post@ralfj.de>2025-06-29 12:22:58 +0200
commit7be1bf7dfe5fb8e846b7776c815e6daea9419e62 (patch)
tree2c97490659be66d544d483bd2a23d072d4d378ac
parent03a7b9f532d183b97a5caa5519b3fb734eb1e20a (diff)
downloadrust-7be1bf7dfe5fb8e846b7776c815e6daea9419e62.tar.gz
rust-7be1bf7dfe5fb8e846b7776c815e6daea9419e62.zip
make ./miri work on stable again
-rw-r--r--src/tools/miri/.github/workflows/setup/action.yml4
-rwxr-xr-xsrc/tools/miri/miri28
-rw-r--r--src/tools/miri/miri-script/src/commands.rs16
-rw-r--r--src/tools/miri/miri.bat4
4 files changed, 29 insertions, 23 deletions
diff --git a/src/tools/miri/.github/workflows/setup/action.yml b/src/tools/miri/.github/workflows/setup/action.yml
index 146b432171e..f374897bc78 100644
--- a/src/tools/miri/.github/workflows/setup/action.yml
+++ b/src/tools/miri/.github/workflows/setup/action.yml
@@ -39,10 +39,6 @@ runs:
         run: cargo install -f rustup-toolchain-install-master hyperfine
         shell: bash
 
-      - name: Install nightly toolchain
-        run: rustup toolchain install nightly --profile minimal
-        shell: bash
-
       - name: Install "master" toolchain
         run: |
           if [[ ${{ github.event_name }} == 'schedule' ]]; then
diff --git a/src/tools/miri/miri b/src/tools/miri/miri
index b1b146d7990..549998ae44a 100755
--- a/src/tools/miri/miri
+++ b/src/tools/miri/miri
@@ -2,20 +2,24 @@
 set -e
 # We want to call the binary directly, so we need to know where it ends up.
 ROOT_DIR="$(dirname "$0")"
-MIRI_SCRIPT_TARGET_DIR="$ROOT_DIR"/miri-script/target
-TOOLCHAIN="+nightly"
+TARGET_DIR="$ROOT_DIR"/miri-script/target
+# Prepare cargo invocation.
+# We have to overwrite the toolchain since `+miri` might be activated and not installed.
+TOOLCHAIN="+stable"
+CARGO_FLAGS=("-q")
 # If we are being invoked for RA, use JSON output and the default toolchain (to make proc-macros
 # work in RA). This needs a different target dir to avoid mixing up the builds.
+# Also set `-Zroot-dir` so that RA can identify where the error occurred.
 if [ -n "$MIRI_IN_RA" ]; then
-  MESSAGE_FORMAT="--message-format=json"
   TOOLCHAIN=""
-  MIRI_SCRIPT_TARGET_DIR="$MIRI_SCRIPT_TARGET_DIR"/ra
+  CARGO_FLAGS+=("--message-format=json" "-Zroot-dir=$ROOT_DIR")
+  TARGET_DIR="$ROOT_DIR"/target
 fi
-# We need a nightly toolchain, for `-Zroot-dir`.
-cargo $TOOLCHAIN build $CARGO_EXTRA_FLAGS --manifest-path "$ROOT_DIR"/miri-script/Cargo.toml \
-  -Zroot-dir="$ROOT_DIR" \
-  -q --target-dir "$MIRI_SCRIPT_TARGET_DIR" $MESSAGE_FORMAT || \
-  ( echo "Failed to build miri-script. Is the 'nightly' toolchain installed?"; exit 1 )
-# Instead of doing just `cargo run --manifest-path .. $@`, we invoke miri-script binary directly. Invoking `cargo run` goes through
-# rustup (that sets it's own environmental variables), which is undesirable.
-"$MIRI_SCRIPT_TARGET_DIR"/debug/miri-script "$@"
+# Run cargo.
+cargo $TOOLCHAIN build --manifest-path "$ROOT_DIR"/miri-script/Cargo.toml \
+  --target-dir "$TARGET_DIR" "${CARGO_FLAGS[@]}" || \
+  ( echo "Failed to build miri-script. Is the 'stable' toolchain installed?"; exit 1 )
+# Instead of doing just `cargo run --manifest-path .. $@`, we invoke miri-script binary directly.
+# Invoking `cargo run` goes through rustup (that sets it's own environmental variables), which is
+# undesirable.
+"$TARGET_DIR"/debug/miri-script "$@"
diff --git a/src/tools/miri/miri-script/src/commands.rs b/src/tools/miri/miri-script/src/commands.rs
index d18e9c7791f..a3778215019 100644
--- a/src/tools/miri/miri-script/src/commands.rs
+++ b/src/tools/miri/miri-script/src/commands.rs
@@ -707,9 +707,12 @@ impl Command {
         let mut early_flags = Vec::<OsString>::new();
 
         // In `dep` mode, the target is already passed via `MIRI_TEST_TARGET`
-        if !dep && let Some(target) = &target {
-            early_flags.push("--target".into());
-            early_flags.push(target.into());
+        #[expect(clippy::collapsible_if)] // we need to wait until this is stable
+        if !dep {
+            if let Some(target) = &target {
+                early_flags.push("--target".into());
+                early_flags.push(target.into());
+            }
         }
         early_flags.push("--edition".into());
         early_flags.push(edition.as_deref().unwrap_or("2021").into());
@@ -737,8 +740,11 @@ impl Command {
         // Add Miri flags
         let mut cmd = cmd.args(&miri_flags).args(&early_flags).args(&flags);
         // For `--dep` we also need to set the target in the env var.
-        if dep && let Some(target) = &target {
-            cmd = cmd.env("MIRI_TEST_TARGET", target);
+        #[expect(clippy::collapsible_if)] // we need to wait until this is stable
+        if dep {
+            if let Some(target) = &target {
+                cmd = cmd.env("MIRI_TEST_TARGET", target);
+            }
         }
         // Finally, run the thing.
         Ok(cmd.run()?)
diff --git a/src/tools/miri/miri.bat b/src/tools/miri/miri.bat
index b046b6310dd..6f9a8f38d65 100644
--- a/src/tools/miri/miri.bat
+++ b/src/tools/miri/miri.bat
@@ -5,8 +5,8 @@ set MIRI_SCRIPT_TARGET_DIR=%0\..\miri-script\target
 
 :: If any other steps are added, the "|| exit /b" must be appended to early
 :: return from the script. If not, it will continue execution.
-cargo +nightly build %CARGO_EXTRA_FLAGS% -q --target-dir %MIRI_SCRIPT_TARGET_DIR% --manifest-path %0\..\miri-script\Cargo.toml ^
-  || (echo Failed to build miri-script. Is the 'nightly' toolchain installed? & exit /b)
+cargo +stable build %CARGO_EXTRA_FLAGS% -q --target-dir %MIRI_SCRIPT_TARGET_DIR% --manifest-path %0\..\miri-script\Cargo.toml ^
+  || (echo Failed to build miri-script. Is the 'stable' toolchain installed? & exit /b)
 
 :: Forwards all arguments to this file to the executable.
 :: We invoke the binary directly to avoid going through rustup, which would set some extra