Skip to content

Commit 7c89485

Browse files
committed
Auto merge of #121232 - RalfJung:miri, r=RalfJung
Miri subtree update r? `@ghost`
2 parents b806b91 + f856ddd commit 7c89485

Some content is hidden

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

44 files changed

+2116
-263
lines changed

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

Cargo.lock

Lines changed: 0 additions & 56 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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"] }

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.

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

rust-version

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

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/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/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};

src/borrow_tracker/stacked_borrows/stack.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ impl<'tcx> Stack {
385385
let upper = unique_range.end;
386386
for item in &mut self.borrows[lower..upper] {
387387
if item.perm() == Permission::Unique {
388-
log::trace!("access: disabling item {:?}", item);
388+
trace!("access: disabling item {:?}", item);
389389
visitor(*item)?;
390390
item.set_permission(Permission::Disabled);
391391
// Also update all copies of this item in the cache.

0 commit comments

Comments
 (0)