Skip to content

Commit

Permalink
adjust the way we build miri-script in RA, to fix proc-macros
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Jan 11, 2025
1 parent bd99bc7 commit fe9bc05
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
10 changes: 4 additions & 6 deletions etc/rust_analyzer_vscode.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,19 @@
"cargo-miri/Cargo.toml",
"miri-script/Cargo.toml",
],
"rust-analyzer.check.invocationLocation": "root",
"rust-analyzer.check.invocationStrategy": "once",
"rust-analyzer.check.overrideCommand": [
"env",
"MIRI_AUTO_OPS=no",
"./miri",
"clippy", // make this `check` when working with a locally built rustc
"--message-format=json",
],
"rust-analyzer.cargo.extraEnv": {
"MIRI_AUTO_OPS": "no",
"MIRI_IN_RA": "1",
},
// Contrary to what the name suggests, this also affects proc macros.
"rust-analyzer.cargo.buildScripts.invocationLocation": "root",
"rust-analyzer.cargo.buildScripts.invocationStrategy": "once",
"rust-analyzer.cargo.buildScripts.overrideCommand": [
"env",
"MIRI_AUTO_OPS=no",
"./miri",
"check",
"--message-format=json",
Expand Down
10 changes: 7 additions & 3 deletions miri
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ 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
# If stdout is not a terminal and we are not on CI, assume that we are being invoked by RA, and use JSON output.
if ! [ -t 1 ] && [ -z "$CI" ]; then
TOOLCHAIN="+nightly"
# 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.
if [ -n "$MIRI_IN_RA" ]; then
MESSAGE_FORMAT="--message-format=json"
TOOLCHAIN=""
MIRI_SCRIPT_TARGET_DIR="$ROOT_DIR"/miri-script/target/ra
fi
# We need a nightly toolchain, for `-Zroot-dir`.
cargo +nightly build $CARGO_EXTRA_FLAGS --manifest-path "$ROOT_DIR"/miri-script/Cargo.toml \
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 )
Expand Down

0 comments on commit fe9bc05

Please sign in to comment.