diff options
| author | Ralf Jung <post@ralfj.de> | 2024-11-18 21:01:11 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-11-18 21:01:11 +0100 |
| commit | aada9efde8d39d458eb399ac347e633873983aca (patch) | |
| tree | b6a596a7c6ceab4fb961b0e941e5ce196d5a3bef | |
| parent | 34ad8de02d6283b81b608b1915e8c37bbd1fe764 (diff) | |
| download | rust-aada9efde8d39d458eb399ac347e633873983aca.tar.gz rust-aada9efde8d39d458eb399ac347e633873983aca.zip | |
use -Zroot-dir instead of --remap-path-prefix for diagnostic dir handling
| -rw-r--r-- | src/tools/miri/.cargo/config.toml | 9 | ||||
| -rwxr-xr-x | src/tools/miri/miri | 8 | ||||
| -rw-r--r-- | src/tools/miri/miri-script/src/util.rs | 4 |
3 files changed, 8 insertions, 13 deletions
diff --git a/src/tools/miri/.cargo/config.toml b/src/tools/miri/.cargo/config.toml deleted file mode 100644 index 42e7c2c4818..00000000000 --- a/src/tools/miri/.cargo/config.toml +++ /dev/null @@ -1,9 +0,0 @@ -[unstable] -profile-rustflags = true - -# Add back the containing directory of the packages we have to refer to using --manifest-path. -# Per-package profiles avoid adding this to build dependencies. -[profile.dev.package."cargo-miri"] -rustflags = ["--remap-path-prefix", "=cargo-miri"] -[profile.dev.package."miri-script"] -rustflags = ["--remap-path-prefix", "=miri-script"] diff --git a/src/tools/miri/miri b/src/tools/miri/miri index 5d07ad9e249..ac1a7211c4e 100755 --- a/src/tools/miri/miri +++ b/src/tools/miri/miri @@ -1,13 +1,15 @@ #!/usr/bin/env bash set -e # We want to call the binary directly, so we need to know where it ends up. -MIRI_SCRIPT_TARGET_DIR="$(dirname "$0")"/miri-script/target +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 MESSAGE_FORMAT="--message-format=json" fi -# We need a nightly toolchain, for the `profile-rustflags` cargo feature. -cargo +nightly build $CARGO_EXTRA_FLAGS --manifest-path "$(dirname "$0")"/miri-script/Cargo.toml \ +# We need a nightly toolchain, for `-Zroot-dir`. +cargo +nightly 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 diff --git a/src/tools/miri/miri-script/src/util.rs b/src/tools/miri/miri-script/src/util.rs index e6e85747d4d..cf6529d8373 100644 --- a/src/tools/miri/miri-script/src/util.rs +++ b/src/tools/miri/miri-script/src/util.rs @@ -105,7 +105,7 @@ impl MiriEnv { // Get extra flags for cargo. let cargo_extra_flags = std::env::var("CARGO_EXTRA_FLAGS").unwrap_or_default(); - let cargo_extra_flags = flagsplit(&cargo_extra_flags); + let mut cargo_extra_flags = flagsplit(&cargo_extra_flags); if cargo_extra_flags.iter().any(|a| a == "--release" || a.starts_with("--profile")) { // This makes binaries end up in different paths, let's not do that. eprintln!( @@ -113,6 +113,8 @@ impl MiriEnv { ); std::process::exit(1); } + // Also set `-Zroot-dir` for cargo, to print diagnostics relative to the miri dir. + cargo_extra_flags.push(format!("-Zroot-dir={}", miri_dir.display())); Ok(MiriEnv { miri_dir, toolchain, sh, sysroot, cargo_extra_flags, libdir }) } |
