From 22f2afe21e5decae46ee76ee22aa10d51daaed4b Mon Sep 17 00:00:00 2001 From: Ed Barnard Date: Thu, 11 Apr 2019 13:47:27 +0100 Subject: [PATCH] Use SecRandomCopyBytes instead of /dev/urandom on MacOS --- src/libstd/build.rs | 2 +- src/libstd/sys/unix/rand.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libstd/build.rs b/src/libstd/build.rs index 726c27321538d..bb85ac4240286 100644 --- a/src/libstd/build.rs +++ b/src/libstd/build.rs @@ -30,7 +30,7 @@ fn main() { println!("cargo:rustc-link-lib=resolv"); } else if target.contains("apple-darwin") { println!("cargo:rustc-link-lib=System"); - + println!("cargo:rustc-link-lib=framework=Security"); // res_init and friends require -lresolv on macOS/iOS. // See #41582 and http://blog.achernya.com/2013/03/os-x-has-silly-libsystem.html println!("cargo:rustc-link-lib=resolv"); diff --git a/src/libstd/sys/unix/rand.rs b/src/libstd/sys/unix/rand.rs index 122f22b37a26b..7934c7f0c820c 100644 --- a/src/libstd/sys/unix/rand.rs +++ b/src/libstd/sys/unix/rand.rs @@ -12,6 +12,7 @@ pub fn hashmap_random_keys() -> (u64, u64) { } #[cfg(all(unix, + not(target_os = "macos"), not(target_os = "ios"), not(target_os = "openbsd"), not(target_os = "freebsd"), @@ -99,7 +100,7 @@ mod imp { } } -#[cfg(target_os = "ios")] +#[cfg(any(target_os = "macos", target_os = "ios"))] mod imp { use crate::io; use crate::ptr;