Skip to content

Commit 72505ea

Browse files
authored
cpufeatures: support freestanding/UEFI x86 targets (#821)
This fixes compilation of dependent crates for these targets. For example, `sha2`: Before: ``` $ cargo build --target x86_64-unknown-none --no-default-features Compiling sha2 v0.10.6 (/home/rvolosatovs/src/github.com/rustcrypto/hashes/sha2) LLVM ERROR: Do not know how to split the result of this operator! error: could not compile `sha2` $ cargo build --target x86_64-unknown-uefi --no-default-features Compiling sha2 v0.10.6 (/home/rvolosatovs/src/github.com/rustcrypto/hashes/sha2) LLVM ERROR: Do not know how to split the result of this operator! error: could not compile `sha2` ``` After: ``` $ cargo build --target x86_64-unknown-none --no-default-features Compiling cpufeatures v0.2.5 (/home/rvolosatovs/src/github.com/rustcrypto/utils/cpufeatures) Compiling sha2 v0.10.6 (/home/rvolosatovs/src/github.com/rustcrypto/hashes/sha2) Finished dev [optimized + debuginfo] target(s) in 0.19s $ cargo build --target x86_64-unknown-uefi --no-default-features Compiling cpufeatures v0.2.5 (/home/rvolosatovs/src/github.com/rustcrypto/utils/cpufeatures) Compiling sha2 v0.10.6 (/home/rvolosatovs/src/github.com/rustcrypto/hashes/sha2) Finished dev [optimized + debuginfo] target(s) in 0.19s ``` Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
1 parent b326398 commit 72505ea

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cpufeatures/src/x86.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ 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(target_env = "sgx", target_os = "none", target_os = "uefi")))]
1818
$body
1919

20-
// CPUID is not available on SGX targets
21-
#[cfg(target_env = "sgx")]
20+
// CPUID is not available on SGX. Freestanding and UEFI targets
21+
// do not support SIMD features with default compilation flags.
22+
#[cfg(any(target_env = "sgx", target_os = "none", target_os = "uefi"))]
2223
false
2324
}
2425

0 commit comments

Comments
 (0)