Skip to content

Commit 84ddd63

Browse files
committed
cpufeatures: cpuid isn't supported under miri
Miri is an interpreter and doesn't support inline assembly. Fortunately, we already have precedent for an x86 target without cpuid: SGX. Treat miri like SGX: only features that are enabled at compile time are available at run time.
1 parent 66c891d commit 84ddd63

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

cpufeatures/src/x86.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66
// Evaluate the given `$body` expression any of the supplied target features
77
// are not enabled. Otherwise returns true.
88
//
9-
// The `$body` expression is not evaluated on SGX targets, and returns false
10-
// on these targets unless *all* supplied target features are enabled.
9+
// The `$body` expression is not evaluated on SGX targets or under Miri, and
10+
// returns false on these targets unless *all* supplied features are enabled.
1111
#[macro_export]
1212
#[doc(hidden)]
1313
macro_rules! __unless_target_features {
1414
($($tf:tt),+ => $body:expr ) => {{
1515
#[cfg(not(all($(target_feature=$tf,)*)))]
1616
{
17-
#[cfg(not(target_env = "sgx"))]
17+
#[cfg(not(any(miri, target_env = "sgx")))]
1818
$body
1919

20-
// CPUID is not available on SGX targets
21-
#[cfg(target_env = "sgx")]
20+
// CPUID is not available in certain configurations.
21+
#[cfg(any(miri, target_env = "sgx"))]
2222
false
2323
}
2424

0 commit comments

Comments
 (0)