Skip to content

Commit 1cbed5c

Browse files
authored
Merge pull request #483 from apoelstra/2018-10-readme
improve README instructions for using `rustup` and for compiling separate crates
2 parents 25d7e19 + 5347411 commit 1cbed5c

File tree

4 files changed

+44
-17
lines changed

4 files changed

+44
-17
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ before_script:
1818
if [ "$TRAVIS_EVENT_TYPE" = cron ]; then
1919
RUST_TOOLCHAIN=nightly
2020
else
21-
RUST_TOOLCHAIN=$(cat rust-toolchain)
21+
RUST_TOOLCHAIN=$(cat rust-version)
2222
fi
23-
- rm rust-toolchain
2423
# install Rust
2524
- curl https://build.travis-ci.org/files/rustup-init.sh -sSf | sh -s -- -y --default-toolchain "$RUST_TOOLCHAIN"
2625
- export PATH=$HOME/.cargo/bin:$PATH

README.md

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,19 @@ undergraduate research course at the [University of Saskatchewan][usask].
88
## Building Miri
99

1010
I recommend that you install [rustup][rustup] to obtain Rust. Miri comes with a
11-
`rust-toolchain` file so rustup will automatically pick a suitable nightly
12-
version. Then all you have to do is:
11+
`rust-version` file describing the latest supported nightly version of the Rust
12+
compiler toolchain. Then all you have to do is:
1313

1414
```sh
15-
cargo build
15+
cargo +nightly build
1616
```
1717

18+
with `+nightly` replaced with the appropriate nightly version of Rust.
19+
1820
## Running Miri
1921

2022
```sh
21-
cargo run tests/run-pass/vecs.rs # Or whatever test you like.
23+
cargo +nightly run tests/run-pass/vecs.rs # Or whatever test you like.
2224
```
2325

2426
## Running Miri with full libstd
@@ -28,15 +30,15 @@ Miri hits a call to such a function, execution terminates. To fix this, it is
2830
possible to compile libstd with full MIR:
2931

3032
```sh
31-
rustup component add rust-src
32-
cargo install xargo
33-
xargo/build.sh
33+
rustup component add --toolchain nightly rust-src
34+
cargo +nightly install xargo
35+
rustup run nightly xargo/build.sh
3436
```
3537

3638
Now you can run Miri against the libstd compiled by xargo:
3739

3840
```sh
39-
MIRI_SYSROOT=~/.xargo/HOST cargo run tests/run-pass-fullmir/hashmap.rs
41+
MIRI_SYSROOT=~/.xargo/HOST cargo +nightly run tests/run-pass-fullmir/hashmap.rs
4042
```
4143

4244
Notice that you will have to re-run the last step of the preparations above when
@@ -47,13 +49,39 @@ You can also set `-Zmiri-start-fn` to make Miri start evaluation with the
4749

4850
## Running Miri on your own project('s test suite)
4951

50-
Install Miri as a cargo subcommand with `cargo install --all-features`, and install
51-
a full libstd as described above.
52+
Install Miri as a cargo subcommand with `cargo install +nightly --all-features --path .`.
53+
54+
Compile your project and its dependencies against a MIR-enabled libstd as described
55+
above:
56+
57+
1. Run `cargo clean` to eliminate any cached dependencies that were built against
58+
the non-MIR `libstd`.
59+
2. To run all tests in your project through, Miri, use
60+
`MIRI_SYSROOT=~/.xargo/HOST cargo +nightly miri test`.
61+
3. If you have a binary project, you can run it through Miri using
62+
`MIRI_SYSROOT=~/.xargo/HOST cargo +nightly miri`.
63+
64+
### Common Problems
65+
66+
When using the above instructions, you may encounter a number of confusing compiler
67+
errors.
68+
69+
#### "constant evaluation error: no mir for `<function>`"
70+
71+
You may have forgotten to set `MIRI_SYSROOT` when calling `cargo miri`, and
72+
your program called into `std` or `core`. Be sure to set `MIRI_SYSROOT=~/.xargo/HOST`.
73+
74+
#### "found possibly newer version of crate `std` which `<dependency>` depends on"
75+
76+
Your build directory may contain artifacts from an earlier build that did/did not
77+
have `MIRI_SYSROOT` set. Run `cargo clean` before switching from non-Miri to Miri
78+
builds and vice-versa.
79+
80+
#### "found crate `std` compiled by an incompatible version of rustc"
5281

53-
Then, inside your own project, use `MIRI_SYSROOT=~/.xargo/HOST cargo +nightly
54-
miri` to run your project, if it is a bin project, or run
55-
`MIRI_SYSROOT=~/.xargo/HOST cargo +nightly miri test` to run all tests in your
56-
project through Miri.
82+
You may be running `cargo miri` with a different compiler version than the one
83+
used to build the MIR-enabled `std`. Be sure to consistently use the same toolchain,
84+
which should be the toolchain specified in the `rust-version` file.
5785

5886
## Miri `-Z` flags
5987

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ branches:
1616
install:
1717
# install Rust
1818
- set PATH=C:\Program Files\Git\mingw64\bin;C:\msys64\mingw%MSYS2_BITS%\bin;%PATH%
19-
- set /p RUST_TOOLCHAIN=<rust-toolchain
19+
- set /p RUST_TOOLCHAIN=<rust-version
2020
- curl -sSf -o rustup-init.exe https://win.rustup.rs/
2121
- rustup-init.exe -y --default-host %TARGET% --default-toolchain %RUST_TOOLCHAIN%
2222
- set PATH=%USERPROFILE%\.cargo\bin;%PATH%
File renamed without changes.

0 commit comments

Comments
 (0)