Skip to content

Commit 78fdd59

Browse files
authored
Merge pull request rust-lang#4134 from RalfJung/miri-script-ra
adjust the way we build miri-script in RA, to fix proc-macros
2 parents fcb64d3 + 4221765 commit 78fdd59

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

src/tools/miri/etc/rust_analyzer_vscode.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,19 @@
55
"cargo-miri/Cargo.toml",
66
"miri-script/Cargo.toml",
77
],
8-
"rust-analyzer.check.invocationLocation": "root",
98
"rust-analyzer.check.invocationStrategy": "once",
109
"rust-analyzer.check.overrideCommand": [
11-
"env",
12-
"MIRI_AUTO_OPS=no",
1310
"./miri",
1411
"clippy", // make this `check` when working with a locally built rustc
1512
"--message-format=json",
1613
],
14+
"rust-analyzer.cargo.extraEnv": {
15+
"MIRI_AUTO_OPS": "no",
16+
"MIRI_IN_RA": "1",
17+
},
1718
// Contrary to what the name suggests, this also affects proc macros.
18-
"rust-analyzer.cargo.buildScripts.invocationLocation": "root",
1919
"rust-analyzer.cargo.buildScripts.invocationStrategy": "once",
2020
"rust-analyzer.cargo.buildScripts.overrideCommand": [
21-
"env",
22-
"MIRI_AUTO_OPS=no",
2321
"./miri",
2422
"check",
2523
"--message-format=json",

src/tools/miri/miri

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ set -e
33
# We want to call the binary directly, so we need to know where it ends up.
44
ROOT_DIR="$(dirname "$0")"
55
MIRI_SCRIPT_TARGET_DIR="$ROOT_DIR"/miri-script/target
6-
# If stdout is not a terminal and we are not on CI, assume that we are being invoked by RA, and use JSON output.
7-
if ! [ -t 1 ] && [ -z "$CI" ]; then
6+
TOOLCHAIN="+nightly"
7+
# If we are being invoked for RA, use JSON output and the default toolchain (to make proc-macros
8+
# work in RA). This needs a different target dir to avoid mixing up the builds.
9+
if [ -n "$MIRI_IN_RA" ]; then
810
MESSAGE_FORMAT="--message-format=json"
11+
TOOLCHAIN=""
12+
MIRI_SCRIPT_TARGET_DIR="$MIRI_SCRIPT_TARGET_DIR"/ra
913
fi
1014
# We need a nightly toolchain, for `-Zroot-dir`.
11-
cargo +nightly build $CARGO_EXTRA_FLAGS --manifest-path "$ROOT_DIR"/miri-script/Cargo.toml \
15+
cargo $TOOLCHAIN build $CARGO_EXTRA_FLAGS --manifest-path "$ROOT_DIR"/miri-script/Cargo.toml \
1216
-Zroot-dir="$ROOT_DIR" \
1317
-q --target-dir "$MIRI_SCRIPT_TARGET_DIR" $MESSAGE_FORMAT || \
1418
( echo "Failed to build miri-script. Is the 'nightly' toolchain installed?"; exit 1 )

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,10 @@ impl Command {
564564
if bless {
565565
e.sh.set_var("RUSTC_BLESS", "Gesundheit");
566566
}
567+
if e.sh.var("MIRI_TEST_TARGET").is_ok() {
568+
// Avoid trouble due to an incorrectly set env var.
569+
bail!("MIRI_TEST_TARGET must not be set when invoking `./miri test`");
570+
}
567571
if let Some(target) = target {
568572
// Tell the harness which target to test.
569573
e.sh.set_var("MIRI_TEST_TARGET", target);

0 commit comments

Comments
 (0)