Skip to content

Commit 583f758

Browse files
committed
Fix no_std and cross-platform build failures
- Add conditional import of get_arch_ops (only for supported architectures) - Remove feature = "std" guard from fusion module import (fusion works in no_std) - Add missing has_crc and has_sse42 fields to ArchCapabilities in no_std feature detection Fixes build failures for: - PowerPC targets (software fallback) - Embedded ARM targets (thumbv7em, thumbv8m, etc.) - WASM targets (wasm32-unknown-unknown, wasm32-wasip1, wasm32-wasip2)
1 parent ba21f5c commit 583f758

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/feature_detection.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,10 @@ unsafe fn detect_aarch64_features() -> ArchCapabilities {
175175
unsafe fn detect_aarch64_features() -> ArchCapabilities {
176176
ArchCapabilities {
177177
has_aes: cfg!(target_feature = "aes"),
178+
has_crc: cfg!(target_feature = "crc"),
178179
has_sha3: cfg!(target_feature = "sha3"),
179180
has_sse41: false,
181+
has_sse42: false,
180182
has_pclmulqdq: false,
181183
has_avx512vl: false,
182184
has_vpclmulqdq: false,
@@ -225,6 +227,7 @@ unsafe fn detect_x86_features() -> ArchCapabilities {
225227
let rust_version_supports_avx512 = check_rust_version_supports_avx512();
226228

227229
let has_sse41 = cfg!(target_feature = "sse4.1");
230+
let has_sse42 = cfg!(target_feature = "sse4.2");
228231
let has_pclmulqdq = has_sse41 && cfg!(target_feature = "pclmulqdq");
229232
let has_avx512vl =
230233
has_pclmulqdq && rust_version_supports_avx512 && cfg!(target_feature = "avx512vl");
@@ -233,8 +236,10 @@ unsafe fn detect_x86_features() -> ArchCapabilities {
233236

234237
ArchCapabilities {
235238
has_aes: false,
239+
has_crc: false,
236240
has_sha3: false,
237241
has_sse41,
242+
has_sse42,
238243
has_pclmulqdq,
239244
has_avx512vl,
240245
has_vpclmulqdq,

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ use crate::crc32::consts::{
194194
};
195195

196196
#[cfg(any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64"))]
197-
#[cfg(feature = "std")]
198197
use crate::crc32::fusion;
199198

200199
use crate::crc64::consts::{
@@ -207,6 +206,7 @@ use digest::DynDigest;
207206
#[cfg(feature = "alloc")]
208207
use digest::InvalidBufferSize;
209208

209+
#[cfg(any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64"))]
210210
use crate::feature_detection::get_arch_ops;
211211
#[cfg(feature = "std")]
212212
use std::fs::File;

0 commit comments

Comments
 (0)