Skip to content

Commit eeeb021

Browse files
committed
Auto merge of #121232 - RalfJung:miri, r=RalfJung
Miri subtree update r? `@ghost`
2 parents ba824a2 + fd5a84b commit eeeb021

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2116
-265
lines changed

Cargo.lock

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2524,14 +2524,12 @@ dependencies = [
25242524
"aes",
25252525
"colored",
25262526
"ctrlc",
2527-
"env_logger 0.10.2",
25282527
"getrandom",
25292528
"jemalloc-sys",
25302529
"lazy_static",
25312530
"libc",
25322531
"libffi",
25332532
"libloading",
2534-
"log",
25352533
"measureme",
25362534
"rand",
25372535
"regex",

src/tools/miri/CONTRIBUTING.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ custom target file, you might have to set `MIRI_NO_STD=1`.
7878
base directory, e.g. `./miri test fail` will run all compile-fail tests). These filters are passed
7979
to `cargo test`, so for multiple filers you need to use `./miri test -- FILTER1 FILTER2`.
8080

81+
#### Fine grained logging
82+
8183
You can get a trace of which MIR statements are being executed by setting the
8284
`MIRI_LOG` environment variable. For example:
8385

@@ -94,9 +96,16 @@ stacked borrows implementation:
9496
MIRI_LOG=rustc_mir::interpret=info,miri::stacked_borrows ./miri run tests/pass/vec.rs
9597
```
9698

97-
In addition, you can set `MIRI_BACKTRACE=1` to get a backtrace of where an
99+
Note that you will only get `info`, `warn` or `error` messages if you use a prebuilt compiler.
100+
In order to get `debug` and `trace` level messages, you need to build miri with a locally built
101+
compiler that has `debug=true` set in `config.toml`.
102+
103+
#### Debugging error messages
104+
105+
You can set `MIRI_BACKTRACE=1` to get a backtrace of where an
98106
evaluation error was originally raised.
99107

108+
100109
### UI testing
101110

102111
We use ui-testing in Miri, meaning we generate `.stderr` and `.stdout` files for the output

src/tools/miri/Cargo.lock

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -273,19 +273,6 @@ version = "0.3.6"
273273
source = "registry+https://github.com/rust-lang/crates.io-index"
274274
checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
275275

276-
[[package]]
277-
name = "env_logger"
278-
version = "0.10.1"
279-
source = "registry+https://github.com/rust-lang/crates.io-index"
280-
checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece"
281-
dependencies = [
282-
"humantime",
283-
"is-terminal",
284-
"log",
285-
"regex",
286-
"termcolor",
287-
]
288-
289276
[[package]]
290277
name = "errno"
291278
version = "0.3.8"
@@ -339,18 +326,6 @@ version = "0.28.1"
339326
source = "registry+https://github.com/rust-lang/crates.io-index"
340327
checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
341328

342-
[[package]]
343-
name = "hermit-abi"
344-
version = "0.3.3"
345-
source = "registry+https://github.com/rust-lang/crates.io-index"
346-
checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7"
347-
348-
[[package]]
349-
name = "humantime"
350-
version = "2.1.0"
351-
source = "registry+https://github.com/rust-lang/crates.io-index"
352-
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
353-
354329
[[package]]
355330
name = "indenter"
356331
version = "0.3.3"
@@ -388,17 +363,6 @@ dependencies = [
388363
"cfg-if",
389364
]
390365

391-
[[package]]
392-
name = "is-terminal"
393-
version = "0.4.10"
394-
source = "registry+https://github.com/rust-lang/crates.io-index"
395-
checksum = "0bad00257d07be169d870ab665980b06cdb366d792ad690bf2e76876dc503455"
396-
dependencies = [
397-
"hermit-abi",
398-
"rustix",
399-
"windows-sys 0.52.0",
400-
]
401-
402366
[[package]]
403367
name = "itoa"
404368
version = "1.0.10"
@@ -529,14 +493,12 @@ dependencies = [
529493
"aes",
530494
"colored",
531495
"ctrlc",
532-
"env_logger",
533496
"getrandom",
534497
"jemalloc-sys",
535498
"lazy_static",
536499
"libc",
537500
"libffi",
538501
"libloading",
539-
"log",
540502
"measureme",
541503
"rand",
542504
"regex",
@@ -875,15 +837,6 @@ dependencies = [
875837
"windows-sys 0.52.0",
876838
]
877839

878-
[[package]]
879-
name = "termcolor"
880-
version = "1.4.0"
881-
source = "registry+https://github.com/rust-lang/crates.io-index"
882-
checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449"
883-
dependencies = [
884-
"winapi-util",
885-
]
886-
887840
[[package]]
888841
name = "thiserror"
889842
version = "1.0.56"
@@ -1034,15 +987,6 @@ version = "0.4.0"
1034987
source = "registry+https://github.com/rust-lang/crates.io-index"
1035988
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
1036989

1037-
[[package]]
1038-
name = "winapi-util"
1039-
version = "0.1.6"
1040-
source = "registry+https://github.com/rust-lang/crates.io-index"
1041-
checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"
1042-
dependencies = [
1043-
"winapi",
1044-
]
1045-
1046990
[[package]]
1047991
name = "winapi-x86_64-pc-windows-gnu"
1048992
version = "0.4.0"

src/tools/miri/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ doctest = false # and no doc tests
1919

2020
[dependencies]
2121
getrandom = { version = "0.2", features = ["std"] }
22-
env_logger = "0.10"
23-
log = "0.4"
2422
rand = "0.8"
2523
smallvec = "1.7"
2624
aes = { version = "0.8.3", features = ["hazmat"] }

src/tools/miri/README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,8 @@ assume the right toolchain is pinned via `rustup override set nightly` or
108108

109109
Now you can run your project in Miri:
110110

111-
1. Run `cargo clean` to eliminate any cached dependencies. Miri needs your
112-
dependencies to be compiled the right way, that would not happen if they have
113-
previously already been compiled.
114-
2. To run all tests in your project through Miri, use `cargo miri test`.
115-
3. If you have a binary project, you can run it through Miri using `cargo miri run`.
111+
- To run all tests in your project through Miri, use `cargo miri test`.
112+
- If you have a binary project, you can run it through Miri using `cargo miri run`.
116113

117114
The first time you run Miri, it will perform some extra setup and install some
118115
dependencies. It will ask you for confirmation before installing anything.

src/tools/miri/ci/ci.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ case $HOST_TARGET in
121121
MIRI_TEST_TARGET=aarch64-apple-darwin run_tests
122122
MIRI_TEST_TARGET=i686-pc-windows-gnu run_tests
123123
# Some targets are only partially supported.
124-
MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal hello integer vec panic/panic concurrency/simple pthread-threadname libc-getentropy libc-getrandom libc-misc libc-fs atomic env align
125-
MIRI_TEST_TARGET=i686-unknown-freebsd run_tests_minimal hello integer vec panic/panic concurrency/simple pthread-threadname libc-getentropy libc-getrandom libc-misc libc-fs atomic env align
124+
MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal hello integer vec panic/panic concurrency/simple pthread-threadname libc-getentropy libc-getrandom libc-misc libc-fs atomic env align num_cpus
125+
MIRI_TEST_TARGET=i686-unknown-freebsd run_tests_minimal hello integer vec panic/panic concurrency/simple pthread-threadname libc-getentropy libc-getrandom libc-misc libc-fs atomic env align num_cpus
126+
126127
MIRI_TEST_TARGET=aarch64-linux-android run_tests_minimal hello integer vec panic/panic
127128
MIRI_TEST_TARGET=wasm32-wasi run_tests_minimal no_std integer strings wasm
128129
MIRI_TEST_TARGET=wasm32-unknown-unknown run_tests_minimal no_std integer strings wasm

src/tools/miri/rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
dd2559e08e1530806740931037d6bb83ef956161
1+
4316d0c6252cb1f833e582dfa68adb98efd5ddfb

src/tools/miri/src/bin/miri.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
clippy::useless_format,
66
clippy::field_reassign_with_default,
77
rustc::diagnostic_outside_of_impl,
8-
rustc::untranslatable_diagnostic,
8+
rustc::untranslatable_diagnostic
99
)]
1010

1111
extern crate rustc_data_structures;
@@ -16,14 +16,14 @@ extern crate rustc_log;
1616
extern crate rustc_metadata;
1717
extern crate rustc_middle;
1818
extern crate rustc_session;
19+
#[macro_use]
20+
extern crate tracing;
1921

2022
use std::env::{self, VarError};
2123
use std::num::NonZero;
2224
use std::path::PathBuf;
2325
use std::str::FromStr;
2426

25-
use log::debug;
26-
2727
use rustc_data_structures::sync::Lrc;
2828
use rustc_driver::Compilation;
2929
use rustc_hir::{self as hir, Node};
@@ -200,7 +200,7 @@ fn rustc_logger_config() -> rustc_log::LoggerConfig {
200200
// CTFE-related. Otherwise, we use it verbatim for `RUSTC_LOG`.
201201
// This way, if you set `MIRI_LOG=trace`, you get only the right parts of
202202
// rustc traced, but you can also do `MIRI_LOG=miri=trace,rustc_const_eval::interpret=debug`.
203-
if log::Level::from_str(&var).is_ok() {
203+
if tracing::Level::from_str(&var).is_ok() {
204204
cfg.filter = Ok(format!(
205205
"rustc_middle::mir::interpret={var},rustc_const_eval::interpret={var}"
206206
));
@@ -218,10 +218,6 @@ fn rustc_logger_config() -> rustc_log::LoggerConfig {
218218
}
219219

220220
fn init_early_loggers(early_dcx: &EarlyDiagCtxt) {
221-
// Note that our `extern crate log` is *not* the same as rustc's; as a result, we have to
222-
// initialize them both, and we always initialize `miri`'s first.
223-
let env = env_logger::Env::new().filter("MIRI_LOG").write_style("MIRI_LOG_STYLE");
224-
env_logger::init_from_env(env);
225221
// Now for rustc. We only initialize `rustc` if the env var is set (so the user asked for it).
226222
// If it is not set, we avoid initializing now so that we can initialize later with our custom
227223
// settings, and *not* log anything for what happens before `miri` gets started.

src/tools/miri/src/borrow_tracker/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::cell::RefCell;
22
use std::fmt;
33
use std::num::NonZero;
44

5-
use log::trace;
65
use smallvec::SmallVec;
76

87
use rustc_data_structures::fx::{FxHashMap, FxHashSet};

src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ use std::cmp;
99
use std::fmt::Write;
1010
use std::mem;
1111

12-
use log::trace;
13-
1412
use rustc_data_structures::fx::FxHashSet;
1513
use rustc_middle::mir::{Mutability, RetagKind};
1614
use rustc_middle::ty::{self, layout::HasParamEnv, Ty};

0 commit comments

Comments
 (0)