Skip to content

Commit

Permalink
Auto merge of #136110 - RalfJung:miri-sync, r=RalfJung
Browse files Browse the repository at this point in the history
Miri subtree update

r? `@ghost`
  • Loading branch information
bors committed Jan 27, 2025
2 parents ebcf860 + 05a2dcd commit 2f348cb
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 16 deletions.
4 changes: 3 additions & 1 deletion src/tools/miri/ci/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ function endgroup {
begingroup "Building Miri"

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

Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
01706e1a34c87656fcbfce198608f4cd2ac6461a
2f0ad2a71e4a4528bb80bcb24bf8fa4e50cb87c2
20 changes: 13 additions & 7 deletions src/tools/miri/src/bin/miri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ use std::num::NonZero;
use std::ops::Range;
use std::path::PathBuf;
use std::str::FromStr;
use std::sync::atomic::{AtomicI32, Ordering};
use std::sync::Once;
use std::sync::atomic::{AtomicI32, AtomicU32, Ordering};

use miri::{
BacktraceStyle, BorrowTrackerMethod, MiriConfig, MiriEntryFnType,ProvenanceMode, RetagFields, ValidationMode,
BacktraceStyle, BorrowTrackerMethod, MiriConfig, MiriEntryFnType, ProvenanceMode, RetagFields,
ValidationMode,
};
use rustc_abi::ExternAbi;
use rustc_data_structures::sync;
Expand Down Expand Up @@ -182,7 +183,8 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
if let Some(many_seeds) = self.many_seeds.take() {
assert!(config.seed.is_none());
let exit_code = sync::IntoDynSyncSend(AtomicI32::new(rustc_driver::EXIT_SUCCESS));
sync::par_for_each_in(many_seeds.seeds, |seed| {
let num_failed = sync::IntoDynSyncSend(AtomicU32::new(0));
sync::par_for_each_in(many_seeds.seeds.clone(), |seed| {
let mut config = config.clone();
config.seed = Some(seed.into());
eprintln!("Trying seed: {seed}");
Expand All @@ -196,8 +198,13 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
std::process::exit(return_code);
}
exit_code.store(return_code, Ordering::Relaxed);
num_failed.fetch_add(1, Ordering::Relaxed);
}
});
let num_failed = num_failed.0.into_inner();
if num_failed > 0 {
eprintln!("{num_failed}/{total} SEEDS FAILED", total = many_seeds.seeds.count());
}
std::process::exit(exit_code.0.into_inner());
} else {
let return_code = miri::eval_entry(tcx, entry_def_id, entry_type, config)
Expand Down Expand Up @@ -716,10 +723,9 @@ fn main() {

// Ensure we have parallelism for many-seeds mode.
if many_seeds.is_some() && !rustc_args.iter().any(|arg| arg.starts_with("-Zthreads=")) {
rustc_args.push(format!(
"-Zthreads={}",
std::thread::available_parallelism().map_or(1, |n| n.get())
));
// Clamp to 8 threads; things get a lot less efficient beyond that due to lock contention.
let threads = std::thread::available_parallelism().map_or(1, |n| n.get()).min(8);
rustc_args.push(format!("-Zthreads={threads}"));
}
let many_seeds =
many_seeds.map(|seeds| ManySeedsConfig { seeds, keep_going: many_seeds_keep_going });
Expand Down
3 changes: 2 additions & 1 deletion src/tools/miri/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ fn try_resolve_did(tcx: TyCtxt<'_>, path: &[&str], namespace: Option<Namespace>)
item: DefId,
name: &'a str,
) -> impl Iterator<Item = DefId> + 'a {
let name = Symbol::intern(name);
tcx.module_children(item)
.iter()
.filter(move |item| item.ident.name.as_str() == name)
.filter(move |item| item.ident.name == name)
.map(move |item| item.res.def_id())
}

Expand Down
1 change: 1 addition & 0 deletions src/tools/miri/test-cargo-miri/no-std-smoke/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copied from tests/pass/no-std.rs

#![no_std]
#![no_main]

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

Expand Down
1 change: 0 additions & 1 deletion src/tools/miri/tests/fail/intrinsics/cttz_nonzero.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#![feature(intrinsics)]

mod rusti {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#[rustc_intrinsic]
unsafe fn float_to_int_unchecked<Float: Copy, Int: Copy>(_value: Float) -> Int;


fn main() {
unsafe {
float_to_int_unchecked::<f32, u32>(-f32::NAN); //~ ERROR: cannot be represented in target type `u32`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#[rustc_intrinsic]
unsafe fn float_to_int_unchecked<Float: Copy, Int: Copy>(_value: Float) -> Int;


fn main() {
unsafe {
float_to_int_unchecked::<f64, u128>(f64::NEG_INFINITY); //~ ERROR: cannot be represented in target type `u128`
Expand Down
5 changes: 2 additions & 3 deletions src/tools/miri/tests/pass-dep/concurrency/linux-futex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ fn concurrent_wait_wake() {
static mut DATA: i32 = 0;
static WOKEN: AtomicI32 = AtomicI32::new(0);

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

Expand Down

0 comments on commit 2f348cb

Please sign in to comment.