Skip to content

Commit 7be1bf7

Browse files
committed
make ./miri work on stable again
1 parent 03a7b9f commit 7be1bf7

File tree

4 files changed

+29
-23
lines changed

4 files changed

+29
-23
lines changed

src/tools/miri/.github/workflows/setup/action.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ runs:
3939
run: cargo install -f rustup-toolchain-install-master hyperfine
4040
shell: bash
4141

42-
- name: Install nightly toolchain
43-
run: rustup toolchain install nightly --profile minimal
44-
shell: bash
45-
4642
- name: Install "master" toolchain
4743
run: |
4844
if [[ ${{ github.event_name }} == 'schedule' ]]; then

src/tools/miri/miri

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,24 @@
22
set -e
33
# We want to call the binary directly, so we need to know where it ends up.
44
ROOT_DIR="$(dirname "$0")"
5-
MIRI_SCRIPT_TARGET_DIR="$ROOT_DIR"/miri-script/target
6-
TOOLCHAIN="+nightly"
5+
TARGET_DIR="$ROOT_DIR"/miri-script/target
6+
# Prepare cargo invocation.
7+
# We have to overwrite the toolchain since `+miri` might be activated and not installed.
8+
TOOLCHAIN="+stable"
9+
CARGO_FLAGS=("-q")
710
# If we are being invoked for RA, use JSON output and the default toolchain (to make proc-macros
811
# work in RA). This needs a different target dir to avoid mixing up the builds.
12+
# Also set `-Zroot-dir` so that RA can identify where the error occurred.
913
if [ -n "$MIRI_IN_RA" ]; then
10-
MESSAGE_FORMAT="--message-format=json"
1114
TOOLCHAIN=""
12-
MIRI_SCRIPT_TARGET_DIR="$MIRI_SCRIPT_TARGET_DIR"/ra
15+
CARGO_FLAGS+=("--message-format=json" "-Zroot-dir=$ROOT_DIR")
16+
TARGET_DIR="$ROOT_DIR"/target
1317
fi
14-
# We need a nightly toolchain, for `-Zroot-dir`.
15-
cargo $TOOLCHAIN build $CARGO_EXTRA_FLAGS --manifest-path "$ROOT_DIR"/miri-script/Cargo.toml \
16-
-Zroot-dir="$ROOT_DIR" \
17-
-q --target-dir "$MIRI_SCRIPT_TARGET_DIR" $MESSAGE_FORMAT || \
18-
( echo "Failed to build miri-script. Is the 'nightly' toolchain installed?"; exit 1 )
19-
# Instead of doing just `cargo run --manifest-path .. $@`, we invoke miri-script binary directly. Invoking `cargo run` goes through
20-
# rustup (that sets it's own environmental variables), which is undesirable.
21-
"$MIRI_SCRIPT_TARGET_DIR"/debug/miri-script "$@"
18+
# Run cargo.
19+
cargo $TOOLCHAIN build --manifest-path "$ROOT_DIR"/miri-script/Cargo.toml \
20+
--target-dir "$TARGET_DIR" "${CARGO_FLAGS[@]}" || \
21+
( echo "Failed to build miri-script. Is the 'stable' toolchain installed?"; exit 1 )
22+
# Instead of doing just `cargo run --manifest-path .. $@`, we invoke miri-script binary directly.
23+
# Invoking `cargo run` goes through rustup (that sets it's own environmental variables), which is
24+
# undesirable.
25+
"$TARGET_DIR"/debug/miri-script "$@"

src/tools/miri/miri-script/src/commands.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -707,9 +707,12 @@ impl Command {
707707
let mut early_flags = Vec::<OsString>::new();
708708

709709
// In `dep` mode, the target is already passed via `MIRI_TEST_TARGET`
710-
if !dep && let Some(target) = &target {
711-
early_flags.push("--target".into());
712-
early_flags.push(target.into());
710+
#[expect(clippy::collapsible_if)] // we need to wait until this is stable
711+
if !dep {
712+
if let Some(target) = &target {
713+
early_flags.push("--target".into());
714+
early_flags.push(target.into());
715+
}
713716
}
714717
early_flags.push("--edition".into());
715718
early_flags.push(edition.as_deref().unwrap_or("2021").into());
@@ -737,8 +740,11 @@ impl Command {
737740
// Add Miri flags
738741
let mut cmd = cmd.args(&miri_flags).args(&early_flags).args(&flags);
739742
// For `--dep` we also need to set the target in the env var.
740-
if dep && let Some(target) = &target {
741-
cmd = cmd.env("MIRI_TEST_TARGET", target);
743+
#[expect(clippy::collapsible_if)] // we need to wait until this is stable
744+
if dep {
745+
if let Some(target) = &target {
746+
cmd = cmd.env("MIRI_TEST_TARGET", target);
747+
}
742748
}
743749
// Finally, run the thing.
744750
Ok(cmd.run()?)

src/tools/miri/miri.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ set MIRI_SCRIPT_TARGET_DIR=%0\..\miri-script\target
55

66
:: If any other steps are added, the "|| exit /b" must be appended to early
77
:: return from the script. If not, it will continue execution.
8-
cargo +nightly build %CARGO_EXTRA_FLAGS% -q --target-dir %MIRI_SCRIPT_TARGET_DIR% --manifest-path %0\..\miri-script\Cargo.toml ^
9-
|| (echo Failed to build miri-script. Is the 'nightly' toolchain installed? & exit /b)
8+
cargo +stable build %CARGO_EXTRA_FLAGS% -q --target-dir %MIRI_SCRIPT_TARGET_DIR% --manifest-path %0\..\miri-script\Cargo.toml ^
9+
|| (echo Failed to build miri-script. Is the 'stable' toolchain installed? & exit /b)
1010

1111
:: Forwards all arguments to this file to the executable.
1212
:: We invoke the binary directly to avoid going through rustup, which would set some extra

0 commit comments

Comments
 (0)