From 6a051b8e5e3e242bda0c82ee543a9da6cc981c0d Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Wed, 28 Oct 2020 13:08:07 -0700 Subject: [PATCH 1/6] Cleanup lib.rs This makes it easier to see what targets use which internal modules. It also makes our std-traits workaround more clear. Signed-off-by: Joe Richey --- src/lib.rs | 53 +++++++++++++++++++++++++++--------------------- src/util.rs | 2 +- src/util_libc.rs | 1 + 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index c30540623..4a1251bf4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -158,75 +158,82 @@ cfg_if! { mod error; pub use crate::error::Error; -#[allow(dead_code)] mod util; -#[cfg(target_os = "vxworks")] -#[allow(dead_code)] -mod util_libc; - -cfg_if! { - // Unlike the other Unix, Fuchsia and iOS don't use the libc to make any calls. - if #[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; - // Keep std-only trait definitions for backwards compatibility - mod error_impls; - } else if #[cfg(feature = "std")] { - mod error_impls; - } -} - -// These targets read from a file as a fallback method. +// For backwards compatibility, we provide the std-only trait implementations +// for some platforms, even if they don't enable the "std" feature. #[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", - target_os = "illumos", ))] -mod use_file; +mod error_impls; // System-specific implementations. // // These should all provide getrandom_inner with the same signature as getrandom. cfg_if! { if #[cfg(target_os = "android")] { + mod util_libc; + mod use_file; #[path = "linux_android.rs"] mod imp; } else if #[cfg(target_os = "cloudabi")] { #[path = "cloudabi.rs"] mod imp; } else if #[cfg(target_os = "dragonfly")] { + mod util_libc; #[path = "use_file.rs"] mod imp; } else if #[cfg(target_os = "emscripten")] { + mod util_libc; #[path = "use_file.rs"] mod imp; } else if #[cfg(target_os = "freebsd")] { + mod util_libc; #[path = "bsd_arandom.rs"] mod imp; } else if #[cfg(target_os = "fuchsia")] { #[path = "fuchsia.rs"] mod imp; } else if #[cfg(target_os = "haiku")] { + mod util_libc; #[path = "use_file.rs"] mod imp; } else if #[cfg(target_os = "illumos")] { + mod util_libc; + mod use_file; #[path = "solaris_illumos.rs"] mod imp; } else if #[cfg(target_os = "ios")] { #[path = "ios.rs"] mod imp; } else if #[cfg(target_os = "linux")] { + mod util_libc; + mod use_file; #[path = "linux_android.rs"] mod imp; } else if #[cfg(target_os = "macos")] { + mod util_libc; + mod use_file; #[path = "macos.rs"] mod imp; } else if #[cfg(target_os = "netbsd")] { + mod util_libc; #[path = "bsd_arandom.rs"] mod imp; } else if #[cfg(target_os = "openbsd")] { + mod util_libc; #[path = "openbsd.rs"] mod imp; } else if #[cfg(target_os = "redox")] { + mod util_libc; #[path = "use_file.rs"] mod imp; } else if #[cfg(target_os = "solaris")] { + mod util_libc; + mod use_file; #[path = "solaris_illumos.rs"] mod imp; } else if #[cfg(target_os = "wasi")] { #[path = "wasi.rs"] mod imp; } else if #[cfg(target_os = "vxworks")] { + mod util_libc; #[path = "vxworks.rs"] mod imp; } else if #[cfg(all(windows, getrandom_uwp))] { #[path = "windows_uwp.rs"] mod imp; diff --git a/src/util.rs b/src/util.rs index 8dbd8ae80..06e23c28c 100644 --- a/src/util.rs +++ b/src/util.rs @@ -5,7 +5,7 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. - +#![allow(dead_code)] use core::sync::atomic::{AtomicUsize, Ordering::Relaxed}; // This structure represents a lazily initialized static usize value. Useful diff --git a/src/util_libc.rs b/src/util_libc.rs index 1cdc13e5a..3cecb1dd6 100644 --- a/src/util_libc.rs +++ b/src/util_libc.rs @@ -5,6 +5,7 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] use crate::error::ERRNO_NOT_POSITIVE; use crate::util::LazyUsize; use crate::Error; From 1a3d206d02fe715c169ed8e33d14e5619deb3296 Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Wed, 28 Oct 2020 13:09:16 -0700 Subject: [PATCH 2/6] Enable std-trait workaround for windows/unix targets From `v0.1.0` to `v0.1.6` we had this enabled for windows/unix, and we inadvertantly removed it. Signed-off-by: Joe Richey --- src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 4a1251bf4..d418d148a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -164,12 +164,15 @@ mod util; // for some platforms, even if they don't enable the "std" feature. #[cfg(any( feature = "std", + windows, target_os = "android", target_os = "dragonfly", target_os = "emscripten", target_os = "freebsd", + target_os = "fuchsia", target_os = "haiku", target_os = "illumos", + target_os = "ios", target_os = "linux", target_os = "macos", target_os = "netbsd", From 14dd9ea3527582b5488d7bfdecddbdddc2dededb Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Wed, 28 Oct 2020 13:27:26 -0700 Subject: [PATCH 3/6] Enable CI for 0.1 branch Signed-off-by: Joe Richey --- .travis.yml | 1 + appveyor.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 6cebb8ea0..860671d0a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -229,3 +229,4 @@ notifications: branches: only: - master + - 0.1 diff --git a/appveyor.yml b/appveyor.yml index 7a34e3268..c176544bd 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -50,3 +50,4 @@ test_script: branches: only: - master + - 0.1 \ No newline at end of file From 696450f376121cfea53518499532fd80bac8d9af Mon Sep 17 00:00:00 2001 From: Artyom Pavlov Date: Wed, 2 Dec 2020 19:03:14 +0000 Subject: [PATCH 4/6] disable error impls for UWP targets --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index d418d148a..af55df58a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -164,7 +164,7 @@ mod util; // for some platforms, even if they don't enable the "std" feature. #[cfg(any( feature = "std", - windows, + all(windows, not(getrandom_uwp)), target_os = "android", target_os = "dragonfly", target_os = "emscripten", From e450ef5029a0a9c6b878edc5cf2a235f395768b9 Mon Sep 17 00:00:00 2001 From: Artyom Pavlov Date: Sat, 5 Dec 2020 21:19:56 +0000 Subject: [PATCH 5/6] disable CloudABI build --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 860671d0a..a9f597b7f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -145,7 +145,9 @@ matrix: - cargo build --target=x86_64-unknown-netbsd - cargo build --target=x86_64-unknown-redox - cargo build --target=x86_64-fortanix-unknown-sgx - - cargo xbuild --target=x86_64-unknown-cloudabi + # This builds currently fails with: + # Could not find specification for target "x86_64-unknown-cloudabi" + #- cargo xbuild --target=x86_64-unknown-cloudabi - cargo xbuild --target=x86_64-unknown-uefi - cargo xbuild --target=x86_64-unknown-hermit - cargo xbuild --target=x86_64-unknown-l4re-uclibc From 64b187a1e371b6c1d2dcd5605005afe16fbec534 Mon Sep 17 00:00:00 2001 From: Artyom Pavlov Date: Mon, 7 Dec 2020 04:15:10 +0000 Subject: [PATCH 6/6] disable Cloud ABI build (take 2) --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a9f597b7f..bac7be27b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -160,7 +160,7 @@ matrix: - cargo build --target=x86_64-unknown-netbsd - cargo build --target=x86_64-unknown-redox - cargo build --target=x86_64-fortanix-unknown-sgx - - cargo xbuild --target=x86_64-unknown-cloudabi + #- cargo xbuild --target=x86_64-unknown-cloudabi - cargo xbuild --target=x86_64-unknown-uefi - cargo xbuild --target=x86_64-unknown-hermit - cargo xbuild --target=x86_64-unknown-l4re-uclibc