Skip to content

Commit 4f34501

Browse files
authored
Rollup merge of rust-lang#59879 - ebarnard:patch-1, r=alexcrichton
Use SecRandomCopyBytes instead of /dev/urandom on MacOS SecRandomCopyBytes is [available since MacOS 10.7](https://developer.apple.com/documentation/security/1399291-secrandomcopybytes?language=objc) which is the minimum supported version and which was suggested in rust-lang#58901 (comment) is the earliest version currently in use. This matches the behaviour of other platforms which have a random number generator syscall available.
2 parents 009a41f + 22f2afe commit 4f34501

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/libstd/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fn main() {
3030
println!("cargo:rustc-link-lib=resolv");
3131
} else if target.contains("apple-darwin") {
3232
println!("cargo:rustc-link-lib=System");
33-
33+
println!("cargo:rustc-link-lib=framework=Security");
3434
// res_init and friends require -lresolv on macOS/iOS.
3535
// See #41582 and http://blog.achernya.com/2013/03/os-x-has-silly-libsystem.html
3636
println!("cargo:rustc-link-lib=resolv");

src/libstd/sys/unix/rand.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub fn hashmap_random_keys() -> (u64, u64) {
1212
}
1313

1414
#[cfg(all(unix,
15+
not(target_os = "macos"),
1516
not(target_os = "ios"),
1617
not(target_os = "openbsd"),
1718
not(target_os = "freebsd"),
@@ -99,7 +100,7 @@ mod imp {
99100
}
100101
}
101102

102-
#[cfg(target_os = "ios")]
103+
#[cfg(any(target_os = "macos", target_os = "ios"))]
103104
mod imp {
104105
use crate::io;
105106
use crate::ptr;

0 commit comments

Comments
 (0)