Skip to content

Commit 2f348cb

Browse files
committed
Auto merge of #136110 - RalfJung:miri-sync, r=RalfJung
Miri subtree update r? `@ghost`
2 parents ebcf860 + 05a2dcd commit 2f348cb

File tree

9 files changed

+22
-16
lines changed

9 files changed

+22
-16
lines changed

src/tools/miri/ci/ci.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ function endgroup {
1414
begingroup "Building Miri"
1515

1616
# Global configuration
17-
export RUSTFLAGS="-D warnings"
17+
# We are getting some odd linker warnings on macOS, make sure they do not fail the build.
18+
# (See <https://github.com/rust-lang/rust/issues/136086>.)
19+
export RUSTFLAGS="-D warnings -A linker-messages"
1820
export CARGO_INCREMENTAL=0
1921
export CARGO_EXTRA_FLAGS="--locked"
2022

src/tools/miri/rust-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
01706e1a34c87656fcbfce198608f4cd2ac6461a
1+
2f0ad2a71e4a4528bb80bcb24bf8fa4e50cb87c2

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

+13-7
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ use std::num::NonZero;
2929
use std::ops::Range;
3030
use std::path::PathBuf;
3131
use std::str::FromStr;
32-
use std::sync::atomic::{AtomicI32, Ordering};
3332
use std::sync::Once;
33+
use std::sync::atomic::{AtomicI32, AtomicU32, Ordering};
3434

3535
use miri::{
36-
BacktraceStyle, BorrowTrackerMethod, MiriConfig, MiriEntryFnType,ProvenanceMode, RetagFields, ValidationMode,
36+
BacktraceStyle, BorrowTrackerMethod, MiriConfig, MiriEntryFnType, ProvenanceMode, RetagFields,
37+
ValidationMode,
3738
};
3839
use rustc_abi::ExternAbi;
3940
use rustc_data_structures::sync;
@@ -182,7 +183,8 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
182183
if let Some(many_seeds) = self.many_seeds.take() {
183184
assert!(config.seed.is_none());
184185
let exit_code = sync::IntoDynSyncSend(AtomicI32::new(rustc_driver::EXIT_SUCCESS));
185-
sync::par_for_each_in(many_seeds.seeds, |seed| {
186+
let num_failed = sync::IntoDynSyncSend(AtomicU32::new(0));
187+
sync::par_for_each_in(many_seeds.seeds.clone(), |seed| {
186188
let mut config = config.clone();
187189
config.seed = Some(seed.into());
188190
eprintln!("Trying seed: {seed}");
@@ -196,8 +198,13 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
196198
std::process::exit(return_code);
197199
}
198200
exit_code.store(return_code, Ordering::Relaxed);
201+
num_failed.fetch_add(1, Ordering::Relaxed);
199202
}
200203
});
204+
let num_failed = num_failed.0.into_inner();
205+
if num_failed > 0 {
206+
eprintln!("{num_failed}/{total} SEEDS FAILED", total = many_seeds.seeds.count());
207+
}
201208
std::process::exit(exit_code.0.into_inner());
202209
} else {
203210
let return_code = miri::eval_entry(tcx, entry_def_id, entry_type, config)
@@ -716,10 +723,9 @@ fn main() {
716723

717724
// Ensure we have parallelism for many-seeds mode.
718725
if many_seeds.is_some() && !rustc_args.iter().any(|arg| arg.starts_with("-Zthreads=")) {
719-
rustc_args.push(format!(
720-
"-Zthreads={}",
721-
std::thread::available_parallelism().map_or(1, |n| n.get())
722-
));
726+
// Clamp to 8 threads; things get a lot less efficient beyond that due to lock contention.
727+
let threads = std::thread::available_parallelism().map_or(1, |n| n.get()).min(8);
728+
rustc_args.push(format!("-Zthreads={threads}"));
723729
}
724730
let many_seeds =
725731
many_seeds.map(|seeds| ManySeedsConfig { seeds, keep_going: many_seeds_keep_going });

src/tools/miri/src/helpers.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ fn try_resolve_did(tcx: TyCtxt<'_>, path: &[&str], namespace: Option<Namespace>)
3838
item: DefId,
3939
name: &'a str,
4040
) -> impl Iterator<Item = DefId> + 'a {
41+
let name = Symbol::intern(name);
4142
tcx.module_children(item)
4243
.iter()
43-
.filter(move |item| item.ident.name.as_str() == name)
44+
.filter(move |item| item.ident.name == name)
4445
.map(move |item| item.res.def_id())
4546
}
4647

src/tools/miri/test-cargo-miri/no-std-smoke/src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copied from tests/pass/no-std.rs
22

33
#![no_std]
4+
#![no_main]
45

56
// Plumbing to let us use `writeln!` to host stdout:
67

src/tools/miri/tests/fail/intrinsics/cttz_nonzero.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#![feature(intrinsics)]
32

43
mod rusti {

src/tools/miri/tests/fail/intrinsics/float_to_int_32_nanneg.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#[rustc_intrinsic]
55
unsafe fn float_to_int_unchecked<Float: Copy, Int: Copy>(_value: Float) -> Int;
66

7-
87
fn main() {
98
unsafe {
109
float_to_int_unchecked::<f32, u32>(-f32::NAN); //~ ERROR: cannot be represented in target type `u32`

src/tools/miri/tests/fail/intrinsics/float_to_int_64_infneg1.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#[rustc_intrinsic]
55
unsafe fn float_to_int_unchecked<Float: Copy, Int: Copy>(_value: Float) -> Int;
66

7-
87
fn main() {
98
unsafe {
109
float_to_int_unchecked::<f64, u128>(f64::NEG_INFINITY); //~ ERROR: cannot be represented in target type `u128`

src/tools/miri/tests/pass-dep/concurrency/linux-futex.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ fn concurrent_wait_wake() {
235235
static mut DATA: i32 = 0;
236236
static WOKEN: AtomicI32 = AtomicI32::new(0);
237237

238-
let rounds = 50;
238+
let rounds = 64;
239239
for _ in 0..rounds {
240240
unsafe { DATA = 0 }; // Reset
241241
// Suppose the main thread is holding a lock implemented using futex...
@@ -267,8 +267,7 @@ fn concurrent_wait_wake() {
267267
}
268268
});
269269
// Increase the chance that the other thread actually goes to sleep.
270-
// (5 yields in a loop seem to make that happen around 40% of the time.)
271-
for _ in 0..5 {
270+
for _ in 0..6 {
272271
thread::yield_now();
273272
}
274273

0 commit comments

Comments
 (0)