From 6c69496fb9352750e61cf25034691c56e4186005 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=9F=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=BE=D0=B2=20=5BArtyom=20Pavlov=5D?= Date: Fri, 19 Sep 2025 17:26:45 +0300 Subject: [PATCH] Add `custom-fallback` crate feature --- Cargo.toml | 4 ++++ src/backends.rs | 3 +++ 2 files changed, 7 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 33322a04..062adc6f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,10 @@ exclude = [".*"] # use std to retrieve OS error descriptions std = [] +# Use the custom backend on unsupported targets +# WARNING: this feature SHOULD be enabled only by fallback implementation crates! +custom-fallback = [] + # Optional backend: wasm_js # This flag enables the backend but does not select it. To use the backend, use # this flag *and* set getrandom_backend=wasm_js (see README). diff --git a/src/backends.rs b/src/backends.rs index d7b73cec..dbd22e05 100644 --- a/src/backends.rs +++ b/src/backends.rs @@ -182,6 +182,9 @@ cfg_if! { } else if #[cfg(all(target_arch = "x86_64", target_env = "sgx"))] { mod rdrand; pub use rdrand::*; + } else if #[cfg(feature = "custom-fallback")] { + mod custom; + pub use custom::*; } else if #[cfg(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "none")))] { compile_error!(concat!( "The wasm32-unknown-unknown targets are not supported by default; \