Skip to content

Commit 8e74aa5

Browse files
authored
cpufeatures: Disable all target features under miri (#779)
Miri is an interpreter, and though it tries to emulate the target CPU it does not support any target features.
1 parent 81536ee commit 8e74aa5

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

cpufeatures/src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,18 @@
5959
html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg"
6060
)]
6161

62+
#[cfg(not(miri))]
6263
#[cfg(all(target_arch = "aarch64"))]
6364
#[doc(hidden)]
6465
pub mod aarch64;
6566

67+
#[cfg(not(miri))]
6668
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
6769
mod x86;
6870

71+
#[cfg(miri)]
72+
mod miri;
73+
6974
#[cfg(not(any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")))]
7075
compile_error!("This crate works only on `aarch64`, `x86`, and `x86-64` targets.");
7176

cpufeatures/src/miri.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//! Minimal miri support.
2+
//!
3+
//! Miri is an interpreter, and though it tries to emulate the target CPU
4+
//! it does not support any target features.
5+
6+
#[macro_export]
7+
#[doc(hidden)]
8+
macro_rules! __unless_target_features {
9+
($($tf:tt),+ => $body:expr ) => {
10+
false
11+
};
12+
}
13+
14+
#[macro_export]
15+
#[doc(hidden)]
16+
macro_rules! __detect_target_features {
17+
($($tf:tt),+) => {
18+
false
19+
};
20+
}

0 commit comments

Comments
 (0)