Skip to content

Commit 5b72a7c

Browse files
Rollup merge of rust-lang#152700 - RalfJung:miri, r=RalfJung
miri subtree update Subtree update of `miri` to rust-lang/miri@ef30e90. Created using https://github.com/rust-lang/josh-sync. r? @ghost
2 parents 71e0027 + 6a3a3d4 commit 5b72a7c

56 files changed

Lines changed: 393 additions & 564 deletions

Some content is hidden

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

src/tools/miri/CONTRIBUTING.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,23 @@ process for such contributions:
6666
This process is largely informal, and its primary goal is to more clearly communicate expectations.
6767
Please get in touch with us if you have any questions!
6868

69+
## Scope of Miri shims
70+
71+
Miri has "shims" to implement functionality that is usually implemented in C libraries which are
72+
invoked from Rust code, such as opening files or spawning threads, as well as for
73+
CPU-vendor-provided SIMD intrinsics. However, the set of C functions that Rust code invokes this way
74+
is enormous, and for obvious reasons we have no intention of implementing every C API ever written
75+
in Miri.
76+
77+
At the moment, the general guideline for "could this function have a shim in Miri" is: we will
78+
generally only add shims for functions that can be implemented in a portable way using just what is
79+
provided by the Rust standard library. The function should also be reasonably widely-used in Rust
80+
code to justify the review and maintenance effort (i.e. the easier the function is to implement, the
81+
lower the barrier). Other than that, we might make exceptions for certain cases if (a) there is a
82+
good case for why Miri should support those APIs, and (b) robust and widely-used portable libraries
83+
exist in the Rust ecosystem. We will generally not add shims to Miri that would require Miri to
84+
directly interact with platform-specific APIs (such as `libc` or `windows-sys`).
85+
6986
## Preparing the build environment
7087

7188
Miri heavily relies on internal and unstable rustc interfaces to execute MIR,

src/tools/miri/Cargo.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -562,9 +562,9 @@ checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7"
562562

