From 6da8a937e5d25482701c58a810dd02dbb6e504cd Mon Sep 17 00:00:00 2001 From: Roman Volosatovs Date: Mon, 12 Dec 2022 18:24:41 +0100 Subject: [PATCH 1/2] cpufeatures: support freestanding/UEFI `x86` targets 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 --- cpufeatures/src/x86.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cpufeatures/src/x86.rs b/cpufeatures/src/x86.rs index c973b744..d1c2a151 100644 --- a/cpufeatures/src/x86.rs +++ b/cpufeatures/src/x86.rs @@ -14,11 +14,11 @@ macro_rules! __unless_target_features { ($($tf:tt),+ => $body:expr ) => {{ #[cfg(not(all($(target_feature=$tf,)*)))] { - #[cfg(not(target_env = "sgx"))] + #[cfg(not(any(target_env = "sgx", target_os = "none", target_os = "uefi")))] $body - // CPUID is not available on SGX targets - #[cfg(target_env = "sgx")] + // CPUID is not available on SGX, freestanding and UEFI targets + #[cfg(any(target_env = "sgx", target_os = "none", target_os = "uefi"))] false } From d3e0ba6148fb21d6d75bb5845816dfb65e824620 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Wed, 19 Apr 2023 08:25:38 -0600 Subject: [PATCH 2/2] Update cpufeatures/src/x86.rs --- cpufeatures/src/x86.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpufeatures/src/x86.rs b/cpufeatures/src/x86.rs index d1c2a151..eb1c359e 100644 --- a/cpufeatures/src/x86.rs +++ b/cpufeatures/src/x86.rs @@ -17,7 +17,8 @@ macro_rules! __unless_target_features { #[cfg(not(any(target_env = "sgx", target_os = "none", target_os = "uefi")))] $body - // CPUID is not available on SGX, freestanding and UEFI targets + // CPUID is not available on SGX. Freestanding and UEFI targets + // do not support SIMD features with default compilation flags. #[cfg(any(target_env = "sgx", target_os = "none", target_os = "uefi"))] false }