From 618593ca03e91fb30ffc2b88aa7c6c92d7b9e9cf Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Wed, 27 May 2020 22:08:00 -0700 Subject: [PATCH] cpu: Have "cpu" feature take precedence over "custom" Right now, features are always enabled across all targets. This means that if _any_ Custom RNG is used _anywhere_ in a crate's dependancy graph on _any_ target. The "custom" feature will be active on all targets. This makes it impossible to have a bare metal target that uses "cpu" on x86_64 and a Custom RNG on aarch64. This solution also makes sure that any implementation `getrandom` itself provides cannot be overridden. Signed-off-by: Joe Richey --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 8a03009..b595b4b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -183,11 +183,11 @@ cfg_if! { #[path = "windows.rs"] mod imp; } else if #[cfg(all(target_arch = "x86_64", target_env = "sgx"))] { #[path = "rdrand.rs"] mod imp; - } else if #[cfg(feature = "custom")] { - use custom as imp; } else if #[cfg(all(feature = "cpu", any(target_arch = "x86_64", target_arch = "x86")))] { #[path = "rdrand.rs"] mod imp; + } else if #[cfg(feature = "custom")] { + use custom as imp; } else { compile_error!("\ target is not supported, for more information see: \