Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6453a17
add `vpdpbusd` avx512 intrinsic
folkertdev Dec 18, 2025
e4a8675
Merge pull request #4776 from folkertdev/vpdpbusd
RalfJung Jan 2, 2026
9f1066b
Basic support for FFI callbacks
weiznich Nov 27, 2025
c7f6d78
minor cleanup
RalfJung Jan 2, 2026
6feaf1d
Merge pull request #4728 from weiznich/ffi_callbacks
RalfJung Jan 2, 2026
1f32c2a
bump libffi
RalfJung Jan 2, 2026
604cf92
avoid aliasing trouble around libffi closures
RalfJung Jan 2, 2026
4d2ce7d
use a single generic codepath for all return types
RalfJung Jan 2, 2026
e811227
Merge pull request #4798 from RalfJung/native-lib-uniform-ret
RalfJung Jan 2, 2026
296ab7c
android: get the entire test suite to pass
RalfJung Jan 2, 2026
2db68ef
Merge pull request #4799 from RalfJung/android
RalfJung Jan 2, 2026
b80a3ea
Prepare for merging from rust-lang/rust
Jan 3, 2026
0b22248
Merge ref 'e8f3cfc0de70' from rust-lang/rust
Jan 3, 2026
efdd313
Merge pull request #4801 from rust-lang/rustup-2026-01-03
oli-obk Jan 3, 2026
aec6b9b
Refactor libc pipe tests to use utility functions for error handling …
hulxv Dec 17, 2025
b692fcb
minor tweaks
RalfJung Jan 3, 2026
cb36523
Merge pull request #4768 from hulxv/refactor/simplify-libc-tests/libc…
RalfJung Jan 3, 2026
9302232
Prepare for merging from rust-lang/rust
Jan 4, 2026
bd26cf7
Merge ref 'f57b9e6f565a' from rust-lang/rust
Jan 4, 2026
f65c581
Merge pull request #4802 from rust-lang/rustup-2026-01-04
RalfJung Jan 4, 2026
0557c75
add check_only feature for faster check builds
RalfJung Jan 4, 2026
dbf2ef7
Merge pull request #4803 from RalfJung/check_only
RalfJung Jan 4, 2026
ff2acf0
update lockfile
RalfJung Jan 4, 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
19 changes: 9 additions & 10 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -445,22 +445,21 @@ dependencies = [

[[package]]
name = "capstone"
version = "0.13.0"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "015ef5d5ca1743e3f94af9509ba6bd2886523cfee46e48d15c2ef5216fd4ac9a"
checksum = "f442ae0f2f3f1b923334b4a5386c95c69c1cfa072bafa23d6fae6d9682eb1dd4"
dependencies = [
"capstone-sys",
"libc",
"static_assertions",
]

[[package]]
name = "capstone-sys"
version = "0.17.0"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2267cb8d16a1e4197863ec4284ffd1aec26fe7e57c58af46b02590a0235809a0"
checksum = "a4e8087cab6731295f5a2a2bd82989ba4f41d3a428aab2e7c98d8f4db38aac05"
dependencies = [
"cc",
"libc",
]

[[package]]
Expand Down Expand Up @@ -2232,19 +2231,19 @@ dependencies = [

[[package]]
name = "libffi"
version = "5.0.0"
version = "5.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0444124f3ffd67e1b0b0c661a7f81a278a135eb54aaad4078e79fbc8be50c8a5"
checksum = "0498fe5655f857803e156523e644dcdcdc3b3c7edda42ea2afdae2e09b2db87b"
dependencies = [
"libc",
"libffi-sys",
]

[[package]]
name = "libffi-sys"
version = "4.0.0"
version = "4.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d722da8817ea580d0669da6babe2262d7b86a1af1103da24102b8bb9c101ce7"
checksum = "71d4f1d4ce15091955144350b75db16a96d4a63728500122706fb4d29a26afbb"
dependencies = [
"cc",
]
Expand Down
25 changes: 15 additions & 10 deletions src/tools/miri/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -123,22 +123,21 @@ dependencies = [

[[package]]
name = "capstone"
version = "0.13.0"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "015ef5d5ca1743e3f94af9509ba6bd2886523cfee46e48d15c2ef5216fd4ac9a"
checksum = "f442ae0f2f3f1b923334b4a5386c95c69c1cfa072bafa23d6fae6d9682eb1dd4"
dependencies = [
"capstone-sys",
"libc",
"static_assertions",
]

[[package]]
name = "capstone-sys"
version = "0.17.0"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2267cb8d16a1e4197863ec4284ffd1aec26fe7e57c58af46b02590a0235809a0"
checksum = "a4e8087cab6731295f5a2a2bd82989ba4f41d3a428aab2e7c98d8f4db38aac05"
dependencies = [
"cc",
"libc",
]

[[package]]
Expand Down Expand Up @@ -786,19 +785,19 @@ checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976"

[[package]]
name = "libffi"
version = "5.0.0"
version = "5.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0444124f3ffd67e1b0b0c661a7f81a278a135eb54aaad4078e79fbc8be50c8a5"
checksum = "0498fe5655f857803e156523e644dcdcdc3b3c7edda42ea2afdae2e09b2db87b"
dependencies = [
"libc",
"libffi-sys",
]

[[package]]
name = "libffi-sys"
version = "4.0.0"
version = "4.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d722da8817ea580d0669da6babe2262d7b86a1af1103da24102b8bb9c101ce7"
checksum = "71d4f1d4ce15091955144350b75db16a96d4a63728500122706fb4d29a26afbb"
dependencies = [
"cc",
]
Expand Down Expand Up @@ -1404,6 +1403,12 @@ version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"

[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"

[[package]]
name = "strsim"
version = "0.11.1"
Expand Down
5 changes: 3 additions & 2 deletions src/tools/miri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ serde_json = { version = "1.0", optional = true }
[target.'cfg(unix)'.dependencies]
libc = "0.2"
# native-lib dependencies
libffi = { version = "5.0.0", optional = true }
libffi = { version = "5.1.0", optional = true }
libloading = { version = "0.9", optional = true }
serde = { version = "1.0.219", features = ["derive"], optional = true }

[target.'cfg(target_os = "linux")'.dependencies]
nix = { version = "0.30.1", features = ["mman", "ptrace", "signal"], optional = true }
ipc-channel = { version = "0.20.0", optional = true }
capstone = { version = "0.13", optional = true }
capstone = { version = "0.14", optional = true }

[target.'cfg(all(target_os = "linux", target_pointer_width = "64", target_endian = "little"))'.dependencies]
genmc-sys = { path = "./genmc-sys/", version = "0.1.0", optional = true }
Expand Down Expand Up @@ -68,6 +68,7 @@ expensive-consistency-checks = ["stack-cache"]
tracing = ["serde_json"]
native-lib = ["dep:libffi", "dep:libloading", "dep:capstone", "dep:ipc-channel", "dep:nix", "dep:serde"]
jemalloc = []
check_only = ["libffi?/check_only", "capstone?/check_only", "genmc-sys?/check_only"]

[lints.rust.unexpected_cfgs]
level = "warn"
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ degree documented below):
- We have unofficial support (not maintained by the Miri team itself) for some further operating systems.
- `solaris` / `illumos`: maintained by @devnexen. Supports the entire test suite.
- `freebsd`: maintained by @YohDeadfall and @LorrensP-2158466. Supports the entire test suite.
- `android`: **maintainer wanted**. Basic OS APIs and concurrency work, but file system access is not supported.
- `android`: **maintainer wanted**. Supports the entire test suite.
- For targets on other operating systems, Miri might fail before even reaching the `main` function.

However, even for targets that we do support, the degree of support for accessing platform APIs
Expand Down
20 changes: 11 additions & 9 deletions src/tools/miri/ci/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ export CARGO_INCREMENTAL=0
export CARGO_EXTRA_FLAGS="--locked"

# Determine configuration for installed build (used by test-cargo-miri and `./miri bench`).
# We use the default set of features for this.
echo "Installing release version of Miri"
time ./miri install

# Prepare debug build for direct `./miri` invocations.
# We enable all features to make sure the Stacked Borrows consistency check runs.
# Here we enable some more features and checks.
echo "Building debug version of Miri"
export CARGO_EXTRA_FLAGS="$CARGO_EXTRA_FLAGS --all-features"
time ./miri build # the build that all the `./miri test` below will use
export FEATURES="--features=expensive-consistency-checks,genmc"
time ./miri build $FEATURES # the build that all the `./miri test` below will use

endgroup

Expand All @@ -63,7 +64,7 @@ function run_tests {
if [ -n "${GC_STRESS-}" ]; then
time MIRIFLAGS="${MIRIFLAGS-} -Zmiri-provenance-gc=1" ./miri test $TARGET_FLAG
else
time ./miri test $TARGET_FLAG
time ./miri test $FEATURES $TARGET_FLAG
fi

## advanced tests
Expand All @@ -74,20 +75,20 @@ function run_tests {
# them. Also error locations change so we don't run the failing tests.
# We explicitly enable debug-assertions here, they are disabled by -O but we have tests
# which exist to check that we panic on debug assertion failures.
time MIRIFLAGS="${MIRIFLAGS-} -O -Zmir-opt-level=4 -Cdebug-assertions=yes" MIRI_SKIP_UI_CHECKS=1 ./miri test $TARGET_FLAG tests/{pass,panic}
time MIRIFLAGS="${MIRIFLAGS-} -O -Zmir-opt-level=4 -Cdebug-assertions=yes" MIRI_SKIP_UI_CHECKS=1 ./miri test $FEATURES $TARGET_FLAG tests/{pass,panic}
fi
if [ -n "${MANY_SEEDS-}" ]; then
# Run many-seeds tests. (Also tests `./miri run`.)
time for FILE in tests/many-seeds/*.rs; do
./miri run "-Zmiri-many-seeds=0..$MANY_SEEDS" $TARGET_FLAG "$FILE"
./miri run $FEATURES "-Zmiri-many-seeds=0..$MANY_SEEDS" $TARGET_FLAG "$FILE"
done
# Smoke-test `./miri run --dep`.
./miri run $FEATURES $TARGET_FLAG --dep tests/pass-dep/getrandom.rs
fi
if [ -n "${TEST_BENCH-}" ]; then
# Check that the benchmarks build and run, but only once.
time HYPERFINE="hyperfine -w0 -r1 --show-output" ./miri bench $TARGET_FLAG --no-install
fi
# Smoke-test `./miri run --dep`.
./miri run $TARGET_FLAG --dep tests/pass-dep/getrandom.rs

## test-cargo-miri
# On Windows, there is always "python", not "python3" or "python2".
Expand Down Expand Up @@ -149,10 +150,11 @@ case $HOST_TARGET in
i686-unknown-linux-gnu)
# Host
MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 CARGO_MIRI_ENV=1 run_tests
# Fully, but not officially, supported tier 2
MANY_SEEDS=16 TEST_TARGET=aarch64-linux-android run_tests
# Partially supported targets (tier 2)
BASIC="empty_main integer heap_alloc libc-mem vec string btreemap" # ensures we have the basics: pre-main code, system allocator
UNIX="hello panic/panic panic/unwind concurrency/simple atomic libc-mem libc-misc libc-random env num_cpus" # the things that are very similar across all Unixes, and hence easily supported there
TEST_TARGET=aarch64-linux-android run_tests_minimal $BASIC $UNIX time hashmap random thread sync concurrency epoll eventfd prctl
TEST_TARGET=wasm32-unknown-unknown run_tests_minimal no_std empty_main wasm # this target doesn't really have std
TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std
;;
Expand Down
1 change: 0 additions & 1 deletion src/tools/miri/etc/rust_analyzer_helix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ invocationStrategy = "once"
overrideCommand = [
"./miri",
"check",
"--no-default-features",
"-Zunstable-options",
"--compile-time-deps",
"--message-format=json",
Expand Down
1 change: 0 additions & 1 deletion src/tools/miri/etc/rust_analyzer_vscode.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"rust-analyzer.cargo.buildScripts.overrideCommand": [
"./miri",
"check",
"--no-default-features",
"-Zunstable-options",
"--compile-time-deps",
"--message-format=json",
Expand Down
1 change: 0 additions & 1 deletion src/tools/miri/etc/rust_analyzer_zed.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"overrideCommand": [
"./miri",
"check",
"--no-default-features",
"-Zunstable-options",
"--compile-time-deps",
"--message-format=json"
Expand Down
3 changes: 3 additions & 0 deletions src/tools/miri/genmc-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ cc = "1.2.16"
cmake = "0.1.54"
git2 = { version = "0.20.2", default-features = false, features = ["https"] }
cxx-build = { version = "1.0.173", features = ["parallel"] }

[features]
check_only = []
5 changes: 5 additions & 0 deletions src/tools/miri/genmc-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ fn compile_cpp_dependencies(genmc_path: &Path, always_configure: bool) {
}

fn main() {
// For check-only builds, we don't need to do anything.
if cfg!(feature = "check_only") {
return;
}

// Select which path to use for the GenMC repo:
let (genmc_path, always_configure) = if let Some(genmc_src_path) = option_env!("GENMC_SRC_PATH")
{
Expand Down
6 changes: 4 additions & 2 deletions src/tools/miri/miri-script/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@ impl Command {
Ok(())
}

fn check(features: Vec<String>, flags: Vec<String>) -> Result<()> {
fn check(mut features: Vec<String>, flags: Vec<String>) -> Result<()> {
features.push("check_only".into());
let e = MiriEnv::new()?;
e.check(".", &features, &flags)?;
e.check("cargo-miri", &[], &flags)?;
Expand All @@ -405,7 +406,8 @@ impl Command {
Ok(())
}

fn clippy(features: Vec<String>, flags: Vec<String>) -> Result<()> {
fn clippy(mut features: Vec<String>, flags: Vec<String>) -> Result<()> {
features.push("check_only".into());
let e = MiriEnv::new()?;
e.clippy(".", &features, &flags)?;
e.clippy("cargo-miri", &[], &flags)?;
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 @@
7fefa09b90ca57b8a0e0e4717d672d38a0ae58b5
f57b9e6f565a1847e83a63f3e90faa3870536c1f
42 changes: 31 additions & 11 deletions src/tools/miri/src/alloc_addresses/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use rustc_middle::ty::TyCtxt;

pub use self::address_generator::AddressGenerator;
use self::reuse_pool::ReusePool;
use crate::alloc::MiriAllocParams;
use crate::concurrency::VClock;
use crate::diagnostics::SpanDedupDiagnostic;
use crate::*;
Expand Down Expand Up @@ -162,18 +163,28 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
this.get_alloc_bytes_unchecked_raw(alloc_id)?
}
}
AllocKind::Function | AllocKind::VTable => {
// Allocate some dummy memory to get a unique address for this function/vtable.
let alloc_bytes = MiriAllocBytes::from_bytes(
&[0u8; 1],
Align::from_bytes(1).unwrap(),
params,
);
let ptr = alloc_bytes.as_ptr();
// Leak the underlying memory to ensure it remains unique.
std::mem::forget(alloc_bytes);
ptr
#[cfg(all(unix, feature = "native-lib"))]
AllocKind::Function => {
if let Some(GlobalAlloc::Function { instance, .. }) =
this.tcx.try_get_global_alloc(alloc_id)
{
let fn_sig = this.tcx.fn_sig(instance.def_id()).skip_binder().skip_binder();
let fn_ptr = crate::shims::native_lib::build_libffi_closure(this, fn_sig)?;

#[expect(
clippy::as_conversions,
reason = "No better way to cast a function ptr to a ptr"
)]
{
fn_ptr as *const _
}
} else {
dummy_alloc(params)
}
}
#[cfg(not(all(unix, feature = "native-lib")))]
AllocKind::Function => dummy_alloc(params),
AllocKind::VTable => dummy_alloc(params),
AllocKind::TypeId | AllocKind::Dead => unreachable!(),
};
// We don't have to expose this pointer yet, we do that in `prepare_for_native_call`.
Expand Down Expand Up @@ -205,6 +216,15 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
}
}

fn dummy_alloc(params: MiriAllocParams) -> *const u8 {
// Allocate some dummy memory to get a unique address for this function/vtable.
let alloc_bytes = MiriAllocBytes::from_bytes(&[0u8; 1], Align::from_bytes(1).unwrap(), params);
let ptr = alloc_bytes.as_ptr();
// Leak the underlying memory to ensure it remains unique.
std::mem::forget(alloc_bytes);
ptr
}

impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
// Returns the `AllocId` that corresponds to the specified addr,
Expand Down
13 changes: 0 additions & 13 deletions src/tools/miri/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ pub enum NonHaltingDiagnostic {
NativeCallSharedMem {
tracing: bool,
},
NativeCallFnPtr,
WeakMemoryOutdatedLoad {
ptr: Pointer,
},
Expand Down Expand Up @@ -643,11 +642,6 @@ impl<'tcx> MiriMachine<'tcx> {
Int2Ptr { .. } => ("integer-to-pointer cast".to_string(), DiagLevel::Warning),
NativeCallSharedMem { .. } =>
("sharing memory with a native function".to_string(), DiagLevel::Warning),
NativeCallFnPtr =>
(
"sharing a function pointer with a native function".to_string(),
DiagLevel::Warning,
),
ExternTypeReborrow =>
("reborrow of reference to `extern type`".to_string(), DiagLevel::Warning),
GenmcCompareExchangeWeak | GenmcCompareExchangeOrderingMismatch { .. } =>
Expand Down Expand Up @@ -686,8 +680,6 @@ impl<'tcx> MiriMachine<'tcx> {
Int2Ptr { .. } => format!("integer-to-pointer cast"),
NativeCallSharedMem { .. } =>
format!("sharing memory with a native function called via FFI"),
NativeCallFnPtr =>
format!("sharing a function pointer with a native function called via FFI"),
WeakMemoryOutdatedLoad { ptr } =>
format!("weak memory emulation: outdated value returned from load at {ptr}"),
ExternTypeReborrow =>
Expand Down Expand Up @@ -785,11 +777,6 @@ impl<'tcx> MiriMachine<'tcx> {
),
]
},
NativeCallFnPtr => {
vec![note!(
"calling Rust functions from C is not supported and will, in the best case, crash the program"
)]
}
ExternTypeReborrow => {
assert!(self.borrow_tracker.as_ref().is_some_and(|b| {
matches!(
Expand Down
Loading
Loading