From e263ea5b6ca199a13da5c5ce867616cd762047e9 Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Fri, 21 Oct 2022 17:21:37 -0700 Subject: [PATCH 1/6] Try to fix Solaris build Signed-off-by: Joe Richey --- .github/workflows/tests.yml | 3 +-- src/solaris_illumos.rs | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 210d67ba..46f8877e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -166,8 +166,7 @@ jobs: strategy: matrix: target: [ - # See: https://github.com/rust-random/getrandom/issues/254 - # sparcv9-sun-solaris, + sparcv9-sun-solaris, x86_64-unknown-netbsd, ] steps: diff --git a/src/solaris_illumos.rs b/src/solaris_illumos.rs index eaf27094..bf669fb6 100644 --- a/src/solaris_illumos.rs +++ b/src/solaris_illumos.rs @@ -22,7 +22,7 @@ use crate::{ util_libc::{sys_fill_exact, Weak}, Error, }; -use core::mem; +use core::mem::{self, MaybeUninit}; #[cfg(target_os = "illumos")] type GetRandomFn = unsafe extern "C" fn(*mut u8, libc::size_t, libc::c_uint) -> libc::ssize_t; @@ -38,7 +38,7 @@ pub fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error> { // derived platforms for atomically obtaining random data. for chunk in dest.chunks_mut(256) { sys_fill_exact(chunk, |buf| unsafe { - func(buf.as_mut_ptr(), buf.len(), 0) as libc::ssize_t + func(buf.as_mut_ptr() as *mut u8, buf.len(), 0) as libc::ssize_t })? } Ok(()) From 0b9a9ffb4a9022822cd61050906a6ef065327b85 Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Fri, 21 Oct 2022 17:26:12 -0700 Subject: [PATCH 2/6] Link tests on FreeBSD Signed-off-by: Joe Richey --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 46f8877e..adf7c448 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -167,6 +167,7 @@ jobs: matrix: target: [ sparcv9-sun-solaris, + x86_64-unknown-freebsd, x86_64-unknown-netbsd, ] steps: @@ -276,7 +277,6 @@ jobs: strategy: matrix: target: [ - x86_64-unknown-freebsd, x86_64-fuchsia, x86_64-unknown-redox, x86_64-fortanix-unknown-sgx, From f48994503ef628a5410b38347e97ee0e25e2273e Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Fri, 21 Oct 2022 17:38:44 -0700 Subject: [PATCH 3/6] Use stable toolchain for Tier-2 Build-only targets Signed-off-by: Joe Richey --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index adf7c448..9112523b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -287,7 +287,7 @@ jobs: with: profile: minimal target: ${{ matrix.target }} - toolchain: nightly # Required to build libc for Redox + toolchain: stable override: true - uses: Swatinem/rust-cache@v1 - name: Build From 2fa8cfcba1231c4cb34a8910866a9520ae197903 Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Fri, 21 Oct 2022 17:52:24 -0700 Subject: [PATCH 4/6] Link (but don't run) tests on Illumos Signed-off-by: Joe Richey --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9112523b..b9875945 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -167,6 +167,7 @@ jobs: matrix: target: [ sparcv9-sun-solaris, + x86_64-unknown-illumos, x86_64-unknown-freebsd, x86_64-unknown-netbsd, ] From 5673a613ddf974131649466c809459c379923c28 Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Fri, 21 Oct 2022 18:05:54 -0700 Subject: [PATCH 5/6] Add Build-Only CI for OpenBSD, Dragonfly, and Haiku Signed-off-by: Joe Richey --- .github/workflows/tests.yml | 6 ++++++ src/dragonfly.rs | 6 ++++-- src/openbsd.rs | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b9875945..ecf2ac7e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -319,6 +319,12 @@ jobs: run: cargo build -Z build-std=core --target=aarch64-kmc-solid_asp3 - name: Nintendo 3DS run: cargo build -Z build-std=core --target=armv6k-nintendo-3ds + - name: OpenBSD + run: cargo build -Z build-std=std --target=x86_64-unknown-openbsd --features=std + - name: Dragonfly BSD + run: cargo build -Z build-std=std --target=x86_64-unknown-dragonfly --features=std + - name: Haiku OS + run: cargo build -Z build-std=std --target=x86_64-unknown-haiku --features=std clippy-fmt: name: Clippy + rustfmt diff --git a/src/dragonfly.rs b/src/dragonfly.rs index c3701cc4..d3ef00aa 100644 --- a/src/dragonfly.rs +++ b/src/dragonfly.rs @@ -12,7 +12,7 @@ use crate::{ util_libc::{sys_fill_exact, Weak}, Error, }; -use std::mem::MaybeUninit; +use core::mem::MaybeUninit; pub fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error> { static GETRANDOM: Weak = unsafe { Weak::new("getrandom\0") }; @@ -21,7 +21,9 @@ pub fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error> { // getrandom(2) was introduced in DragonflyBSD 5.7 if let Some(fptr) = GETRANDOM.ptr() { let func: GetRandomFn = unsafe { core::mem::transmute(fptr) }; - return sys_fill_exact(dest, |buf| unsafe { func(buf.as_mut_ptr(), buf.len(), 0) }); + return sys_fill_exact(dest, |buf| unsafe { + func(buf.as_mut_ptr() as *mut u8, buf.len(), 0) + }); } else { use_file::getrandom_inner(dest) } diff --git a/src/openbsd.rs b/src/openbsd.rs index 5d4df50b..7a76f61d 100644 --- a/src/openbsd.rs +++ b/src/openbsd.rs @@ -8,6 +8,7 @@ //! Implementation for OpenBSD use crate::{util_libc::last_os_error, Error}; +use core::mem::MaybeUninit; pub fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error> { // getentropy(2) was added in OpenBSD 5.6, so we can use it unconditionally. From ade6f2c919c77e060e2b4548bfda4532b5c2cc87 Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Fri, 21 Oct 2022 18:12:49 -0700 Subject: [PATCH 6/6] Add espidf build to CI Signed-off-by: Joe Richey --- .github/workflows/tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ecf2ac7e..808aa8f0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -319,6 +319,8 @@ jobs: run: cargo build -Z build-std=core --target=aarch64-kmc-solid_asp3 - name: Nintendo 3DS run: cargo build -Z build-std=core --target=armv6k-nintendo-3ds + - name: RISC-V ESP-IDF + run: cargo build -Z build-std=core --target=riscv32imc-esp-espidf - name: OpenBSD run: cargo build -Z build-std=std --target=x86_64-unknown-openbsd --features=std - name: Dragonfly BSD