From 3bd521786acf1b649a692d6c8a6c795fe02772c5 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Mon, 16 Mar 2026 13:47:42 -0700 Subject: [PATCH] Use windows backend for cygwin target. Cygwin's `getrandom` implementation is doing the job of the `getrandom` crate. Instead, we can just bypass it and do our own job ourselves. By default, use the `windows` backend, but also allow the `windows_legacy` backend to be used if requested. --- src/backends.rs | 3 +-- src/backends/windows_legacy.rs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/backends.rs b/src/backends.rs index 95547d9d3..441623bd1 100644 --- a/src/backends.rs +++ b/src/backends.rs @@ -112,7 +112,6 @@ cfg_if! { target_os = "freebsd", target_os = "hurd", target_os = "illumos", - target_os = "cygwin", // Check for target_arch = "arm" to only include the 3DS. Does not // include the Nintendo Switch (which is target_arch = "aarch64"). all(target_os = "horizon", target_arch = "arm"), @@ -161,7 +160,7 @@ cfg_if! { } else if #[cfg(all(windows, target_vendor = "win7"))] { mod windows_legacy; pub use windows_legacy::*; - } else if #[cfg(windows)] { + } else if #[cfg(any(windows, target_os = "cygwin"))] { mod windows; pub use windows::*; } else if #[cfg(all(target_arch = "x86_64", target_env = "sgx"))] { diff --git a/src/backends/windows_legacy.rs b/src/backends/windows_legacy.rs index 0e917015d..77786be30 100644 --- a/src/backends/windows_legacy.rs +++ b/src/backends/windows_legacy.rs @@ -14,7 +14,7 @@ use core::{ffi::c_void, mem::MaybeUninit}; pub use crate::util::{inner_u32, inner_u64}; -#[cfg(not(windows))] +#[cfg(not(any(windows, target_os = "cygwin")))] compile_error!("`windows_legacy` backend can be enabled only for Windows targets!"); // Binding to the Windows.Win32.Security.Authentication.Identity.RtlGenRandom