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 <joerichey@google.com>
This commit is contained in:
committed by
Joseph Richey
parent
a29180afcd
commit
618593ca03
+2
-2
@@ -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: \
|
||||
|
||||
Reference in New Issue
Block a user