From e5ad181cdb50f30393a2efe484029b6d53e11110 Mon Sep 17 00:00:00 2001 From: David Knaack Date: Mon, 29 Aug 2022 13:51:42 +0200 Subject: [PATCH] Ignore `asm` feature on unsupported targets (#388) --- md5/Cargo.toml | 2 ++ md5/src/lib.rs | 4 ++-- sha1/Cargo.toml | 2 +- sha2/Cargo.toml | 2 +- whirlpool/Cargo.toml | 2 ++ whirlpool/src/lib.rs | 4 ++-- 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/md5/Cargo.toml b/md5/Cargo.toml index 594865af..9b71d348 100644 --- a/md5/Cargo.toml +++ b/md5/Cargo.toml @@ -16,6 +16,8 @@ name = "md5" [dependencies] digest = "0.10.3" + +[target.'cfg(any(target_arch = "x86", target_arch = "x86_64"))'.dependencies] md5-asm = { version = "0.5", optional = true } [dev-dependencies] diff --git a/md5/src/lib.rs b/md5/src/lib.rs index 0dcb14fd..3a997016 100644 --- a/md5/src/lib.rs +++ b/md5/src/lib.rs @@ -31,10 +31,10 @@ )] #![warn(missing_docs, rust_2018_idioms)] -#[cfg(feature = "asm")] +#[cfg(all(feature = "asm", any(target_arch = "x86", target_arch = "x86_64")))] extern crate md5_asm as compress; -#[cfg(not(feature = "asm"))] +#[cfg(not(all(feature = "asm", any(target_arch = "x86", target_arch = "x86_64"))))] mod compress; pub use digest::{self, Digest}; diff --git a/sha1/Cargo.toml b/sha1/Cargo.toml index 6627712a..1878d3e2 100644 --- a/sha1/Cargo.toml +++ b/sha1/Cargo.toml @@ -15,10 +15,10 @@ categories = ["cryptography", "no-std"] [dependencies] digest = "0.10.3" cfg-if = "1.0" -sha1-asm = { version = "0.5", optional = true } [target.'cfg(any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64"))'.dependencies] cpufeatures = "0.2" +sha1-asm = { version = "0.5", optional = true } [dev-dependencies] digest = { version = "0.10.3", features = ["dev"] } diff --git a/sha2/Cargo.toml b/sha2/Cargo.toml index cc4c783c..4f563f6e 100644 --- a/sha2/Cargo.toml +++ b/sha2/Cargo.toml @@ -17,10 +17,10 @@ categories = ["cryptography", "no-std"] [dependencies] digest = "0.10.3" cfg-if = "1.0" -sha2-asm = { version = "0.6.1", optional = true } [target.'cfg(any(target_arch = "aarch64", target_arch = "x86_64", target_arch = "x86"))'.dependencies] cpufeatures = "0.2" +sha2-asm = { version = "0.6.1", optional = true } [dev-dependencies] digest = { version = "0.10.3", features = ["dev"] } diff --git a/whirlpool/Cargo.toml b/whirlpool/Cargo.toml index 5844b701..573b28e4 100644 --- a/whirlpool/Cargo.toml +++ b/whirlpool/Cargo.toml @@ -13,6 +13,8 @@ categories = ["cryptography", "no-std"] [dependencies] digest = "0.10.3" + +[target.'cfg(any(target_arch = "x86", target_arch = "x86_64"))'.dependencies] whirlpool-asm = { version = "0.6", optional = true} [dev-dependencies] diff --git a/whirlpool/src/lib.rs b/whirlpool/src/lib.rs index 996c9b79..62f863ea 100644 --- a/whirlpool/src/lib.rs +++ b/whirlpool/src/lib.rs @@ -45,10 +45,10 @@ pub use digest::{self, Digest}; -#[cfg(not(feature = "asm"))] +#[cfg(not(all(feature = "asm", any(target_arch = "x86", target_arch = "x86_64"))))] mod compress; -#[cfg(feature = "asm")] +#[cfg(all(feature = "asm", any(target_arch = "x86", target_arch = "x86_64")))] use whirlpool_asm as compress; use compress::compress;