3939TARGET=$( rustc --version --verbose | grep " ^host:" | cut -d ' ' -f 2)
4040SYSROOT=$( rustc --print sysroot)
4141LIBDIR=$SYSROOT /lib/rustlib/$TARGET /lib
42+ MIRIDIR=$( readlink -e " $( dirname " $0 " ) " )
4243if ! test -d " $LIBDIR " ; then
4344 echo " Something went wrong determining the library dir."
4445 echo " I got $LIBDIR but that does not exist."
@@ -51,7 +52,7 @@ if [ -z "$CARGO_INCREMENTAL" ]; then
5152fi
5253if [ -z " $CARGO_TARGET_DIR " ]; then
5354 # Share target dir between `miri` and `cargo-miri`.
54- export CARGO_TARGET_DIR=" $( dirname " $0 " ) " /target
55+ export CARGO_TARGET_DIR=" $MIRIDIR /target"
5556fi
5657# We set the rpath so that Miri finds the private rustc libraries it needs.
5758# We enable debug-assertions to get tracing.
@@ -63,9 +64,9 @@ export RUSTFLAGS="-C link-args=-Wl,-rpath,$LIBDIR -C debug-assertions -C debugin
6364# Build a sysroot and set MIRI_SYSROOT to use it. Arguments are passed to `cargo miri setup`.
6465build_sysroot () {
6566 # Build once, for the user to see.
66- cargo run $CARGO_BUILD_FLAGS --manifest-path " $( dirname " $0 " ) " /cargo-miri/Cargo.toml -- miri setup " $@ "
67+ cargo run $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /cargo-miri/Cargo.toml -- miri setup " $@ "
6768 # Call again, to just set env var.
68- export MIRI_SYSROOT=" $( cargo run $CARGO_BUILD_FLAGS --manifest-path " $( dirname " $0 " ) " /cargo-miri/Cargo.toml -q -- miri setup --print-sysroot " $@ " ) "
69+ export MIRI_SYSROOT=" $( cargo run $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /cargo-miri/Cargo.toml -q -- miri setup --print-sysroot " $@ " ) "
6970}
7071
7172# Prepare and set MIRI_SYSROOT. Respects `MIRI_TEST_TARGET` and takes into account
@@ -108,18 +109,18 @@ case "$COMMAND" in
108109install|install-debug)
109110 # "--locked" to respect the Cargo.lock file if it exists,
110111 # "--offline" to avoid querying the registry (for yanked packages).
111- cargo install $CARGO_INSTALL_FLAGS --path " $( dirname " $0 " ) " --force --locked --offline " $@ "
112- cargo install $CARGO_INSTALL_FLAGS --path " $( dirname " $0 " ) " /cargo-miri --force --locked --offline " $@ "
112+ cargo install $CARGO_INSTALL_FLAGS --path " $MIRIDIR " --force --locked --offline " $@ "
113+ cargo install $CARGO_INSTALL_FLAGS --path " $MIRIDIR " /cargo-miri --force --locked --offline " $@ "
113114 ;;
114115check|check-debug)
115116 # Check, and let caller control flags.
116- cargo check $CARGO_BUILD_FLAGS --manifest-path " $( dirname " $0 " ) " /Cargo.toml " $@ "
117- cargo check $CARGO_BUILD_FLAGS --manifest-path " $( dirname " $0 " ) " /cargo-miri/Cargo.toml " $@ "
117+ cargo check $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /Cargo.toml " $@ "
118+ cargo check $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /cargo-miri/Cargo.toml " $@ "
118119 ;;
119120build|build-debug)
120121 # Build, and let caller control flags.
121- cargo build $CARGO_BUILD_FLAGS --manifest-path " $( dirname " $0 " ) " /Cargo.toml " $@ "
122- cargo build $CARGO_BUILD_FLAGS --manifest-path " $( dirname " $0 " ) " /cargo-miri/Cargo.toml " $@ "
122+ cargo build $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /Cargo.toml " $@ "
123+ cargo build $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /cargo-miri/Cargo.toml " $@ "
123124 ;;
124125test|test-debug)
125126 # First build and get a sysroot.
0 commit comments