From cd56f52bd69ad6a58c1dd4282e0d26ca0e4a92bb Mon Sep 17 00:00:00 2001 From: Bob Peterson Date: Mon, 13 Oct 2025 12:57:13 -0500 Subject: [PATCH] Add cfg attributes for running under Miri --- cli/main.rs | 2 +- core/ext/mod.rs | 4 ++-- core/io/mod.rs | 6 +++--- core/lib.rs | 6 +++--- core/storage/buffer_pool.rs | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cli/main.rs b/cli/main.rs index 5b5f98e2f..a9a4eeb89 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -16,7 +16,7 @@ use std::{ sync::{atomic::Ordering, LazyLock}, }; -#[cfg(not(target_family = "wasm"))] +#[cfg(all(not(target_family = "wasm"), not(miri)))] #[global_allocator] static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; diff --git a/core/ext/mod.rs b/core/ext/mod.rs index 1d73c3ba2..d58c86909 100644 --- a/core/ext/mod.rs +++ b/core/ext/mod.rs @@ -2,7 +2,7 @@ mod dynamic; mod vtab_xconnect; use crate::schema::{Schema, Table}; -#[cfg(all(target_os = "linux", feature = "io_uring"))] +#[cfg(all(target_os = "linux", feature = "io_uring", not(miri)))] use crate::UringIO; use crate::{function::ExternalFunc, Connection, Database}; use crate::{vtab::VirtualTable, SymbolTable}; @@ -146,7 +146,7 @@ impl Database { let io: Arc = match vfs { "memory" => Arc::new(MemoryIO::new()), "syscall" => Arc::new(SyscallIO::new()?), - #[cfg(all(target_os = "linux", feature = "io_uring"))] + #[cfg(all(target_os = "linux", feature = "io_uring", not(miri)))] "io_uring" => Arc::new(UringIO::new()?), other => match get_vfs_modules().iter().find(|v| v.0 == vfs) { Some((_, vfs)) => vfs.clone(), diff --git a/core/io/mod.rs b/core/io/mod.rs index c1940e191..0c0baa807 100644 --- a/core/io/mod.rs +++ b/core/io/mod.rs @@ -717,13 +717,13 @@ impl TempBufferCache { } cfg_block! { - #[cfg(all(target_os = "linux", feature = "io_uring"))] { + #[cfg(all(target_os = "linux", feature = "io_uring", not(miri)))] { mod io_uring; #[cfg(feature = "fs")] pub use io_uring::UringIO; } - #[cfg(target_family = "unix")] { + #[cfg(all(target_family = "unix", not(miri)))] { mod unix; #[cfg(feature = "fs")] pub use unix::UnixIO; @@ -731,7 +731,7 @@ cfg_block! { pub use PlatformIO as SyscallIO; } - #[cfg(not(any(target_family = "unix", target_os = "android", target_os = "ios")))] { + #[cfg(any(not(any(target_family = "unix", target_os = "android", target_os = "ios")), miri))] { mod generic; pub use generic::GenericIO as PlatformIO; pub use PlatformIO as SyscallIO; diff --git a/core/lib.rs b/core/lib.rs index 8f6d91d4e..2a0a558cf 100644 --- a/core/lib.rs +++ b/core/lib.rs @@ -53,9 +53,9 @@ use crate::{incremental::view::AllViewsTxState, translate::emitter::TransactionM use core::str; pub use error::{CompletionError, LimboError}; pub use io::clock::{Clock, Instant}; -#[cfg(all(feature = "fs", target_family = "unix"))] +#[cfg(all(feature = "fs", target_family = "unix", not(miri)))] pub use io::UnixIO; -#[cfg(all(feature = "fs", target_os = "linux", feature = "io_uring"))] +#[cfg(all(feature = "fs", target_os = "linux", feature = "io_uring", not(miri)))] pub use io::UringIO; pub use io::{ Buffer, Completion, CompletionType, File, GroupCompletion, MemoryIO, OpenFlags, PlatformIO, @@ -791,7 +791,7 @@ impl Database { None => match vfs.as_ref() { "memory" => Arc::new(MemoryIO::new()), "syscall" => Arc::new(SyscallIO::new()?), - #[cfg(all(target_os = "linux", feature = "io_uring"))] + #[cfg(all(target_os = "linux", feature = "io_uring", not(miri)))] "io_uring" => Arc::new(UringIO::new()?), other => { return Err(LimboError::InvalidArgument(format!("no such VFS: {other}"))); diff --git a/core/storage/buffer_pool.rs b/core/storage/buffer_pool.rs index 05fe77d6a..106c9bc8c 100644 --- a/core/storage/buffer_pool.rs +++ b/core/storage/buffer_pool.rs @@ -427,7 +427,7 @@ impl Arena { } } -#[cfg(unix)] +#[cfg(all(unix, not(miri)))] mod arena { #[cfg(target_vendor = "apple")] use libc::MAP_ANON as MAP_ANONYMOUS; @@ -463,7 +463,7 @@ mod arena { } } -#[cfg(not(unix))] +#[cfg(any(not(unix), miri))] mod arena { pub fn alloc(len: usize) -> *mut u8 { let layout = std::alloc::Layout::from_size_align(len, std::mem::size_of::()).unwrap();