@@ -6,7 +6,8 @@ USAGE=$(cat <<"EOF"
6
6
./miri install <flags>:
7
7
Installs the miri driver and cargo-miri. <flags> are passed to `cargo
8
8
install`. Sets up the rpath such that the installed binary should work in any
9
- working directory.
9
+ working directory. However, the rustup toolchain when invoking `cargo miri`
10
+ needs to be the same one used for `./miri install`.
10
11
11
12
./miri build <flags>:
12
13
Just build miri. <flags> are passed to `cargo build`.
@@ -22,10 +23,6 @@ to the final `cargo test` invocation.
22
23
Build miri, set up a sysroot and then run the driver with the given <flags>.
23
24
(Also respects MIRIFLAGS environment variable.)
24
25
25
- The commands above also exist in a "-debug" variant (e.g. "./miri run-debug
26
- <flags>") which uses debug builds instead of release builds, for faster build
27
- times and slower execution times.
28
-
29
26
./miri fmt <flags>:
30
27
Format all sources and tests. <flags> are passed to `rustfmt`.
31
28
99
96
100
97
# Prepare flags for cargo and rustc.
101
98
CARGO=" cargo +$TOOLCHAIN "
102
- if [ -z " $CARGO_INCREMENTAL " ]; then
103
- # Default CARGO_INCREMENTAL to 1.
104
- export CARGO_INCREMENTAL=1
105
- fi
106
99
if [ -z " $CARGO_TARGET_DIR " ]; then
107
100
# Share target dir between `miri` and `cargo-miri`.
108
101
export CARGO_TARGET_DIR=" $MIRIDIR /target"
109
102
fi
110
103
# We set the rpath so that Miri finds the private rustc libraries it needs.
111
- # We enable debug-assertions to get tracing.
112
- # We enable line-only debuginfo for backtraces.
113
- export RUSTFLAGS=" -C link-args=-Wl,-rpath,$LIBDIR -C debug-assertions -C debuginfo=1 $RUSTFLAGS "
114
- # Determine flags passed to all cargo invocations.
115
- # This is a bit more annoying that one would hope due to
116
- # <https://github.com/rust-lang/cargo/issues/6992>.
117
- case " $COMMAND " in
118
- * -debug)
119
- CARGO_INSTALL_FLAGS=" --target $TARGET --debug $CARGO_EXTRA_FLAGS "
120
- CARGO_BUILD_FLAGS=" --target $TARGET $CARGO_EXTRA_FLAGS "
121
- ;;
122
- * )
123
- CARGO_INSTALL_FLAGS=" --target $TARGET $CARGO_EXTRA_FLAGS "
124
- CARGO_BUILD_FLAGS=" --target $TARGET --release $CARGO_EXTRA_FLAGS "
125
- ;;
126
- esac
104
+ export RUSTFLAGS=" -C link-args=-Wl,-rpath,$LIBDIR $RUSTFLAGS "
127
105
128
106
# # Helper functions
129
107
130
108
# Build a sysroot and set MIRI_SYSROOT to use it. Arguments are passed to `cargo miri setup`.
131
109
build_sysroot () {
132
110
# Build once, for the user to see.
133
- $CARGO run $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /cargo-miri/Cargo.toml -- miri setup " $@ "
111
+ $CARGO run $CARGO_EXTRA_FLAGS --manifest-path " $MIRIDIR " /cargo-miri/Cargo.toml -- miri setup " $@ "
134
112
# Call again, to just set env var.
135
- export MIRI_SYSROOT=" $( $CARGO run $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /cargo-miri/Cargo.toml -q -- miri setup --print-sysroot " $@ " ) "
113
+ export MIRI_SYSROOT=" $( $CARGO run $CARGO_EXTRA_FLAGS --manifest-path " $MIRIDIR " /cargo-miri/Cargo.toml -q -- miri setup --print-sysroot " $@ " ) "
136
114
}
137
115
138
116
# Prepare and set MIRI_SYSROOT. Respects `MIRI_TEST_TARGET` and takes into account
@@ -154,37 +132,35 @@ find_sysroot() {
154
132
155
133
# Run command.
156
134
case " $COMMAND " in
157
- install|install-debug )
135
+ install)
158
136
# "--locked" to respect the Cargo.lock file if it exists,
159
137
# "--offline" to avoid querying the registry (for yanked packages).
160
- $CARGO install $CARGO_INSTALL_FLAGS --path " $MIRIDIR " --force --locked --offline " $@ "
161
- $CARGO install $CARGO_INSTALL_FLAGS --path " $MIRIDIR " /cargo-miri --force --locked --offline " $@ "
138
+ $CARGO install $CARGO_EXTRA_FLAGS --path " $MIRIDIR " --force --locked --offline " $@ "
139
+ $CARGO install $CARGO_EXTRA_FLAGS --path " $MIRIDIR " /cargo-miri --force --locked --offline " $@ "
162
140
;;
163
- check|check-debug )
141
+ check)
164
142
# Check, and let caller control flags.
165
- $CARGO check $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /Cargo.toml --all-targets " $@ "
166
- $CARGO check $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /cargo-miri/Cargo.toml " $@ "
143
+ $CARGO check $CARGO_EXTRA_FLAGS --manifest-path " $MIRIDIR " /Cargo.toml --all-targets " $@ "
144
+ $CARGO check $CARGO_EXTRA_FLAGS --manifest-path " $MIRIDIR " /cargo-miri/Cargo.toml " $@ "
167
145
;;
168
- build|build-debug )
146
+ build)
169
147
# Build, and let caller control flags.
170
- $CARGO build $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /Cargo.toml " $@ "
171
- $CARGO build $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /cargo-miri/Cargo.toml " $@ "
148
+ $CARGO build $CARGO_EXTRA_FLAGS --manifest-path " $MIRIDIR " /Cargo.toml " $@ "
149
+ $CARGO build $CARGO_EXTRA_FLAGS --manifest-path " $MIRIDIR " /cargo-miri/Cargo.toml " $@ "
172
150
;;
173
- test|test-debug| bless|bless-debug )
151
+ test|bless)
174
152
# First build and get a sysroot.
175
- $CARGO build $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /Cargo.toml
153
+ $CARGO build $CARGO_EXTRA_FLAGS --manifest-path " $MIRIDIR " /Cargo.toml
176
154
find_sysroot
177
- case " $COMMAND " in
178
- bless|bless-debug)
155
+ if [ " $COMMAND " = " bless" ]; then
179
156
export MIRI_BLESS=" Gesundheit"
180
- ;;
181
- esac
157
+ fi
182
158
# Then test, and let caller control flags.
183
159
# Only in root project and ui_test as `cargo-miri` has no tests.
184
- $CARGO test $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /Cargo.toml " $@ "
185
- $CARGO test $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /ui_test/Cargo.toml " $@ "
160
+ $CARGO test $CARGO_EXTRA_FLAGS --manifest-path " $MIRIDIR " /Cargo.toml " $@ "
161
+ $CARGO test $CARGO_EXTRA_FLAGS --manifest-path " $MIRIDIR " /ui_test/Cargo.toml " $@ "
186
162
;;
187
- run|run-debug )
163
+ run)
188
164
# Scan for "--target" to overwrite the "MIRI_TEST_TARGET" env var so
189
165
# that we set the MIRI_SYSROOT up the right way.
190
166
FOUND_TARGET_OPT=0
@@ -202,19 +178,19 @@ run|run-debug)
202
178
MIRIFLAGS=" $MIRIFLAGS --target $MIRI_TEST_TARGET "
203
179
fi
204
180
# First build and get a sysroot.
205
- $CARGO build $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /Cargo.toml
181
+ $CARGO build $CARGO_EXTRA_FLAGS --manifest-path " $MIRIDIR " /Cargo.toml
206
182
find_sysroot
207
183
# Then run the actual command.
208
- exec $CARGO run $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /Cargo.toml -- --sysroot " $MIRI_SYSROOT " $MIRIFLAGS " $@ "
184
+ exec $CARGO run $CARGO_EXTRA_FLAGS --manifest-path " $MIRIDIR " /Cargo.toml -- --sysroot " $MIRI_SYSROOT " $MIRIFLAGS " $@ "
209
185
;;
210
186
fmt)
211
187
find " $MIRIDIR " -not \( -name target -prune \) -name ' *.rs' \
212
188
| xargs rustfmt +$TOOLCHAIN --edition=2021 --config-path " $MIRIDIR /rustfmt.toml" " $@ "
213
189
;;
214
190
clippy)
215
- $CARGO clippy $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /Cargo.toml --all-targets " $@ "
216
- $CARGO clippy $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /ui_test/Cargo.toml --all-targets " $@ "
217
- $CARGO clippy $CARGO_BUILD_FLAGS --manifest-path " $MIRIDIR " /cargo-miri/Cargo.toml " $@ "
191
+ $CARGO clippy $CARGO_EXTRA_FLAGS --manifest-path " $MIRIDIR " /Cargo.toml --all-targets " $@ "
192
+ $CARGO clippy $CARGO_EXTRA_FLAGS --manifest-path " $MIRIDIR " /ui_test/Cargo.toml --all-targets " $@ "
193
+ $CARGO clippy $CARGO_EXTRA_FLAGS --manifest-path " $MIRIDIR " /cargo-miri/Cargo.toml " $@ "
218
194
;;
219
195
* )
220
196
if [ -n " $COMMAND " ]; then
0 commit comments