Skip to content

Commit 3dcf655

Browse files
committed
readme: pull "common problems" into their own section
1 parent f77b292 commit 3dcf655

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

README.md

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,27 +54,43 @@ above:
5454

5555
1. Run `cargo clean` to eliminate any cached dependencies that were built against
5656
the non-MIR `libstd`.
57-
2. For a binary project, run `MIRI_SYSROOT=~/.xargo/HOST cargo +nightly miri` to
58-
build and run your project; for a binary or library, use `MIRI_SYSROOT=~/.xargo/HOST cargo +nightly miri test`
59-
to run all tests in your project through Miri.
57+
2. To run all tests in your project through, Miri, use
58+
`MIRI_SYSROOT=~/.xargo/HOST cargo +nightly miri test`.
59+
3. If you have a binary project, you can run it through Miri using
60+
`MIRI_SYSROOT=~/.xargo/HOST cargo +nightly miri`.
6061

61-
If you forget to set `MIRI_SYSROOT`, be sure to run `cargo clean` again before
62-
correcting it. Otherwise you are likely to get "dependency was built against possibly
63-
newer std" errors.
62+
### Common Problems
63+
64+
When modifying the above instructions, you may encounter a number of confusing compiler
65+
errors.
66+
67+
#### "constant evaluation error: no mir for `<function>`"
68+
69+
You may have forgotten to set `MIRI_SYSROOT` when calling `cargo miri test`, and
70+
your program called into `std` or `core`. Be sure to set `MIRI_SYSROOT=~/.xargo/HOST`.
71+
72+
#### "found possibly newer version of crate `std` which `<dependency>` depends on"
73+
74+
Your build directory may contain artifacts from an earlier build that did/did not
75+
have `MIRI_SYSROOT` set. Run `cargo clean` before switching from non-Miri to Miri
76+
builds and vice-versa.
77+
78+
#### "found crate `std` compiled by an incompatible version of rustc"
79+
80+
You may be running `cargo miri test` with a different compiler version than the one
81+
used to build the MIR-enabled `std`. Be sure to consistently use the same toolchain,
82+
perhaps by following the below instructions to specify a specific nightly for use
83+
with Miri.
6484

6585
## Using Rustup To Specify a Specific Nightly
6686

6787
To target a specific nightly, modify the above instructions as follows.
6888

6989
1. Install Miri using `cargo +nightly-2018-10-15 install --all-features --path .`,
7090
with the date replaced as appropriate.
71-
2. Run `xargo/build.sh` as `rustup run nightly-2018-10-15 build.sh`.
91+
2. Run `xargo/build.sh` as `rustup run nightly-2018-10-15 xargo/build.sh`.
7292
3. When running tests, use `MIRI_SYSROOT=~/.xargo/HOST cargo +nightly-2018-10-15 miri test`.
7393

74-
You may prefer to do this rather than depending on the rustup default toolchain,
75-
if you routinely update the default, since **it is essential that `xargo/build.sh`
76-
is run with the same toolchain as `cargo miri`.**
77-
7894
## Miri `-Z` flags
7995

8096
Miri adds some extra `-Z` flags to control its behavior:

0 commit comments

Comments
 (0)