Skip to content

Commit cc4dd29

Browse files
committed
kill xargo dir and update docs
1 parent 16ac7ec commit cc4dd29

File tree

8 files changed

+26
-77
lines changed

8 files changed

+26
-77
lines changed

README.md

Lines changed: 23 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ in this directory.
4242

4343
[rustup]: https://www.rustup.rs
4444

45-
## Running Miri
45+
## Running Miri on tiny examples
4646

4747
```sh
4848
cargo +nightly run -- -Zmiri-disable-validation tests/run-pass/vecs.rs # Or whatever test you like.
@@ -51,74 +51,42 @@ cargo +nightly run -- -Zmiri-disable-validation tests/run-pass/vecs.rs # Or what
5151
We have to disable validation because that can lead to errors when libstd is not
5252
compiled the right way.
5353

54-
## Running Miri with full libstd
55-
56-
Per default libstd does not contain the MIR of non-polymorphic functions, and
57-
also does not contain some extra MIR statements that miri needs for validation.
58-
When Miri hits a call to such a function, execution terminates, and even when
59-
the MIR is present, validation can fail. To fix this, it is possible to compile
60-
libstd with full MIR:
61-
62-
```sh
63-
rustup component add --toolchain nightly rust-src
64-
cargo +nightly install xargo
65-
rustup run nightly xargo/build.sh
66-
```
67-
68-
Now you can run Miri against the libstd compiled by xargo:
69-
70-
```sh
71-
MIRI_SYSROOT=~/.xargo/HOST cargo +nightly run tests/run-pass-fullmir/hashmap.rs
72-
```
73-
74-
Notice that you will have to re-run the last step of the preparations above
75-
(`xargo/build.sh`) when your toolchain changes (e.g., when you update the
76-
nightly).
77-
7854
## Running Miri on your own project('s test suite)
7955

80-
Install Miri as a cargo subcommand with `cargo +nightly install --all-features
81-
--path .`. Be aware that if you used `rustup override set` to fix a particular
82-
Rust version for the miri directory, that will *not* apply to your own project
83-
directory! You have to use a consistent Rust version for building miri and your
84-
project for this to work, so remember to either always specify the nightly
85-
version manually, overriding it in your project directory as well, or use
86-
`rustup default nightly` (or `rustup default nightly-YYYY-MM-DD`) to globally
87-
make `nightly` the default toolchain.
88-
89-
We assume that you have prepared a MIR-enabled libstd as described above. Now
90-
compile your project and its dependencies against that libstd:
91-
92-
1. Run `cargo clean` to eliminate any cached dependencies that were built against
93-
the non-MIR `libstd`.
94-
2. To run all tests in your project through, Miri, use
95-
`MIRI_SYSROOT=~/.xargo/HOST cargo +nightly miri test`. **NOTE**: This is
96-
currently broken, see the discussion in
97-
[#479](https://github.com/solson/miri/issues/479).
98-
3. If you have a binary project, you can run it through Miri using
99-
`MIRI_SYSROOT=~/.xargo/HOST cargo +nightly miri`.
56+
Install Miri as a cargo subcommand with `cargo +nightly install --path .`. Be
57+
aware that if you used `rustup override set` to fix a particular Rust version
58+
for the miri directory, that will *not* apply to your own project directory!
59+
You have to use a consistent Rust version for building miri and your project for
60+
this to work, so remember to either always specify the nightly version manually,
61+
overriding it in your project directory as well, or use `rustup default nightly`
62+
(or `rustup default nightly-YYYY-MM-DD`) to globally make `nightly` the default
63+
toolchain.
64+
65+
1. Run `cargo clean` to eliminate any cached dependencies. Miri needs your
66+
dependencies to be compiled the right way, that would not happen if they have
67+
previously already been compiled.
68+
2. To run all tests in your project through Miri, use `cargo +nightly miri test`.
69+
**NOTE**: This is currently broken, see the discussion in
70+
[#479](https://github.com/solson/miri/issues/479).
71+
3. If you have a binary project, you can run it through Miri using `cargo
72+
+nightly miri run`.
10073

10174
### Common Problems
10275

10376
When using the above instructions, you may encounter a number of confusing compiler
10477
errors.
10578

106-
#### "constant evaluation error: no mir for `<function>`"
107-
108-
You may have forgotten to set `MIRI_SYSROOT` when calling `cargo miri`, and
109-
your program called into `std` or `core`. Be sure to set `MIRI_SYSROOT=~/.xargo/HOST`.
110-
11179
#### "found possibly newer version of crate `std` which `<dependency>` depends on"
11280

113-
Your build directory may contain artifacts from an earlier build that did/did not
114-
have `MIRI_SYSROOT` set. Run `cargo clean` before switching from non-Miri to Miri
115-
builds and vice-versa.
81+
Your build directory may contain artifacts from an earlier build that have/have
82+
not been built for Miri. Run `cargo clean` before switching from non-Miri to
83+
Miri builds and vice-versa.
11684

11785
#### "found crate `std` compiled by an incompatible version of rustc"
11886

11987
You may be running `cargo miri` with a different compiler version than the one
120-
used to build the MIR-enabled `std`. Be sure to consistently use the same toolchain,
121-
which should be the toolchain specified in the `rust-version` file.
88+
used to build the custom libstd that Miri uses, and Miri failed to detect that.
89+
Try deleting `~/.miri`.
12290

12391
## Miri `-Z` flags
12492

cargo-miri-test/run-test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
import sys, subprocess
99

1010
def test_cargo_miri():
11-
print("==> Testing `cargo miri` <==")
11+
print("==> Testing `cargo miri run` <==")
1212
## Call `cargo miri`, capture all output
1313
p = subprocess.Popen(
14-
["cargo", "miri", "-q"],
14+
["cargo", "miri", "run", "-q"],
1515
stdout=subprocess.PIPE,
1616
stderr=subprocess.PIPE
1717
)

src/bin/cargo-miri.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ path = "lib.rs"
174174
"#).unwrap();
175175
File::create(dir.join("lib.rs")).unwrap();
176176
// Run xargo
177-
if !Command::new("xargo").arg("build")
177+
if !Command::new("xargo").arg("build").arg("-q")
178178
.current_dir(&dir)
179179
.env("RUSTFLAGS", miri::miri_default_args().join(" "))
180180
.env("XARGO_HOME", dir.to_str().unwrap())

xargo/Cargo.lock

Lines changed: 0 additions & 4 deletions
This file was deleted.

xargo/Cargo.toml

Lines changed: 0 additions & 6 deletions
This file was deleted.

xargo/Xargo.toml

Lines changed: 0 additions & 5 deletions
This file was deleted.

xargo/build.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

xargo/src/lib.rs

Whitespace-only changes.

0 commit comments

Comments
 (0)