Skip to content

Commit 5130d5d

Browse files
committed
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 <[email protected]>
1 parent a29180a commit 5130d5d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,11 @@ cfg_if! {
183183
#[path = "windows.rs"] mod imp;
184184
} else if #[cfg(all(target_arch = "x86_64", target_env = "sgx"))] {
185185
#[path = "rdrand.rs"] mod imp;
186-
} else if #[cfg(feature = "custom")] {
187-
use custom as imp;
188186
} else if #[cfg(all(feature = "cpu",
189187
any(target_arch = "x86_64", target_arch = "x86")))] {
190188
#[path = "rdrand.rs"] mod imp;
189+
} else if #[cfg(feature = "custom")] {
190+
use custom as imp;
191191
} else {
192192
compile_error!("\
193193
target is not supported, for more information see: \

0 commit comments

Comments
 (0)