563563
[[package]]
564564
name = "git2"
565-
version = "0.20.2"
565+
version = "0.20.4"
566566
source = "registry+https://github.com/rust-lang/crates.io-index"
567-
checksum = "2deb07a133b1520dc1a5690e9bd08950108873d7ed5de38dcc74d3b5ebffa110"
567+
checksum = "7b88256088d75a56f8ecfa070513a775dd9107f6530ef14919dac831af9cfe2b"
568568
dependencies = [
569569
"bitflags",
570570
"libc",
@@ -804,9 +804,9 @@ dependencies = [
804804

805805
[[package]]
806806
name = "libgit2-sys"
807-
version = "0.18.2+1.9.1"
807+
version = "0.18.3+1.9.2"
808808
source = "registry+https://github.com/rust-lang/crates.io-index"
809-
checksum = "1c42fe03df2bd3c53a3a9c7317ad91d80c81cd1fb0caec8d7cc4cd2bfa10c222"
809+
checksum = "c9b3acc4b91781bb0b3386669d325163746af5f6e4f73e6d2d630e09a35f3487"
810810
dependencies = [
811811
"cc",
812812
"libc",

src/tools/miri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ serde = { version = "1.0.219", features = ["derive"], optional = true }
3939
[target.'cfg(target_os = "linux")'.dependencies]
4040
nix = { version = "0.30.1", features = ["mman", "ptrace", "signal"], optional = true }
4141
ipc-channel = { version = "0.20.0", optional = true }
42-
capstone = { version = "0.14", optional = true }
42+
capstone = { version = "0.14", features = ["arch_x86", "full"], default-features = false, optional = true}
4343

4444
[target.'cfg(all(target_os = "linux", target_pointer_width = "64", target_endian = "little"))'.dependencies]
4545
genmc-sys = { path = "./genmc-sys/", version = "0.1.0", optional = true }

src/tools/miri/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,8 @@ Definite bugs found:
626626
* [`ReentrantLock` not correctly dealing with reuse of addresses for TLS storage of different threads](https://github.com/rust-lang/rust/pull/141248)
627627
* [Rare Deadlock in the thread (un)parking example code](https://github.com/rust-lang/rust/issues/145816)
628628
* [`winit` registering a global constructor with the wrong ABI on Windows](https://github.com/rust-windowing/winit/issues/4435)
629+
* [`VecDeque::splice` confusing physical and logical indices](https://github.com/rust-lang/rust/issues/151758)
630+
* [Data race in `oneshot` channel](https://github.com/faern/oneshot/issues/69)
629631

630632
Violations of [Stacked Borrows] found that are likely bugs (but Stacked Borrows is currently just an experiment):
631633

src/tools/miri/cargo-miri/src/phases.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ pub fn phase_cargo_miri(mut args: impl Iterator<Item = String>) {
6363
"setup" => MiriCommand::Setup,
6464
"test" | "t" | "run" | "r" | "nextest" => MiriCommand::Forward(subcommand),
6565
"clean" => MiriCommand::Clean,
66+
// For use by the `./miri test` dependency builder.
67+
"build" if env::var_os("MIRI_BUILD_TEST_DEPS").is_some() =>
68+
MiriCommand::Forward("build".into()),
6669
_ => {
6770
// Check for version and help flags.
6871
if has_arg_flag("--help") || has_arg_flag("-h") {
@@ -309,6 +312,7 @@ pub fn phase_rustc(args: impl Iterator<Item = String>, phase: RustcPhase) {
309312
// Ask rustc for the filename (since that is target-dependent).
310313
let mut rustc = miri_for_host(); // sysroot doesn't matter for this so we just use the host
311314
rustc.arg("--print").arg("file-names");
315+
rustc.arg("-Zunstable-options"); // needed for JSON targets
312316
for flag in ["--crate-name", "--crate-type", "--target"] {
313317
for val in get_arg_flag_values(flag) {
314318
rustc.arg(flag).arg(val);

src/tools/miri/cargo-miri/src/setup.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ pub fn setup(
8888
};
8989
let cargo_cmd = {
9090
let mut command = cargo();
91+
// Allow JSON targets since users do not have a good way to set this flag otherwise.
92+
if env::var("RUSTC_STAGE").is_err() {
93+
// ^ is a HACK for bootstrap cargo. FIXME(cfg(bootstrap)) remove the hack.
94+
command.arg("-Zjson-target-spec");
95+
}
9196
// Use Miri as rustc to build a libstd compatible with us (and use the right flags).
9297
// We set ourselves (`cargo-miri`) instead of Miri directly to be able to patch the flags
9398
// for `libpanic_abort` (usually this is done by bootstrap but we have to do it ourselves).

src/tools/miri/ci/ci.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function run_tests_minimal {
129129
time ./miri test $TARGET_FLAG "$@"
130130

131131
# Ensure that a small smoke test of cargo-miri works.
132-
time cargo miri run --manifest-path test-cargo-miri/no-std-smoke/Cargo.toml $TARGET_FLAG
132+
time cargo miri run --manifest-path test-cargo-miri/no-std-smoke/Cargo.toml -Zjson-target-spec $TARGET_FLAG
133133

134134
endgroup
135135
}
@@ -173,7 +173,9 @@ case $HOST_TARGET in
173173
# Host
174174
MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 CARGO_MIRI_ENV=1 run_tests
175175
# Custom target JSON file
176-
TEST_TARGET=tests/x86_64-unknown-kernel.json MIRI_NO_STD=1 run_tests_minimal no_std
176+
TEST_TARGET=tests/x86_64-unknown-kernel.json MIRI_NO_STD=1 MIRIFLAGS="-Zunstable-options" run_tests_minimal no_std
177+
# Not officially supported tier 2
178+
MANY_SEEDS=16 TEST_TARGET=x86_64-pc-solaris run_tests
177179
;;
178180
aarch64-apple-darwin)
179181
# Host
@@ -184,7 +186,6 @@ case $HOST_TARGET in
184186
# Not officially supported tier 2
185187
MANY_SEEDS=16 TEST_TARGET=mips-unknown-linux-gnu run_tests # a 32bit big-endian target, and also a target without 64bit atomics
186188
MANY_SEEDS=16 TEST_TARGET=x86_64-unknown-illumos run_tests
187-
MANY_SEEDS=16 TEST_TARGET=x86_64-pc-solaris run_tests
188189
;;
189190
i686-pc-windows-msvc)
190191
# Host

src/tools/miri/rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d10ac47c20152feb5e99b1c35a2e6830f77c66dc
1+
7bee525095c0872e87c038c412c781b9bbb3f5dc

src/tools/miri/src/alloc/isolated_alloc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ impl IsolatedAlloc {
6666
// And make sure the align is at least one page
6767
let align = std::cmp::max(layout.align(), self.page_size);
6868
// pg_count gives us the # of pages needed to satisfy the size. For
69-
// align > page_size where align = n * page_size, a sufficently-aligned
69+
// align > page_size where align = n * page_size, a sufficiently-aligned
7070
// address must exist somewhere in the range of
7171
// some_page_aligned_address..some_page_aligned_address + (n-1) * page_size
72-
// (since if some_page_aligned_address + n * page_size is sufficently aligned,
72+
// (since if some_page_aligned_address + n * page_size is sufficiently aligned,
7373
// then so is some_page_aligned_address itself per the definition of n, so we
7474
// can avoid using that 1 extra page).
7575
// Thus we allocate n-1 extra pages

src/tools/miri/src/bin/log/tracing_chrome_instant.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//! <https://github.com/tikv/minstant/blob/27c9ec5ec90b5b67113a748a4defee0d2519518c/src/tsc_now.rs>.
33
//! A useful resource is also
44
//! <https://www.pingcap.com/blog/how-we-trace-a-kv-database-with-less-than-5-percent-performance-impact/>,
5-
//! although this file does not implement TSC synchronization but insteads pins threads to CPUs,
5+
//! although this file does not implement TSC synchronization but instead pins threads to CPUs,
66
//! since the former is not reliable (i.e. it might lead to non-monotonic time measurements).
77
//! Another useful resource for future improvements might be measureme's time measurement utils:
88
//! <https://github.com/rust-lang/measureme/blob/master/measureme/src/counters.rs>.
@@ -11,7 +11,7 @@
1111
#![cfg(feature = "tracing")]
1212

1313
/// This alternative `TracingChromeInstant` implementation was made entirely to suit the needs of
14-
/// [crate::log::tracing_chrome], and shouldn't be used for anything else. It featues two functions:
14+
/// [crate::log::tracing_chrome], and shouldn't be used for anything else. It features two functions:
1515
/// - [TracingChromeInstant::setup_for_thread_and_start], which sets up the current thread to do
1616
/// proper time tracking and returns a point in time to use as "t=0", and
1717
/// - [TracingChromeInstant::with_elapsed_micros_subtracting_tracing], which allows

0 commit comments

Comments
 (0)