From fd401a1b92bfb1f5db309206eca4515607493d1b Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Fri, 8 Jul 2022 15:33:54 -0700 Subject: [PATCH] cpufeatures: Disable all target features under miri Miri is an interpreter, and though it tries to emulate the target CPU it does not support any target features. --- cpufeatures/src/lib.rs | 5 +++++ cpufeatures/src/miri.rs | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 cpufeatures/src/miri.rs diff --git a/cpufeatures/src/lib.rs b/cpufeatures/src/lib.rs index 08b6e528..b6c7c10b 100644 --- a/cpufeatures/src/lib.rs +++ b/cpufeatures/src/lib.rs @@ -59,13 +59,18 @@ html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg" )] +#[cfg(not(miri))] #[cfg(all(target_arch = "aarch64"))] #[doc(hidden)] pub mod aarch64; +#[cfg(not(miri))] #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] mod x86; +#[cfg(miri)] +mod miri; + #[cfg(not(any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")))] compile_error!("This crate works only on `aarch64`, `x86`, and `x86-64` targets."); diff --git a/cpufeatures/src/miri.rs b/cpufeatures/src/miri.rs new file mode 100644 index 00000000..8dff21c1 --- /dev/null +++ b/cpufeatures/src/miri.rs @@ -0,0 +1,20 @@ +//! Minimal miri support. +//! +//! Miri is an interpreter, and though it tries to emulate the target CPU +//! it does not support any target features. + +#[macro_export] +#[doc(hidden)] +macro_rules! __unless_target_features { + ($($tf:tt),+ => $body:expr ) => { + false + }; +} + +#[macro_export] +#[doc(hidden)] +macro_rules! __detect_target_features { + ($($tf:tt),+) => { + false + }; +}