@@ -5,14 +5,14 @@ USAGE=$(cat <<"EOF"
5
5
6
6
./miri install <flags>:
7
7
Installs the miri driver and cargo-miri. <flags> are passed to `cargo
8
- install`. Sets up the rpath such that the installed binary should work in any
8
+ install`. Sets up the rpath such that the installed binary should work in any
9
9
working directory.
10
10
11
11
./miri build <flags>:
12
- Just build miri. <flags> are passed to `cargo build`.
12
+ Just build miri. <flags> are passed to `cargo build`.
13
13
14
14
./miri check <flags>:
15
- Just check miri. <flags> are passed to `cargo check`.
15
+ Just check miri. <flags> are passed to `cargo check`.
16
16
17
17
./miri test <flags>:
18
18
Build miri, set up a sysroot and then run the test suite. <flags> are passed
@@ -26,10 +26,10 @@ The commands above also exist in a "-debug" variant (e.g. "./miri run-debug
26
26
times and slower execution times.
27
27
28
28
./miri fmt <flags>:
29
- Format all sources and tests. <flags> are passed to `rustfmt`.
29
+ Format all sources and tests. <flags> are passed to `rustfmt`.
30
30
31
31
./miri clippy <flags>:
32
- Format all sources and tests. <flags> are passed to `cargo clippy`.
32
+ Format all sources and tests. <flags> are passed to `cargo clippy`.
33
33
34
34
ENVIRONMENT VARIABLES
35
35
42
42
)
43
43
44
44
# # Preparation
45
- TARGET=$( rustc --version --verbose | grep " ^host:" | cut -d ' ' -f 2)
46
- SYSROOT=$( rustc --print sysroot)
47
- LIBDIR=$SYSROOT /lib/rustlib/$TARGET /lib
48
45
# macOS does not have a useful readlink/realpath so we have to use Python instead...
49
46
MIRIDIR=$( dirname " $( python3 -c ' import os, sys; print(os.path.realpath(sys.argv[1]))' " $0 " ) " )
47
+ # Determine toolchain *in the Miri dir* and use that.
48
+ TOOLCHAIN=$( cd " $MIRIDIR " ; rustup show active-toolchain | head -n 1 | cut -d ' ' -f 1)
49
+ # Determine some toolchain properties
50
+ TARGET=$( rustc +$TOOLCHAIN --version --verbose | grep " ^host:" | cut -d ' ' -f 2)
51
+ SYSROOT=$( rustc +$TOOLCHAIN --print sysroot)
52
+ LIBDIR=$SYSROOT /lib/rustlib/$TARGET /lib
53
+
50
54
if ! test -d " $LIBDIR " ; then
51
55
echo " Something went wrong determining the library dir."
52
56
echo " I got $LIBDIR but that does not exist."
53
57
echo " Please report a bug at https://github.com/rust-lang/miri/issues."
54
58
exit 2
55
59
fi
60
+
61
+ CARGO=" cargo +$TOOLCHAIN "
56
62
if [ -z " $CARGO_INCREMENTAL " ]; then
57
63
# Default CARGO_INCREMENTAL to 1.
58
64
export CARGO_INCREMENTAL=1
@@ -68,15 +74,15 @@ export RUSTFLAGS="-C link-args=-Wl,-rpath,$LIBDIR -C debug-assertions -C debugin
68
74
69
75
# # Helper functions
70
76
71
- # Build a sysroot and set MIRI_SYSROOT to use it. Arguments are passed to `cargo miri setup`.
77
+ # Build a sysroot and set MIRI_SYSROOT to use it. Arguments are passed to `cargo miri setup`.
72
78
build_sysroot () {
73
79
# Build once, for the user to see.
74
- cargo run $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /cargo-miri/Cargo.toml -- miri setup " $@ "
80
+ $CARGO run $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /cargo-miri/Cargo.toml -- miri setup " $@ "
75
81
# Call again, to just set env var.
76
- export MIRI_SYSROOT=" $( cargo run $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /cargo-miri/Cargo.toml -q -- miri setup --print-sysroot " $@ " ) "
82
+ export MIRI_SYSROOT=" $( $CARGO run $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /cargo-miri/Cargo.toml -q -- miri setup --print-sysroot " $@ " ) "
77
83
}
78
84
79
- # Prepare and set MIRI_SYSROOT. Respects `MIRI_TEST_TARGET` and takes into account
85
+ # Prepare and set MIRI_SYSROOT. Respects `MIRI_TEST_TARGET` and takes into account
80
86
# locally built vs. distributed rustc.
81
87
find_sysroot () {
82
88
if [ -n " $MIRI_SYSROOT " ]; then
@@ -116,22 +122,22 @@ case "$COMMAND" in
116
122
install|install-debug)
117
123
# "--locked" to respect the Cargo.lock file if it exists,
118
124
# "--offline" to avoid querying the registry (for yanked packages).
119
- cargo install $CARGO_INSTALL_FLAGS --path " $MIRIDIR " --force --locked --offline " $@ "
120
- cargo install $CARGO_INSTALL_FLAGS --path " $MIRIDIR " /cargo-miri --force --locked --offline " $@ "
125
+ $CARGO install $CARGO_INSTALL_FLAGS --path " $MIRIDIR " --force --locked --offline " $@ "
126
+ $CARGO install $CARGO_INSTALL_FLAGS --path " $MIRIDIR " /cargo-miri --force --locked --offline " $@ "
121
127
;;
122
128
check|check-debug)
123
129
# Check, and let caller control flags.
124
- cargo check $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /Cargo.toml --all-targets " $@ "
125
- cargo check $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /cargo-miri/Cargo.toml " $@ "
130
+ $CARGO check $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /Cargo.toml --all-targets " $@ "
131
+ $CARGO check $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /cargo-miri/Cargo.toml " $@ "
126
132
;;
127
133
build|build-debug)
128
134
# Build, and let caller control flags.
129
- cargo build $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /Cargo.toml " $@ "
130
- cargo build $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /cargo-miri/Cargo.toml " $@ "
135
+ $CARGO build $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /Cargo.toml " $@ "
136
+ $CARGO build $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /cargo-miri/Cargo.toml " $@ "
131
137
;;
132
138
test|test-debug|bless|bless-debug)
133
139
# First build and get a sysroot.
134
- cargo build $CARGO_BUILD_FLAGS
140
+ $CARGO build $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /Cargo.toml
135
141
find_sysroot
136
142
case " $COMMAND " in
137
143
bless|bless-debug)
@@ -140,8 +146,8 @@ test|test-debug|bless|bless-debug)
140
146
esac
141
147
# Then test, and let caller control flags.
142
148
# Only in root project and ui_test as `cargo-miri` has no tests.
143
- cargo test $CARGO_BUILD_FLAGS " $@ "
144
- cargo test $CARGO_BUILD_FLAGS --manifest-path ui_test/Cargo.toml " $@ "
149
+ $CARGO test $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /Cargo.toml " $@ "
150
+ $CARGO test $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " / ui_test/Cargo.toml " $@ "
145
151
;;
146
152
run|run-debug)
147
153
# Scan for "--target" to set the "MIRI_TEST_TARGET" env var so
@@ -157,19 +163,19 @@ run|run-debug)
157
163
done
158
164
fi
159
165
# First build and get a sysroot.
160
- cargo build $CARGO_BUILD_FLAGS
166
+ $CARGO build $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /Cargo.toml
161
167
find_sysroot
162
168
# Then run the actual command.
163
- exec cargo run $CARGO_BUILD_FLAGS -- --sysroot " $MIRI_SYSROOT " " $@ "
169
+ exec $CARGO run $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /Cargo.toml -- --sysroot " $MIRI_SYSROOT " " $@ "
164
170
;;
165
171
fmt)
166
172
find " $MIRIDIR " -not \( -name target -prune \) -name ' *.rs' \
167
- | xargs rustfmt --edition=2021 --config-path " $MIRIDIR /rustfmt.toml" " $@ "
173
+ | xargs rustfmt + $TOOLCHAIN --edition=2021 --config-path " $MIRIDIR /rustfmt.toml" " $@ "
168
174
;;
169
175
clippy)
170
- cargo clippy $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /Cargo.toml --all-targets " $@ "
171
- cargo clippy $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /ui_test/Cargo.toml --all-targets " $@ "
172
- cargo clippy $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /cargo-miri/Cargo.toml " $@ "
176
+ $CARGO clippy $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /Cargo.toml --all-targets " $@ "
177
+ $CARGO clippy $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /ui_test/Cargo.toml --all-targets " $@ "
178
+ $CARGO clippy $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /cargo-miri/Cargo.toml " $@ "
173
179
;;
174
180
* )
175
181
if [ -n " $COMMAND " ]; then
0 commit comments