From afee98ab4a878b4d9176ac9dd6a8a657539d2861 Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Sun, 7 Jul 2019 01:12:58 -0700 Subject: [PATCH 1/4] Add support for hermit and l4re --- src/lib.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f3c065747..595e5daf5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -209,9 +209,12 @@ cfg_if! { #[path = "wasi.rs"] mod imp; } else if #[cfg(windows)] { #[path = "windows.rs"] mod imp; - } else if #[cfg(target_env = "sgx")] { - #[path = "rdrand.rs"] mod imp; - } else if #[cfg(all(target_arch = "x86_64", target_os = "uefi"))] { + } else if #[cfg(all(target_arch = "x86_64", any( + target_os = "hermit", + target_os = "l4re", + target_os = "uefi", + target_env = "sgx", + )))] { #[path = "rdrand.rs"] mod imp; } else if #[cfg(target_arch = "wasm32")] { cfg_if! { From d00efa9029c79c2b936ec52583acd99e7c21d823 Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Thu, 11 Jul 2019 12:32:11 -0700 Subject: [PATCH 2/4] Fix cfg guards for util_libc and error_impls --- src/lib.rs | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 595e5daf5..75a78245d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -152,12 +152,39 @@ pub use crate::error::Error; #[allow(dead_code)] mod util; -#[cfg(any(unix, target_os = "redox"))] +#[cfg(any( + target_os = "android", + target_os = "dragonfly", + target_os = "emscripten", + target_os = "freebsd", + target_os = "haiku", + target_os = "illumos", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd", + target_os = "redox", + target_os = "solaris", +))] #[allow(dead_code)] mod util_libc; // std-only trait definitions (also need for use_file) -#[cfg(any(feature = "std", unix, target_os = "redox"))] +#[cfg(any( + feature = "std", + target_os = "android", + target_os = "dragonfly", + target_os = "emscripten", + target_os = "freebsd", + target_os = "haiku", + target_os = "illumos", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd", + target_os = "redox", + target_os = "solaris", +))] mod error_impls; // These targets read from a file as a fallback method. From 61bc4896c22735f39db2d27a3506216ee3dab5da Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Thu, 11 Jul 2019 12:33:55 -0700 Subject: [PATCH 3/4] Add CI build check for new targets --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 7161f6976..8200f2b4f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -123,6 +123,8 @@ matrix: # - cargo build --target=x86_64-unknown-redox --all-features - cargo build --target=x86_64-fortanix-unknown-sgx --all-features - cargo xbuild --target=x86_64-unknown-uefi + - cargo xbuild --target=x86_64-unknown-hermit + - cargo xbuild --target=x86_64-unknown-l4re-uclibc # also test minimum dependency versions are usable - cargo generate-lockfile -Z minimal-versions - cargo build --target=x86_64-sun-solaris --all-features @@ -133,6 +135,8 @@ matrix: # - cargo build --target=x86_64-unknown-redox --all-features - cargo build --target=x86_64-fortanix-unknown-sgx --all-features - cargo xbuild --target=x86_64-unknown-uefi + - cargo xbuild --target=x86_64-unknown-hermit + - cargo xbuild --target=x86_64-unknown-l4re-uclibc # Trust cross-built/emulated targets. We must repeat all non-default values. - rust: stable From e871575e1166359880fb3193fff3d17e300bcb14 Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Thu, 11 Jul 2019 12:44:52 -0700 Subject: [PATCH 4/4] Update documentation --- src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 75a78245d..d98d85845 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,7 +25,8 @@ //! | Redox | [`rand:`][12] //! | CloudABI | [`cloudabi_sys_random_get`][13] //! | Haiku | `/dev/random` (identical to `/dev/urandom`) -//! | SGX, UEFI | [RDRAND][18] +//! | L4RE, SGX, UEFI | [RDRAND][18] +//! | Hermit | [RDRAND][18] as [`sys_rand`][22] is currently broken. //! | Web browsers | [`Crypto.getRandomValues`][14] (see [Support for WebAssembly and ams.js][14]) //! | Node.js | [`crypto.randomBytes`][15] (see [Support for WebAssembly and ams.js][16]) //! | WASI | [`__wasi_random_get`][17] @@ -119,6 +120,7 @@ //! [19]: https://www.unix.com/man-page/mojave/2/getentropy/ //! [20]: https://www.unix.com/man-page/mojave/4/random/ //! [21]: https://www.freebsd.org/cgi/man.cgi?query=getrandom&manpath=FreeBSD+12.0-stable +//! [22]: https://github.com/hermitcore/libhermit-rs/blob/09c38b0371cee6f56a541400ba453e319e43db53/src/syscalls/random.rs#L21 #![doc( html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png",