Skip to content

Commit d2ca769

Browse files
authored
Fix Solaris/OpenBSD/Dragonfly build and re-enable CI (#301)
Fixes #216 This also adds two minor CI improvements: - Do a full link on `freebsd` - Build, Link, but don't run on `illumos` - Use the stable toolchain for our Tier 2 Build-only targets - Build (via `build-std`) for Tier 3 targets: `openbsd`, `dragonfly`, `haiku` Signed-off-by: Joe Richey <[email protected]>
1 parent f7b7330 commit d2ca769

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

.github/workflows/tests.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,9 @@ jobs:
166166
strategy:
167167
matrix:
168168
target: [
169-
# See: https://github.com/rust-random/getrandom/issues/254
170-
# sparcv9-sun-solaris,
169+
sparcv9-sun-solaris,
170+
x86_64-unknown-illumos,
171+
x86_64-unknown-freebsd,
171172
x86_64-unknown-netbsd,
172173
]
173174
steps:
@@ -277,7 +278,6 @@ jobs:
277278
strategy:
278279
matrix:
279280
target: [
280-
x86_64-unknown-freebsd,
281281
x86_64-fuchsia,
282282
x86_64-unknown-redox,
283283
x86_64-fortanix-unknown-sgx,
@@ -288,7 +288,7 @@ jobs:
288288
with:
289289
profile: minimal
290290
target: ${{ matrix.target }}
291-
toolchain: nightly # Required to build libc for Redox
291+
toolchain: stable
292292
override: true
293293
- uses: Swatinem/rust-cache@v1
294294
- name: Build
@@ -319,6 +319,14 @@ jobs:
319319
run: cargo build -Z build-std=core --target=aarch64-kmc-solid_asp3
320320
- name: Nintendo 3DS
321321
run: cargo build -Z build-std=core --target=armv6k-nintendo-3ds
322+
- name: RISC-V ESP-IDF
323+
run: cargo build -Z build-std=core --target=riscv32imc-esp-espidf
324+
- name: OpenBSD
325+
run: cargo build -Z build-std=std --target=x86_64-unknown-openbsd --features=std
326+
- name: Dragonfly BSD
327+
run: cargo build -Z build-std=std --target=x86_64-unknown-dragonfly --features=std
328+
- name: Haiku OS
329+
run: cargo build -Z build-std=std --target=x86_64-unknown-haiku --features=std
322330

323331
clippy-fmt:
324332
name: Clippy + rustfmt

src/dragonfly.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{
1212
util_libc::{sys_fill_exact, Weak},
1313
Error,
1414
};
15-
use std::mem::MaybeUninit;
15+
use core::mem::MaybeUninit;
1616

1717
pub fn getrandom_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
1818
static GETRANDOM: Weak = unsafe { Weak::new("getrandom\0") };
@@ -21,7 +21,9 @@ pub fn getrandom_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
2121
// getrandom(2) was introduced in DragonflyBSD 5.7
2222
if let Some(fptr) = GETRANDOM.ptr() {
2323
let func: GetRandomFn = unsafe { core::mem::transmute(fptr) };
24-
return sys_fill_exact(dest, |buf| unsafe { func(buf.as_mut_ptr(), buf.len(), 0) });
24+
return sys_fill_exact(dest, |buf| unsafe {
25+
func(buf.as_mut_ptr() as *mut u8, buf.len(), 0)
26+
});
2527
} else {
2628
use_file::getrandom_inner(dest)
2729
}

src/openbsd.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
//! Implementation for OpenBSD
1010
use crate::{util_libc::last_os_error, Error};
11+
use core::mem::MaybeUninit;
1112

1213
pub fn getrandom_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
1314
// getentropy(2) was added in OpenBSD 5.6, so we can use it unconditionally.

src/solaris_illumos.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::{
2222
util_libc::{sys_fill_exact, Weak},
2323
Error,
2424
};
25-
use core::mem;
25+
use core::mem::{self, MaybeUninit};
2626

2727
#[cfg(target_os = "illumos")]
2828
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<u8>]) -> Result<(), Error> {
3838
// derived platforms for atomically obtaining random data.
3939
for chunk in dest.chunks_mut(256) {
4040
sys_fill_exact(chunk, |buf| unsafe {
41-
func(buf.as_mut_ptr(), buf.len(), 0) as libc::ssize_t
41+
func(buf.as_mut_ptr() as *mut u8, buf.len(), 0) as libc::ssize_t
4242
})?
4343
}
4444
Ok(())

0 commit comments

Comments
 (0)