Skip to content

Commit

Permalink
Switch to using the arandom sysctl on NetBSD (same as FreeBSD).
Browse files Browse the repository at this point in the history
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 sofware, or cause
it to fail entirely, especially in VMs (for example, our Xen package
building cluster).
  • Loading branch information
alarixnia committed Oct 20, 2019
1 parent 6b4925a commit ab8c75b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ cfg_if! {
} else if #[cfg(target_os = "emscripten")] {
#[path = "use_file.rs"] mod imp;
} else if #[cfg(target_os = "freebsd")] {
#[path = "freebsd.rs"] mod imp;
#[path = "sysctl_arandom.rs"] mod imp;
} else if #[cfg(target_os = "fuchsia")] {
#[path = "fuchsia.rs"] mod imp;
} else if #[cfg(target_os = "haiku")] {
Expand All @@ -212,7 +212,7 @@ cfg_if! {
} else if #[cfg(target_os = "macos")] {
#[path = "macos.rs"] mod imp;
} else if #[cfg(target_os = "netbsd")] {
#[path = "use_file.rs"] mod imp;
#[path = "sysctl_arandom.rs"] mod imp;
} else if #[cfg(target_os = "openbsd")] {
#[path = "openbsd.rs"] mod imp;
} else if #[cfg(target_os = "redox")] {
Expand Down
4 changes: 2 additions & 2 deletions src/freebsd.rs → src/sysctl_arandom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Implementation for FreeBSD
//! Implementation for FreeBSD and NetBSD
use crate::util_libc::{sys_fill_exact, Weak};
use crate::Error;
use core::{mem, ptr};
Expand All @@ -27,7 +27,7 @@ fn kern_arnd(buf: &mut [u8]) -> libc::ssize_t {
)
};
if ret == -1 {
error!("freebsd: kern.arandom syscall failed");
error!("sysctl_arandom: kern.arandom syscall failed");
-1
} else {
len as libc::ssize_t
Expand Down

0 comments on commit ab8c75b

Please sign in to comment.