Skip to content

Commit 02dad90

Browse files
committed
Switch to using the arandom sysctl on NetBSD (same as FreeBSD).
Rename it from freebsd.rs to sysctl_arandom.rs. NetBSD has been patching rustc for some time to use the FreeBSD implementation because every single invocation of the compiler may drain from the entropy pool and cause the next to block. This can massively inflate build times for rust software, or cause it to fail entirely, especially in VMs (for example, our Xen package building cluster).
1 parent 6b4925a commit 02dad90

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ cfg_if! {
198198
} else if #[cfg(target_os = "emscripten")] {
199199
#[path = "use_file.rs"] mod imp;
200200
} else if #[cfg(target_os = "freebsd")] {
201-
#[path = "freebsd.rs"] mod imp;
201+
#[path = "sysctl_arandom.rs"] mod imp;
202202
} else if #[cfg(target_os = "fuchsia")] {
203203
#[path = "fuchsia.rs"] mod imp;
204204
} else if #[cfg(target_os = "haiku")] {
@@ -212,7 +212,7 @@ cfg_if! {
212212
} else if #[cfg(target_os = "macos")] {
213213
#[path = "macos.rs"] mod imp;
214214
} else if #[cfg(target_os = "netbsd")] {
215-
#[path = "use_file.rs"] mod imp;
215+
#[path = "sysctl_arandom.rs"] mod imp;
216216
} else if #[cfg(target_os = "openbsd")] {
217217
#[path = "openbsd.rs"] mod imp;
218218
} else if #[cfg(target_os = "redox")] {

src/freebsd.rs renamed to src/sysctl_arandom.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// option. This file may not be copied, modified, or distributed
77
// except according to those terms.
88

9-
//! Implementation for FreeBSD
9+
//! Implementation for FreeBSD and NetBSD
1010
use crate::util_libc::{sys_fill_exact, Weak};
1111
use crate::Error;
1212
use core::{mem, ptr};
@@ -27,7 +27,7 @@ fn kern_arnd(buf: &mut [u8]) -> libc::ssize_t {
2727
)
2828
};
2929
if ret == -1 {
30-
error!("freebsd: kern.arandom syscall failed");
30+
error!("sysctl_arandom: kern.arandom syscall failed");
3131
-1
3232
} else {
3333
len as libc::ssize_t

0 commit comments

Comments
 (0)