Skip to content

Commit e71f8b0

Browse files
committed
fix ./miri run with MIRI_TEST_TARGET
1 parent c6f44c1 commit e71f8b0

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,9 @@ Moreover, Miri recognizes some environment variables:
418418
sysroot to use. Only set this if you do not want to use the automatically
419419
created sysroot. (The `miri` driver sysroot is controlled via the `--sysroot`
420420
flag instead.)
421-
* `MIRI_TEST_TARGET` (recognized by the test suite) indicates which target
422-
architecture to test against. `miri` and `cargo miri` accept the `--target`
423-
flag for the same purpose.
421+
* `MIRI_TEST_TARGET` (recognized by the test suite and the `./miri` script) indicates which target
422+
architecture to test against. `miri` and `cargo miri` accept the `--target` flag for the same
423+
purpose.
424424
* `MIRI_NO_STD` (recognized by `cargo miri` and the test suite) makes sure that the target's
425425
sysroot is built without libstd. This allows testing and running no_std programs.
426426
* `MIRI_BLESS` (recognized by the test suite) overwrite all `stderr` and `stdout` files

miri

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,21 @@ test|test-debug|bless|bless-debug)
167167
$CARGO test $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/ui_test/Cargo.toml "$@"
168168
;;
169169
run|run-debug)
170-
# Scan for "--target" to set the "MIRI_TEST_TARGET" env var so
170+
# Scan for "--target" to overwrite the "MIRI_TEST_TARGET" env var so
171171
# that we set the MIRI_SYSROOT up the right way.
172-
if [ -z "$MIRI_TEST_TARGET" ]; then
173-
for ARG in "$@"; do
174-
if [ "$LAST_ARG" = "--target" ]; then
175-
# Found it!
176-
export MIRI_TEST_TARGET="$ARG"
177-
break
178-
fi
179-
LAST_ARG="$ARG"
180-
done
172+
FOUND_TARGET_OPT=0
173+
for ARG in "$@"; do
174+
if [ "$LAST_ARG" = "--target" ]; then
175+
# Found it!
176+
export MIRI_TEST_TARGET="$ARG"
177+
FOUND_TARGET_OPT=1
178+
break
179+
fi
180+
LAST_ARG="$ARG"
181+
done
182+
if [ "$FOUND_TARGET_OPT" = "0" ] && [ -n "$MIRI_TEST_TARGET" ]; then
183+
# Make sure Miri actually uses this target.
184+
MIRIFLAGS="$MIRIFLAGS --target $MIRI_TEST_TARGET"
181185
fi
182186
# First build and get a sysroot.
183187
$CARGO build $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml

0 commit comments

Comments
 (0)