summaryrefslogtreecommitdiff
path: root/lang/rust
diff options
context:
space:
mode:
authortnn <tnn@pkgsrc.org>2019-06-13 19:06:30 +0000
committertnn <tnn@pkgsrc.org>2019-06-13 19:06:30 +0000
commit140d97f81d325823f6f40e4c6d7bc94ea09606b7 (patch)
tree4e3b549ac5b42a5ab4214628731fad8d20898785 /lang/rust
parentab35a8074b858a00f9e452d85d8c53cd25d0c82e (diff)
downloadpkgsrc-140d97f81d325823f6f40e4c6d7bc94ea09606b7.tar.gz
rust: work around problem in rand vendor crate that made rustc very slow
... on some NetBSD hosts. To be discussed with upstream.
Diffstat (limited to 'lang/rust')
-rw-r--r--lang/rust/Makefile5
-rw-r--r--lang/rust/distinfo4
-rw-r--r--lang/rust/patches/patch-vendor_rand_src_rngs_os.rs96
3 files changed, 96 insertions, 9 deletions
diff --git a/lang/rust/Makefile b/lang/rust/Makefile
index 0ced0e50342..1a6cc25c972 100644
--- a/lang/rust/Makefile
+++ b/lang/rust/Makefile
@@ -1,6 +1,7 @@
-# $NetBSD: Makefile,v 1.103 2019/06/02 22:12:39 he Exp $
+# $NetBSD: Makefile,v 1.104 2019/06/13 19:06:30 tnn Exp $
DISTNAME= rustc-1.35.0-src
+PKGREVISION= 1
PKGNAME= ${DISTNAME:S/rustc/rust/:S/-src//}
CATEGORIES= lang
MASTER_SITES= http://static.rust-lang.org/dist/
@@ -308,7 +309,7 @@ post-extract:
# patch(1) in NetBSD does not handle .cargo-checksum.json like long width file.
${CP} ${WRKSRC}/vendor/rand/.cargo-checksum.json \
${WRKSRC}/vendor/rand/.cargo-checksum.json.orig
- ${SED} -e 's/1e732c2e3b4bd1561f11e0979bf9d20669a96eae7afe0deff9dfbb980ee47bf1/55abd8100db14a076dedbf84ce0f2db08158e1bd33ff1d4978bd3c4ad978f281/' ${WRKSRC}/vendor/rand/.cargo-checksum.json.orig > ${WRKSRC}/vendor/rand/.cargo-checksum.json
+ ${SED} -e 's/1e732c2e3b4bd1561f11e0979bf9d20669a96eae7afe0deff9dfbb980ee47bf1/bc03f2345d7cfa7000f9da817120b6afa073359789c21a9a790ebd8676c50cca/' ${WRKSRC}/vendor/rand/.cargo-checksum.json.orig > ${WRKSRC}/vendor/rand/.cargo-checksum.json
${CP} ${WRKSRC}/vendor/libc/.cargo-checksum.json \
${WRKSRC}/vendor/libc/.cargo-checksum.json.orig
${SED} -e 's/c6a740dac9af99321f48d5c9e86c6a4f5dcc611c413263881764f7121c1f7e9d/01ca1e6a21f01efd9d4b2768c1f9bcfab829e95a23d88cd35bf4e0172c672f3a/' ${WRKSRC}/vendor/libc/.cargo-checksum.json.orig > ${WRKSRC}/vendor/libc/.cargo-checksum.json
diff --git a/lang/rust/distinfo b/lang/rust/distinfo
index 30de2127957..011b691c377 100644
--- a/lang/rust/distinfo
+++ b/lang/rust/distinfo
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.79 2019/06/02 22:50:04 ryoon Exp $
+$NetBSD: distinfo,v 1.80 2019/06/13 19:06:30 tnn Exp $
SHA1 (rust-1.34.2-i686-apple-darwin.tar.gz) = 1c7f71c554dd4cffc4bdbdf291234292c5fcc9ad
RMD160 (rust-1.34.2-i686-apple-darwin.tar.gz) = e1f3228f63a2580d7980f28e10e3f4fa34f63dac
@@ -127,4 +127,4 @@ SHA1 (patch-src_tools_rls_rls_src_server_io.rs) = 51af64526db55abcf6b4b3165df314
SHA1 (patch-src_tools_rust-installer_install-template.sh) = f2ec6dced2be1fa23773d5827503ad07d0913dc2
SHA1 (patch-vendor_backtrace-sys_src_libbacktrace_configure) = 90e54f66edce65ebe23fbf2480deb193ca926733
SHA1 (patch-vendor_libc_src_unix_solarish_mod.rs) = 804ea03be546fef0d2bd37d7f8abb26d38a7892b
-SHA1 (patch-vendor_rand_src_rngs_os.rs) = 7a1c6d91d9418e1f8e378c4baca33045cc768f2d
+SHA1 (patch-vendor_rand_src_rngs_os.rs) = ae78f9e8abfa5a223bceac5ac8bbe25453dc70c0
diff --git a/lang/rust/patches/patch-vendor_rand_src_rngs_os.rs b/lang/rust/patches/patch-vendor_rand_src_rngs_os.rs
index f4907403b3c..50f9f0adb93 100644
--- a/lang/rust/patches/patch-vendor_rand_src_rngs_os.rs
+++ b/lang/rust/patches/patch-vendor_rand_src_rngs_os.rs
@@ -1,11 +1,88 @@
-$NetBSD: patch-vendor_rand_src_rngs_os.rs,v 1.1 2019/01/22 09:17:15 jperkin Exp $
+$NetBSD: patch-vendor_rand_src_rngs_os.rs,v 1.2 2019/06/13 19:06:30 tnn Exp $
-Explicitly disable getrandom support on SunOS, the test fails.
-https://github.com/rust-random/rand/issues/637
+-Explicitly disable getrandom support on SunOS, the test fails.
+-https://github.com/rust-random/rand/issues/637
---- vendor/rand/src/rngs/os.rs.orig 2019-01-16 11:06:08.000000000 +0000
+The rand implementation for NetBSD drains a byte from /dev/random on every
+rustc invocation, with the intent to ensure /dev/urandom is seeded.
+This is inappropriate; seeding the rng should be handled by rc.d scripts only.
+The result is that rustc eventually blocks for very long times when generating
+temp file names, causing the lang/rust build to take days(!) in some cases.
+The fix is to delete the NetBSD specific implementation and instead use the
+FreeBSD implementation which relies on the kern.arandom sysctl instead of
+/dev/{u,}random.
+The bootstrap compiler of course has the same issue so I will raise a PR
+with upstream authors to address this.
+
+--- vendor/rand/src/rngs/os.rs.orig 2019-05-20 13:47:25.000000000 +0000
+++ vendor/rand/src/rngs/os.rs
-@@ -675,6 +675,7 @@ mod imp {
+@@ -246,7 +246,7 @@ trait OsRngImpl where Self: Sized {
+ // All instances use a single internal file handle, to prevent possible
+ // exhaustion of file descriptors.
+ #[cfg(any(target_os = "linux", target_os = "android",
+- target_os = "netbsd", target_os = "dragonfly",
++ target_os = "dragonfly",
+ target_os = "solaris", target_os = "redox",
+ target_os = "haiku", target_os = "emscripten"))]
+ mod random_device {
+@@ -487,56 +487,6 @@ mod imp {
+ }
+ }
+
+-
+-#[cfg(target_os = "netbsd")]
+-mod imp {
+- use Error;
+- use super::random_device;
+- use super::OsRngImpl;
+-
+- use std::fs::File;
+- use std::io::Read;
+- use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering};
+-
+- #[derive(Clone, Debug)]
+- pub struct OsRng { initialized: bool }
+-
+- impl OsRngImpl for OsRng {
+- fn new() -> Result<OsRng, Error> {
+- random_device::open("/dev/urandom", &|p| File::open(p))?;
+- Ok(OsRng { initialized: false })
+- }
+-
+- fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> {
+- random_device::read(dest)
+- }
+-
+- // Read a single byte from `/dev/random` to determine if the OS RNG is
+- // already seeded. NetBSD always blocks if not yet ready.
+- fn test_initialized(&mut self, dest: &mut [u8], _blocking: bool)
+- -> Result<usize, Error>
+- {
+- static OS_RNG_INITIALIZED: AtomicBool = ATOMIC_BOOL_INIT;
+- if !self.initialized {
+- self.initialized = OS_RNG_INITIALIZED.load(Ordering::Relaxed);
+- }
+- if self.initialized { return Ok(0); }
+-
+- info!("OsRng: testing random device /dev/random");
+- let mut file =
+- File::open("/dev/random").map_err(random_device::map_err)?;
+- file.read(&mut dest[..1]).map_err(random_device::map_err)?;
+-
+- OS_RNG_INITIALIZED.store(true, Ordering::Relaxed);
+- self.initialized = true;
+- Ok(1)
+- }
+-
+- fn method_str(&self) -> &'static str { "/dev/urandom" }
+- }
+-}
+-
+-
+ #[cfg(any(target_os = "dragonfly",
+ target_os = "haiku",
+ target_os = "emscripten"))]
+@@ -677,6 +627,7 @@ mod imp {
}
fn getrandom(buf: &mut [u8], blocking: bool) -> libc::c_long {
@@ -13,3 +90,12 @@ https://github.com/rust-random/rand/issues/637
extern "C" {
fn syscall(number: libc::c_long, ...) -> libc::c_long;
}
+@@ -824,7 +775,7 @@ mod imp {
+ }
+
+
+-#[cfg(target_os = "freebsd")]
++#[cfg(any(target_os = "freebsd", target_os = "netbsd"))]
+ mod imp {
+ extern crate libc;
+