Skip to content

Commit 6420293

Browse files
committed
adjust readme to miri build script
1 parent c2791fc commit 6420293

File tree

1 file changed

+11
-36
lines changed

1 file changed

+11
-36
lines changed

README.md

Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -141,42 +141,28 @@ version of `rustc` that, instead of compiling your code, runs it. It accepts
141141
all the same flags as `rustc` (though the ones only affecting code generation
142142
and linking obviously will have no effect) [and more][miri-flags].
143143

144-
To run the Miri driver, you need to have the `MIRI_SYSROOT` environment variable
145-
set to an appropriate sysroot. You can generate such a sysroot with the
146-
following incantation:
147-
148-
```
149-
cargo run --bin cargo-miri -- miri setup
150-
```
151-
152-
This basically runs the `cargo-miri` binary (which backs the `cargo miri`
153-
subcommand) with `cargo`, and asks it to `setup`. It should in the end print
154-
the directory where the libstd was built. In the following, we will assume it
155-
is `~/.cache/miri/HOST`; you may have to adjust that if you are not using Linux.
156-
157-
Now you can run the driver directly using
144+
Running the Miri driver requires some fiddling with environment variables, so the `miri` script helps you do that.
145+
For example, you can run the driver on a particular file by doing
158146

159147
```sh
160-
MIRI_SYSROOT=~/.cache/miri/HOST cargo run tests/run-pass/format.rs # or whatever test you like
148+
./miri run tests/run-pass/format.rs # or whatever test you like
161149
```
162150

163151
and you can run the test suite using
164152

165153
```
166-
cargo test
154+
./miri test
167155
```
168156

169-
We recommend adding the `--release` flag to make tests run faster.
170-
171-
`cargo test --release FILTER` only runs those tests that contain `FILTER` in
172-
their filename (including the base directory, e.g. `cargo test --release fail`
173-
will run all compile-fail tests).
157+
`./miri test FILTER` only runs those tests that contain `FILTER` in their
158+
filename (including the base directory, e.g. `./miri test fail` will run all
159+
compile-fail tests).
174160

175161
You can get a trace of which MIR statements are being executed by setting the
176162
`MIRI_LOG` environment variable. For example:
177163

178164
```sh
179-
MIRI_LOG=info cargo run tests/run-pass/vecs.rs
165+
MIRI_LOG=info ./miri run tests/run-pass/vecs.rs
180166
```
181167

182168
Setting `MIRI_LOG` like this will configure logging for Miri itself as well as
@@ -185,7 +171,7 @@ can also do more targeted configuration, e.g. the following helps debug the
185171
stacked borrows implementation:
186172

187173
```sh
188-
MIRI_LOG=rustc_mir::interpret=info,miri::stacked_borrows cargo run tests/run-pass/vecs.rs
174+
MIRI_LOG=rustc_mir::interpret=info,miri::stacked_borrows ./miri run tests/run-pass/vecs.rs
189175
```
190176

191177
In addition, you can set `MIRI_BACKTRACE=1` to get a backtrace of where an
@@ -199,7 +185,7 @@ is probably easier to test it with the cargo wrapper. You can install your
199185
development version of Miri using
200186

201187
```
202-
cargo install --path . --force
188+
./miri install
203189
```
204190

205191
and then you can use it as if it was installed by `rustup`. Make sure you use
@@ -235,18 +221,7 @@ rustup override set custom
235221
```
236222

237223
With this, you should now have a working development setup! See
238-
[above][testing-miri] for how to proceed working with the Miri driver. Notice
239-
that rustc's sysroot is already built for Miri in this case, so you can set
240-
`MIRI_SYSROOT=$(rustc --print sysroot)`.
241-
242-
Running `cargo miri` in this setup is a bit more complicated, because the Miri
243-
binary you just created needs help to find the libraries it links against. On
244-
Linux, you can set the rpath to make this "just work":
245-
246-
```sh
247-
export RUSTFLAGS="-C link-args=-Wl,-rpath,$(rustc --print sysroot)/lib/rustlib/x86_64-unknown-linux-gnu/lib"
248-
cargo install --path . --force
249-
```
224+
[above][testing-miri] for how to proceed working with the Miri driver.
250225

251226
### Miri `-Z` flags and environment variables
252227
[miri-flags]: #miri--z-flags-and-environment-variables

0 commit comments

Comments
 (0)