Skip to content

Commit f42b708

Browse files
authored
Merge branch 'master' into oli-obk-patch-1
2 parents 5958fa6 + fb2d0ff commit f42b708

36 files changed

+250
-176
lines changed

.travis.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ os:
1111
- osx
1212

1313
before_script:
14-
# macOS weirdness (https://github.com/travis-ci/travis-ci/issues/6307)
14+
# macOS weirdness (https://github.com/travis-ci/travis-ci/issues/6307, https://github.com/travis-ci/travis-ci/issues/10165)
1515
- if [[ "$TRAVIS_OS_NAME" == osx ]]; then rvm get stable; fi
1616
# Compute the rust version we use. We do not use "language: rust" to have more control here.
1717
- |
@@ -28,8 +28,6 @@ before_script:
2828
- rustup target add i686-unknown-linux-gnu
2929
- rustup target add i686-pc-windows-gnu
3030
- rustup target add i686-pc-windows-msvc
31-
- rustup component add rust-src
32-
- cargo install xargo || echo "Skipping xargo install"
3331

3432
script:
3533
- set -e
@@ -39,11 +37,15 @@ script:
3937
cargo test --release --all-features &&
4038
cargo install --all-features --force --path .
4139
- |
42-
# get ourselves a MIR-full libstd
43-
xargo/build.sh &&
44-
export MIRI_SYSROOT=~/.xargo/HOST
40+
# Get ourselves a MIR-full libstd, and use it henceforth
41+
cargo miri setup &&
42+
if [ "$TRAVIS_OS_NAME" == osx ]; then
43+
export MIRI_SYSROOT=~/Library/Caches/miri.miri.miri/HOST
44+
else
45+
export MIRI_SYSROOT=~/.cache/miri/HOST
46+
fi
4547
- |
46-
# run all tests with full mir
48+
# Test miri with full MIR
4749
cargo test --release --all-features
4850
- |
4951
# Test cargo integration

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,16 @@ required-features = ["rustc_tests"]
3535
[dependencies]
3636
byteorder = { version = "1.1", features = ["i128"]}
3737
cargo_metadata = { version = "0.6", optional = true }
38+
directories = { version = "1.0", optional = true }
3839
env_logger = "0.5"
3940
log = "0.4"
4041

4142
[build-dependencies]
4243
vergen = "3"
4344

4445
[features]
45-
cargo_miri = ["cargo_metadata"]
46+
default = ["cargo_miri"]
47+
cargo_miri = ["cargo_metadata", "directories"]
4648
rustc_tests = []
4749

4850
[dev-dependencies]

README.md

Lines changed: 25 additions & 52 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,47 @@ 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-
```
54+
## Running Miri on your own project('s test suite)
6755

68-
Now you can run Miri against the libstd compiled by xargo:
56+
Install Miri as a cargo subcommand:
6957

7058
```sh
71-
MIRI_SYSROOT=~/.xargo/HOST cargo +nightly run tests/run-pass-fullmir/hashmap.rs
59+
cargo +nightly install --git https://github.com/solson/miri/ miri
7260
```
7361

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-
78-
## Running Miri on your own project('s test suite)
79-
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`.
62+
Be aware that if you used `rustup override set` to fix a particular Rust version
63+
for the miri directory, that will *not* apply to your own project directory!
64+
You have to use a consistent Rust version for building miri and your project for
65+
this to work, so remember to either always specify the nightly version manually,
66+
overriding it in your project directory as well, or use `rustup default nightly`
67+
(or `rustup default nightly-YYYY-MM-DD`) to globally make `nightly` the default
68+
toolchain.
69+
70+
1. Run `cargo clean` to eliminate any cached dependencies. Miri needs your
71+
dependencies to be compiled the right way, that would not happen if they have
72+
previously already been compiled.
73+
2. To run all tests in your project through Miri, use `cargo +nightly miri test`.
74+
**NOTE**: This is currently broken, see the discussion in
75+
[#479](https://github.com/solson/miri/issues/479).
76+
3. If you have a binary project, you can run it through Miri using `cargo
77+
+nightly miri run`.
10078

10179
### Common Problems
10280

10381
When using the above instructions, you may encounter a number of confusing compiler
10482
errors.
10583

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-
11184
#### "found possibly newer version of crate `std` which `<dependency>` depends on"
11285

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.
86+
Your build directory may contain artifacts from an earlier build that have/have
87+
not been built for Miri. Run `cargo clean` before switching from non-Miri to
88+
Miri builds and vice-versa.
11689

11790
#### "found crate `std` compiled by an incompatible version of rustc"
11891

11992
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.
93+
used to build the custom libstd that Miri uses, and Miri failed to detect that.
94+
Try deleting `~/.cache/miri`.
12295

12396
## Miri `-Z` flags
12497

appveyor.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,19 @@ install:
2121
- rustup-init.exe -y --default-host %TARGET% --default-toolchain %RUST_TOOLCHAIN%
2222
- set PATH=%USERPROFILE%\.cargo\bin;%PATH%
2323
- rustc --version
24-
# Customize installation.
25-
- rustup component add rust-src
26-
- cargo install xargo
27-
# Prepare a libstd with MIR (cannot use bash script, obviously).
28-
# The flags here should be kept in sync with `add_miri_default_args` in `src/lib.rs`.
29-
- cd xargo
30-
- set RUSTFLAGS=-Zalways-encode-mir -Zmir-emit-retag -Zmir-opt-level=0
31-
- xargo build
32-
- set RUSTFLAGS=
33-
- cd ..
3424

3525
build: false
3626

3727
test_script:
3828
- set RUSTFLAGS=-g
3929
- set RUST_BACKTRACE=1
30+
# Test plain miri
4031
- cargo build --release --all-features --all-targets
4132
- cargo test --release --all-features
42-
- set MIRI_SYSROOT=%USERPROFILE%\.xargo\HOST
33+
# Get ourselves a MIR-full libstd, and use it henceforth
34+
- cargo run --release --all-features --bin cargo-miri -- miri setup
35+
- set MIRI_SYSROOT=%USERPROFILE%\AppData\Local\miri\miri\cache\HOST
36+
# Test miri with full MIR
4337
- cargo test --release --all-features
4438

4539
notifications:

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
)

0 commit comments

Comments
 (0)