diff options
Diffstat (limited to 'src/tools/miri/miri')
| -rwxr-xr-x | src/tools/miri/miri | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/tools/miri/miri b/src/tools/miri/miri index b1b146d7990..a5f2bb1550a 100755 --- a/src/tools/miri/miri +++ b/src/tools/miri/miri @@ -2,20 +2,25 @@ 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:-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 "$@" |
