Skip to content

Commit 90dac3d

Browse files
committed
update README to suggest installing Miri as a component
1 parent 1d75825 commit 90dac3d

File tree

1 file changed

+13
-23
lines changed

1 file changed

+13
-23
lines changed

README.md

+13-23
Original file line numberDiff line numberDiff line change
@@ -27,42 +27,31 @@ list!
2727

2828
## Running Miri on your own project (and its test suite)
2929

30-
Install Miri as a cargo subcommand:
30+
Install Miri via `rustup`:
3131

3232
```sh
33-
cargo +nightly install --force --git https://github.com/rust-lang/miri miri
33+
rustup component add miri
3434
```
3535

36-
If this does not work, try using the nightly version given in
37-
[this file](https://raw.githubusercontent.com/rust-lang/miri/master/rust-version). CI
38-
should ensure that this nightly always works.
39-
40-
You have to use a consistent Rust version for building miri and your project, so
41-
remember to either always specify the nightly version manually (like in the
42-
example above), overriding it in your project directory as well, or use `rustup
43-
default nightly` (or `rustup default nightly-YYYY-MM-DD`) to globally make
44-
`nightly` the default toolchain.
45-
4636
Now you can run your project in Miri:
4737

4838
1. Run `cargo clean` to eliminate any cached dependencies. Miri needs your
4939
dependencies to be compiled the right way, that would not happen if they have
5040
previously already been compiled.
51-
2. To run all tests in your project through Miri, use `cargo +nightly miri test`.
52-
3. If you have a binary project, you can run it through Miri using `cargo
53-
+nightly miri run`.
41+
2. To run all tests in your project through Miri, use `cargo miri test`.
42+
3. If you have a binary project, you can run it through Miri using `cargo miri run`.
5443

5544
The first time you run Miri, it will perform some extra setup and install some
5645
dependencies. It will ask you for confirmation before installing anything. If
57-
you run Miri on CI, run `cargo +nightly miri setup` to avoid getting interactive
46+
you run Miri on CI, run `cargo miri setup` to avoid getting interactive
5847
questions.
5948

6049
You can pass arguments to Miri after the first `--`, and pass arguments to the
6150
interpreted program or test suite after the second `--`. For example, `cargo
62-
+nightly miri run -- -Zmiri-disable-validation` runs the program without
63-
validation of basic type invariants and references. `cargo +nightly miri test
64-
-- -- -Zunstable-options --exclude-should-panic` skips `#[should_panic]` tests,
65-
which is a good idea because Miri does not support unwinding or catching panics.
51+
miri run -- -Zmiri-disable-validation` runs the program without validation of
52+
basic type invariants and references. `cargo miri test -- -- -Zunstable-options
53+
--exclude-should-panic` skips `#[should_panic]` tests, which is a good idea
54+
because Miri does not support unwinding or catching panics.
6655

6756
When running code via `cargo miri`, the `miri` config flag is set. You can
6857
use this to exclude test cases that will fail under Miri because they do things
@@ -110,10 +99,14 @@ convenient way is to install Miri using cargo, then you can easily run it on
11099
other projects:
111100

112101
```sh
102+
rustup component remove miri # avoid having Miri installed twice
113103
cargo +nightly install --path "$DIR" --force # or the nightly in `rust-version`
114104
cargo +nightly miri setup
115105
```
116106

107+
(We are giving `+nightly` explicitly here all the time because it is important
108+
that all of these commands get executed with the same toolchain.)
109+
117110
If you want to use a different libstd (not the one that comes with the
118111
nightly), you can do that by running
119112

@@ -124,9 +117,6 @@ XARGO_RUST_SRC=~/src/rust/rustc/src/ cargo +nightly miri setup
124117
Either way, you can now do `cargo +nightly miri run` to run Miri with your
125118
local changes on whatever project you are debugging.
126119

127-
(We are giving `+nightly` explicitly here all the time because it is important
128-
that all of these commands get executed with the same toolchain.)
129-
130120
`cargo miri setup` should end in printing the directory where the libstd was
131121
built. For the next step to work, set that as your `MIRI_SYSROOT` environment
132122
variable:

0 commit comments

Comments
 (0)