Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
2afd4ed
Manually set initial TCP socket readiness
WhySoBad Aug 31, 2026
c967fc3
Merge pull request #5299 from WhySoBad/default-tcp-socket-readiness
RalfJung Sep 5, 2026
786d634
Prepare for merging from rust-lang/rust
Sep 6, 2026
f6da7ba
Merge ref 'f248f4038796' from rust-lang/rust
Sep 6, 2026
3af1d65
Merge pull request #5309 from rust-lang/rustup-2026-09-06
RalfJung Sep 6, 2026
9311482
Prepare for merging from rust-lang/rust
Sep 10, 2026
bd0c526
Merge ref '315ecf4a939d' from rust-lang/rust
Sep 10, 2026
34deffb
fmt
Sep 10, 2026
2b85c28
adjust CI: 32bit windows hosts are no more
RalfJung Sep 10, 2026
cbb4ec4
Merge pull request #5313 from rust-lang/rustup-2026-09-10
RalfJung Sep 10, 2026
c301619
use proper c_void for '*_' shim signatures
RalfJung Sep 11, 2026
83e06d3
Merge pull request #5315 from RalfJung/sig-ptr-types
RalfJung Sep 11, 2026
68963d8
stop unleaking `&mut`s
maxdexh Sep 14, 2026
8545395
Merge pull request #5316 from maxdexh/unleak-considered-harmful
RalfJung Sep 14, 2026
a243cf4
Prepare for merging from rust-lang/rust
Sep 15, 2026
5c57c46
Merge ref 'c26ce708de5d' from rust-lang/rust
Sep 15, 2026
2e1a970
Merge pull request #5317 from rust-lang/rustup-2026-09-15
RalfJung Sep 15, 2026
0b34b6e
Prepare for merging from rust-lang/rust
Sep 17, 2026
39fc047
Merge ref '923c95cdf5ba' from rust-lang/rust
Sep 17, 2026
39a2977
Merge pull request #5318 from rust-lang/rustup-2026-09-17
RalfJung Sep 17, 2026
c39609d
Revert "./miri toolchain: no need to run 'cargo metadata'"
RalfJung Sep 18, 2026
0d17901
add issue reference for work-around
RalfJung Sep 18, 2026
11458eb
Merge pull request #5322 from RalfJung/toolchain-metadata
RalfJung Sep 18, 2026
c91c25f
Prepare for merging from rust-lang/rust
Sep 19, 2026
4d11a44
Merge ref '971903d9aee2' from rust-lang/rust
Sep 19, 2026
715287a
Merge pull request #5324 from rust-lang/rustup-2026-09-19
oli-obk Sep 19, 2026
f4579a6
use errno_check a few more times
RalfJung Sep 19, 2026
80c0261
add dirfd support
RalfJung Sep 19, 2026
ae80614
prepare statx for metadata relative to dirfd... but we cannot impleme…
RalfJung Sep 19, 2026
001a866
statx: complain about invalid flags
RalfJung Sep 19, 2026
d708bca
Merge pull request #5325 from RalfJung/dirfd
RalfJung Sep 19, 2026
88a1bbe
statx: proper error code on empty path without flag
RalfJung Sep 19, 2026
900f61b
closedir: also close underlying FD
RalfJung Sep 19, 2026
4d65c6e
Merge pull request #5329 from RalfJung/dirfd-close
RalfJung Sep 19, 2026
ad44475
Merge pull request #5328 from RalfJung/statx-empty
RalfJung Sep 19, 2026
3cfab90
Prepare for merging from rust-lang/rust
Sep 20, 2026
788a945
Merge ref 'feaadeeaca7d' from rust-lang/rust
Sep 20, 2026
95f476c
Merge pull request #5330 from rust-lang/rustup-2026-09-20
RalfJung Sep 20, 2026
a94b19e
simplify FileMetadata handling a bit
RalfJung Sep 20, 2026
ba4aca6
stat test: ensure it does follow symlinks
RalfJung Sep 20, 2026
d20eef4
statx: test that dirfd is ignored when path is absolute
RalfJung Sep 20, 2026
a568e05
Merge pull request #5331 from RalfJung/stat
RalfJung Sep 20, 2026
dded7e6
windows: reject some FILE_FLAG_OPEN_REPARSE_POINT uses we do not support
RalfJung Sep 20, 2026
0dc8df9
Merge pull request #5332 from RalfJung/win-reparse
RalfJung Sep 20, 2026
68f7047
move sched_get/setaffinity shims into separate functions
RalfJung Sep 20, 2026
2d8731d
this ESRCH should not be reachable
RalfJung Sep 20, 2026
ac90169
Merge pull request #5334 from RalfJung/cpu-affinity
RalfJung Sep 20, 2026
04ef62c
make some more tests run-native
RalfJung Sep 20, 2026
1d763d3
turns put pthread_set/getname_np can segfault when given the wrong pt…
RalfJung Sep 20, 2026
3e96d2d
macos seems to return pthread_setname_np errors via errno...?
RalfJung Sep 20, 2026
b6a42cc
consistently use utils::prepare for temporary files
RalfJung Sep 20, 2026
38bbfa3
windows fs test: check CREATE_NEW semantics
RalfJung Sep 20, 2026
b9ce922
Merge pull request #5333 from RalfJung/native
RalfJung Sep 20, 2026
ee2e94e
better debugging for which env var we carry over from build-time to r…
RalfJung Sep 6, 2026
1df9314
only preserve env vars cargo actually changes from build-time to run-…
RalfJung Sep 6, 2026
eeb2889
Merge pull request #5337 from RalfJung/env
RalfJung Sep 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/tools/miri/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
# qemu: true
- host_target: aarch64-apple-darwin
os: macos-latest
- host_target: i686-pc-windows-msvc
- host_target: x86_64-pc-windows-msvc
os: windows-latest
- host_target: aarch64-pc-windows-msvc
os: windows-11-arm
Expand Down
29 changes: 15 additions & 14 deletions src/tools/miri/cargo-miri/src/phases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,6 @@ pub fn phase_rustc(args: impl Iterator<Item = String>, phase: RustcPhase) {
cmd.env("MIRI_BE_RUSTC", if target_crate { "target" } else { "host" });

// Run it.
if verbose > 0 {
eprintln!("[cargo-miri rustc] target_crate={target_crate} runnable_crate={runnable_crate}");
}

debug_cmd("[cargo-miri rustc]", verbose, &cmd);
exec(cmd);
}
Expand Down Expand Up @@ -582,16 +578,21 @@ pub fn phase_runner(mut binary_args: impl Iterator<Item = String>, phase: Runner
if name == "CARGO_MAKEFLAGS" {
continue;
}
if let Some(old_val) = env::var_os(name) {
if *old_val == *val {
// This one did not actually change, no need to re-set it.
// (This keeps the `debug_cmd` below more manageable.)
continue;
} else if verbose > 0 {
eprintln!(
"[cargo-miri runner] Overwriting run-time env var {name:?}={old_val:?} with build-time value {val:?}"
);
}
let old_val = env::var_os(name);
if old_val.as_ref() == Some(val) {
// This one did not actually change, no need to re-set it.
// (This keeps the `debug_cmd` below more manageable.)
continue;
}
if verbose > 0 {
eprintln!(
"[cargo-miri runner] Carrying over build-time env var {name:?}={val:?}{}",
if let Some(old_val) = old_val {
format!(", overwriting run-time value {old_val:?}")
} else {
format!("")
}
);
}
cmd.env(name, val);
}
Expand Down
10 changes: 9 additions & 1 deletion src/tools/miri/cargo-miri/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@ impl CrateRunInfo {
/// Gather all the information we need.
pub fn collect(args: impl Iterator<Item = String>, capture_stdin: bool) -> Self {
let args = args.collect();
let env = env::vars_os().collect();
let env = env::vars_os()
.filter(|(var, _val)| {
// We only need to bother with env vars cargo actually sets.
// We try to avoid storing anything that may contain secrets.
var.to_str().is_some_and(|var| {
var == "OUT_DIR" || (var.starts_with("CARGO_") && !var.ends_with("_TOKEN"))
})
})
.collect();
let current_dir = env::current_dir().unwrap().into_os_string();

let mut stdin = Vec::new();
Expand Down
9 changes: 4 additions & 5 deletions src/tools/miri/ci/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ case $HOST_TARGET in
i686-unknown-linux-gnu)
# Host
MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 CARGO_MIRI_ENV=1 run_tests
# Not officially supported tier 2
# Not officially supported tier 2. Also covers "64bit target on 32bit host".
MANY_SEEDS=16 TEST_TARGET=aarch64-linux-android run_tests
MANY_SEEDS=16 TEST_TARGET=loongarch64-unknown-linux-gnu run_tests
# Partially supported targets (no_std, tier 2)
Expand All @@ -175,7 +175,7 @@ case $HOST_TARGET in
MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 CARGO_MIRI_ENV=1 run_tests
# Custom target JSON file
TEST_TARGET=tests/x86_64-unknown-kernel.json MIRI_NO_STD=1 MIRIFLAGS="-Zunstable-options" run_tests_minimal no_std
# Not officially supported tier 2
# Not officially supported tier 2.
MANY_SEEDS=16 TEST_TARGET=x86_64-pc-solaris run_tests
MANY_SEEDS=16 TEST_TARGET=mips-unknown-linux-gnu run_tests # a 32bit big-endian target, and also a target without 64bit atomics
MANY_SEEDS=16 TEST_TARGET=riscv64a23-unknown-linux-gnu run_tests
Expand All @@ -187,12 +187,11 @@ case $HOST_TARGET in
MANY_SEEDS=64 TEST_TARGET=i686-pc-windows-gnu run_tests
MANY_SEEDS=64 TEST_TARGET=x86_64-pc-windows-msvc CARGO_MIRI_ENV=1 run_tests
;;
i686-pc-windows-msvc)
x86_64-pc-windows-msvc)
# Host
MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 run_tests
# Extra tier 1
# We really want to ensure a Linux target works on a Windows host,
# and a 64bit target works on a 32bit host.
# We really want to ensure a Linux target works on a Windows host.
TEST_TARGET=x86_64-unknown-linux-gnu run_tests
;;
aarch64-pc-windows-msvc)
Expand Down
5 changes: 5 additions & 0 deletions src/tools/miri/miri-script/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ impl Command {
cmd!(sh, "rustup override set miri").run()?;
// Cleanup.
cmd!(sh, "cargo clean").run()?;
// Call `cargo metadata` on the sources in case that changes the lockfile
// (works around <https://github.com/rust-lang/rust-analyzer/issues/23392>).
let sysroot = cmd!(sh, "rustc --print sysroot").read()?;
let sysroot = sysroot.trim();
cmd!(sh, "cargo metadata --format-version 1 --manifest-path {sysroot}/lib/rustlib/rustc-src/rust/compiler/rustc/Cargo.toml").ignore_stdout().run()?;
Ok(())
}

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 @@
0ed41eb4142dda2df61eb1145a312c1a9d62eb56
feaadeeaca7db0594da854e7c8c07495341c7439
90 changes: 0 additions & 90 deletions src/tools/miri/src/concurrency/cpu_affinity.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/tools/miri/src/concurrency/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pub mod blocking_io;
pub mod cpu_affinity;
pub mod data_race;
mod data_race_handler;
pub mod init_once;
Expand Down
9 changes: 5 additions & 4 deletions src/tools/miri/src/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,11 +458,13 @@ fn call_main<'tcx>(
// Call start function.
match entry_type {
MiriEntryFnType::Rustc(EntryFnType::Main { .. }) => {
let entry_sig = tcx.fn_sig(entry_id).no_bound_vars().unwrap();
let main_ret_ty = entry_sig.output();
let main_ret_ty = main_ret_ty.no_bound_vars().unwrap();

let start_id = tcx.lang_items().start_fn().unwrap_or_else(|| {
tcx.dcx().fatal("could not find start lang item");
});
let main_ret_ty = tcx.fn_sig(entry_id).no_bound_vars().unwrap().output();
let main_ret_ty = main_ret_ty.no_bound_vars().unwrap();
let start_instance = ty::Instance::try_resolve(
tcx,
ecx.typing_env(),
Expand All @@ -484,8 +486,7 @@ fn call_main<'tcx>(
&[
ImmTy::from_scalar(
Scalar::from_pointer(main_ptr, ecx),
// FIXME use a proper fn ptr type
ecx.machine.layouts.const_raw_ptr,
ecx.layout_of(Ty::new_fn_ptr(tcx, entry_sig)).unwrap(),
),
argc,
argv,
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ pub use crate::clock::{Deadline, Instant, MonotonicClock, TimeoutClock, TimeoutS
pub use crate::concurrency::blocking_io::{
BlockingIoInterest, BlockingIoManager, EvalContextExt as _, SourceFileDescription,
};
pub use crate::concurrency::cpu_affinity::MAX_CPUS;
pub use crate::concurrency::data_race::{
AtomicFenceOrd, AtomicReadOrd, AtomicRwOrd, AtomicWriteOrd, EvalContextExt as _,
};
Expand Down Expand Up @@ -166,6 +165,7 @@ pub use crate::machine::{
pub use crate::operator::EvalContextExt as _;
pub use crate::provenance_gc::{EvalContextExt as _, LiveAllocs, VisitProvenance, VisitWith};
pub use crate::shims::EmulateItemResult;
pub use crate::shims::cpu_affinity::MAX_CPUS;
pub use crate::shims::env::{EnvVars, EvalContextExt as _};
pub use crate::shims::foreign_items::{DynSym, EvalContextExt as _};
pub use crate::shims::io_error::{EvalContextExt as _, IoError, LibcError};
Expand Down
47 changes: 33 additions & 14 deletions src/tools/miri/src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,12 @@ use rustc_target::callconv::FnAbi;
use rustc_target::spec::{Arch, Os};

use crate::alloc_addresses::EvalContextExt;
use crate::concurrency::cpu_affinity::{self, CpuAffinityMask};
use crate::concurrency::data_race::{self, NaReadType, NaWriteType};
use crate::concurrency::sync::SyncObj;
use crate::concurrency::{
AllocDataRaceHandler, GenmcCtx, GenmcEvalContextExt as _, GlobalDataRaceHandler, weak_memory,
};
use crate::helpers::is_no_core;
use crate::shims::readiness::DelayedReadinessUpdates;
use crate::*;

/// First real-time signal.
Expand Down Expand Up @@ -433,15 +431,33 @@ pub struct PrimitiveLayouts<'tcx> {
pub u128: TyAndLayout<'tcx>,
pub usize: TyAndLayout<'tcx>,
pub bool: TyAndLayout<'tcx>,
pub mut_raw_ptr: TyAndLayout<'tcx>, // *mut ()
pub const_raw_ptr: TyAndLayout<'tcx>, // *const ()
pub unit_ptr_mut: TyAndLayout<'tcx>, // *mut ()
pub unit_ptr_const: TyAndLayout<'tcx>, // *const ()
pub void_ptr_mut: TyAndLayout<'tcx>, // *mut c_void
pub void_ptr_const: TyAndLayout<'tcx>, // *const c_void
pub fn_ptr: TyAndLayout<'tcx>, // extern "C" fn()
}

impl<'tcx> PrimitiveLayouts<'tcx> {
fn new(layout_cx: LayoutCx<'tcx>) -> Result<Self, &'tcx LayoutError<'tcx>> {
let tcx = layout_cx.tcx();
let mut_raw_ptr = Ty::new_mut_ptr(tcx, tcx.types.unit);
let const_raw_ptr = Ty::new_imm_ptr(tcx, tcx.types.unit);

let unit_ptr_mut = Ty::new_mut_ptr(tcx, tcx.types.unit);
let unit_ptr_const = Ty::new_imm_ptr(tcx, tcx.types.unit);
// We fall back to `()` if the lang item is missing, so `no_core` works better with Miri.
let c_void = match tcx.lang_items().c_void() {
Some(c_void) => ty::Instance::mono(tcx, c_void).ty(tcx, layout_cx.typing_env),
None => tcx.types.unit,
};
let void_ptr_mut = Ty::new_mut_ptr(tcx, c_void);
let void_ptr_const = Ty::new_imm_ptr(tcx, c_void);

let sig_kind = ty::FnSigKind::default()
.set_abi(ExternAbi::C { unwind: false })
.set_safety(rustc_hir::Safety::Safe);
let fn_ptr =
Ty::new_fn_ptr(tcx, ty::Binder::dummy(tcx.mk_fn_sig([], tcx.types.unit, sig_kind)));

Ok(Self {
unit: layout_cx.layout_of(tcx.types.unit)?,
i8: layout_cx.layout_of(tcx.types.i8)?,
Expand All @@ -457,8 +473,11 @@ impl<'tcx> PrimitiveLayouts<'tcx> {
u128: layout_cx.layout_of(tcx.types.u128)?,
usize: layout_cx.layout_of(tcx.types.usize)?,
bool: layout_cx.layout_of(tcx.types.bool)?,
mut_raw_ptr: layout_cx.layout_of(mut_raw_ptr)?,
const_raw_ptr: layout_cx.layout_of(const_raw_ptr)?,
unit_ptr_mut: layout_cx.layout_of(unit_ptr_mut)?,
unit_ptr_const: layout_cx.layout_of(unit_ptr_const)?,
void_ptr_mut: layout_cx.layout_of(void_ptr_mut)?,
void_ptr_const: layout_cx.layout_of(void_ptr_const)?,
fn_ptr: layout_cx.layout_of(fn_ptr)?,
})
}

Expand Down Expand Up @@ -536,7 +555,7 @@ pub struct MiriMachine<'tcx> {
pub(crate) dirs: shims::DirTable,

/// Managing file descriptors whose readiness needs to be updated.
pub(crate) delayed_readiness_updates: Rc<DelayedReadinessUpdates>,
pub(crate) delayed_readiness_updates: Rc<shims::DelayedReadinessUpdates>,

/// This machine's monotone clock.
pub(crate) monotonic_clock: MonotonicClock,
Expand All @@ -551,7 +570,7 @@ pub struct MiriMachine<'tcx> {
/// This has no effect at all, it is just tracked to produce the correct result
/// in `sched_getaffinity`
/// This will be `None` when running `#![no_core]` crates.
pub(crate) thread_cpu_affinity: Option<FxHashMap<ThreadId, CpuAffinityMask>>,
pub(crate) thread_cpu_affinity: Option<FxHashMap<ThreadId, shims::CpuAffinityMask>>,

/// Precomputed `TyLayout`s for primitive data types that are commonly used inside Miri.
pub(crate) layouts: PrimitiveLayouts<'tcx>,
Expand Down Expand Up @@ -730,9 +749,9 @@ impl<'tcx> MiriMachine<'tcx> {
let stack_size =
if tcx.pointer_size().bits() < 32 { page_size * 4 } else { page_size * 16 };
assert!(
usize::try_from(config.num_cpus).unwrap() <= cpu_affinity::MAX_CPUS,
usize::try_from(config.num_cpus).unwrap() <= shims::cpu_affinity::MAX_CPUS,
"miri only supports up to {} CPUs, but {} were configured",
cpu_affinity::MAX_CPUS,
shims::cpu_affinity::MAX_CPUS,
config.num_cpus
);
let threads = ThreadManager::new(config);
Expand All @@ -743,7 +762,7 @@ impl<'tcx> MiriMachine<'tcx> {
let mut affinity = FxHashMap::default();
affinity.insert(
threads.active_thread(),
CpuAffinityMask::new(&layout_cx, config.num_cpus),
shims::CpuAffinityMask::new(&layout_cx, config.num_cpus),
);
Some(affinity)
} else {
Expand All @@ -769,7 +788,7 @@ impl<'tcx> MiriMachine<'tcx> {
isolated_op: config.isolated_op,
validation: config.validation,
fds: shims::FdTable::init(config.mute_stdout_stderr),
delayed_readiness_updates: Rc::new(DelayedReadinessUpdates::default()),
delayed_readiness_updates: Rc::new(shims::DelayedReadinessUpdates::default()),
dirs: Default::default(),
layouts,
threads,
Expand Down
Loading
Loading