pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/lang/rust



Module Name:    pkgsrc
Committed By:   tnn
Date:           Thu Jun 13 19:06:30 UTC 2019

Modified Files:
        pkgsrc/lang/rust: Makefile distinfo
        pkgsrc/lang/rust/patches: patch-vendor_rand_src_rngs_os.rs

Log Message:
rust: work around problem in rand vendor crate that made rustc very slow

... on some NetBSD hosts. To be discussed with upstream.


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 pkgsrc/lang/rust/Makefile
cvs rdiff -u -r1.79 -r1.80 pkgsrc/lang/rust/distinfo
cvs rdiff -u -r1.1 -r1.2 \
    pkgsrc/lang/rust/patches/patch-vendor_rand_src_rngs_os.rs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/lang/rust/Makefile
diff -u pkgsrc/lang/rust/Makefile:1.103 pkgsrc/lang/rust/Makefile:1.104
--- pkgsrc/lang/rust/Makefile:1.103     Sun Jun  2 22:12:39 2019
+++ pkgsrc/lang/rust/Makefile   Thu Jun 13 19:06:30 2019
@@ -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

Index: pkgsrc/lang/rust/distinfo
diff -u pkgsrc/lang/rust/distinfo:1.79 pkgsrc/lang/rust/distinfo:1.80
--- pkgsrc/lang/rust/distinfo:1.79      Sun Jun  2 22:50:04 2019
+++ pkgsrc/lang/rust/distinfo   Thu Jun 13 19:06:30 2019
@@ -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
 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

Index: pkgsrc/lang/rust/patches/patch-vendor_rand_src_rngs_os.rs
diff -u pkgsrc/lang/rust/patches/patch-vendor_rand_src_rngs_os.rs:1.1 pkgsrc/lang/rust/patches/patch-vendor_rand_src_rngs_os.rs:1.2
--- pkgsrc/lang/rust/patches/patch-vendor_rand_src_rngs_os.rs:1.1       Tue Jan 22 09:17:15 2019
+++ pkgsrc/lang/rust/patches/patch-vendor_rand_src_rngs_os.rs   Thu Jun 13 19:06:30 2019
@@ -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/issu
          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;
+ 



Home | Main Index | Thread Index | Old Index