Skip to content

Commit

Permalink
Merge branch 'master' into target_flags
Browse files Browse the repository at this point in the history
  • Loading branch information
dhardy committed Jan 3, 2025
2 parents a94fe50 + 9fb4a9a commit d898a78
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 81 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@ jobs:
- env:
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="linux_getrandom"
run: cargo build --target=${{ matrix.target }} --features=std
- env:
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="linux_rustix"
run: cargo build --target=${{ matrix.target }} --features=std
- env:
RUSTFLAGS: -Dwarnings --cfg getrandom_test_linux_fallback
run: cargo build --features=std
Expand Down
7 changes: 0 additions & 7 deletions .github/workflows/nopanic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@ jobs:
- name: Check (linux_android.rs)
run: (exit $( grep -c panic target/release/libgetrandom_wrapper.so ))

- name: Build (linux_rustix.rs)
env:
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="linux_rustix"
run: cargo build --release
- name: Check (linux_rustix.rs)
run: (exit $( grep -c panic target/release/libgetrandom_wrapper.so ))

- name: Build (rdrand.rs)
env:
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="rdrand"
Expand Down
35 changes: 17 additions & 18 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ jobs:
- env:
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="linux_getrandom"
run: cargo test --target=${{ matrix.target }} --features=std
- env:
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="linux_rustix"
run: cargo test --target=${{ matrix.target }} --features=std
- env:
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="linux_rustix"
run: cargo test --target=${{ matrix.target }} --features=rustix,std
Expand Down Expand Up @@ -199,21 +196,23 @@ jobs:
pkg_add rust
run: cargo test

netbsd:
name: NetBSD VM
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Test in NetBSD
uses: vmactions/netbsd-vm@v1
with:
envs: 'RUSTFLAGS'
usesh: true
prepare: |
/usr/sbin/pkg_add rust
run: |
cargo test
RUSTFLAGS="--cfg getrandom_test_netbsd_fallback -D warnings" cargo test
# Rust installation currently fails:
# https://github.com/rust-random/getrandom/actions/runs/12590976993/job/35093395247
# netbsd:
# name: NetBSD VM
# runs-on: ubuntu-24.04
# steps:
# - uses: actions/checkout@v4
# - name: Test in NetBSD
# uses: vmactions/netbsd-vm@v1
# with:
# envs: 'RUSTFLAGS'
# usesh: true
# prepare: |
# /usr/sbin/pkg_add rust
# run: |
# cargo test
# RUSTFLAGS="--cfg getrandom_test_netbsd_fallback -D warnings" cargo test

# This job currently fails:
# https://github.com/rust-random/getrandom/actions/runs/11405005618/job/31735653874?pr=528
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ jobs:
env:
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="linux_getrandom"
run: cargo clippy --target x86_64-unknown-linux-gnu
- name: Linux (linux_rustix.rs)
env:
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="linux_rustix"
run: cargo clippy --target x86_64-unknown-linux-gnu
- name: Linux (linux_android_with_fallback.rs)
run: cargo clippy --target x86_64-unknown-linux-gnu
- name: NetBSD (netbsd.rs)
Expand Down
2 changes: 0 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `getrandom_backend` configuration flag for selection of opt-in backends [#504]
- `Error::new_custom` method [#507]
- `rndr` opt-in backend [#512]
- `linux_rustix` opt-in backend [#520]
- Automatic MemorySanitizer support [#521] [#571]
- `u32` and `u64` functions for generating random values of the respective type [#544]

Expand All @@ -52,7 +51,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#504]: https://github.com/rust-random/getrandom/pull/504
[#507]: https://github.com/rust-random/getrandom/pull/507
[#512]: https://github.com/rust-random/getrandom/pull/512
[#520]: https://github.com/rust-random/getrandom/pull/520
[#521]: https://github.com/rust-random/getrandom/pull/521
[#522]: https://github.com/rust-random/getrandom/pull/522
[#532]: https://github.com/rust-random/getrandom/pull/532
Expand Down
8 changes: 2 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ core = { version = "1.0", optional = true, package = "rustc-std-workspace-core"
[target.'cfg(all(any(target_os = "linux", target_os = "android"), not(any(target_env = "", getrandom_backend = "custom"))))'.dependencies]
libc = { version = "0.2.154", default-features = false }

# linux_rustix
[target.'cfg(all(any(target_os = "linux", target_os = "android")))'.dependencies]
rustix = { version = "0.38.38", default-features = false, features = ["rand"], optional = true }

# apple-other
[target.'cfg(any(target_os = "ios", target_os = "visionos", target_os = "watchos", target_os = "tvos"))'.dependencies]
libc = { version = "0.2.154", default-features = false }
Expand Down Expand Up @@ -90,7 +86,7 @@ wasm-bindgen-test = "0.3"
[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = [
'cfg(getrandom_backend, values("custom", "rdrand", "rndr", "linux_getrandom", "linux_rustix", "wasm_js", "esp_idf"))',
'cfg(getrandom_backend, values("custom", "rdrand", "rndr", "linux_getrandom", "wasm_js", "esp_idf"))',
'cfg(getrandom_msan)',
'cfg(getrandom_test_linux_fallback)',
'cfg(getrandom_test_netbsd_fallback)',
Expand All @@ -103,7 +99,7 @@ features = ["std"]
[package.metadata.cross.target.x86_64-unknown-netbsd]
pre-build = [
"mkdir -p /tmp/netbsd",
"curl https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.2/amd64/binary/sets/base.tar.xz -O",
"curl -fO https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.3/amd64/binary/sets/base.tar.xz",
"tar -C /tmp/netbsd -xJf base.tar.xz",
"cp /tmp/netbsd/usr/lib/libexecinfo.so /usr/local/x86_64-unknown-netbsd/lib",
"rm base.tar.xz",
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn get_random_u128() -> Result<u128, getrandom::Error> {
| WASI 0.2 | `wasm32‑wasip2` | [`get-random-u64`]
| SOLID | `*-kmc-solid_*` | `SOLID_RNG_SampleRandomBytes`
| Nintendo 3DS | `*-nintendo-3ds` | [`getrandom`][18]
| PS Vita | `*-vita-*` | [`getentropy`][13]
| PS Vita | `*-vita-*` | [`getentropy`][19]
| QNX Neutrino | `*‑nto-qnx*` | [`/dev/urandom`][14] (identical to `/dev/random`)
| AIX | `*-ibm-aix` | [`/dev/urandom`][15]

Expand All @@ -79,7 +79,6 @@ of randomness based on their specific needs:
| Backend name | Target | Target Triple | Implementation
| ----------------- | -------------------- | ------------------------ | --------------
| `linux_getrandom` | Linux, Android | `*‑linux‑*` | [`getrandom`][1] system call (without `/dev/urandom` fallback). Bumps minimum supported Linux kernel version to 3.17 and Android API level to 23 (Marshmallow).
| `linux_rustix` | Linux, Android | `*‑linux‑*` | Same as `linux_getrandom`, but uses [`rustix`] instead of `libc`. Requires feature `rustix`.
| `rdrand` | x86, x86-64 | `x86_64-*`, `i686-*` | [`RDRAND`] instruction
| `rndr` | AArch64 | `aarch64-*` | [`RNDR`] register
| `esp_idf` | ESP-IDF | `*‑espidf` | [`esp_fill_random`]. WARNING: can return low-quality entropy without proper hardware configuration!
Expand Down Expand Up @@ -328,6 +327,7 @@ dual licensed as above, without any additional terms or conditions.
[16]: https://man.netbsd.org/getrandom.2
[17]: https://www.gnu.org/software/libc/manual/html_mono/libc.html#index-getrandom
[18]: https://github.com/rust3ds/shim-3ds/commit/b01d2568836dea2a65d05d662f8e5f805c64389d
[19]: https://github.com/vitasdk/newlib/blob/2d869fe47aaf02b8e52d04e9a2b79d5b210fd016/newlib/libc/sys/vita/getentropy.c

[`ProcessPrng`]: https://learn.microsoft.com/en-us/windows/win32/seccng/processprng
[`RtlGenRandom`]: https://learn.microsoft.com/en-us/windows/win32/api/ntsecapi/nf-ntsecapi-rtlgenrandom
Expand All @@ -347,7 +347,6 @@ dual licensed as above, without any additional terms or conditions.
[platform-support]: https://doc.rust-lang.org/stable/rustc/platform-support.html
[WASI]: https://github.com/CraneStation/wasi
[Emscripten]: https://www.hellorust.com/setup/emscripten/
[`rustix`]: https://docs.rs/rustix

[//]: # (licenses)

Expand Down
6 changes: 0 additions & 6 deletions src/backends.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ cfg_if! {
} else if #[cfg(getrandom_backend = "linux_getrandom")] {
mod linux_android;
pub use linux_android::*;
} else if #[cfg(all(feature = "rustix", getrandom_backend = "linux_rustix"))] {
mod linux_rustix;
pub use linux_rustix::*;
} else if #[cfg(getrandom_backend = "rdrand")] {
mod rdrand;
pub use rdrand::*;
Expand Down Expand Up @@ -55,9 +52,6 @@ cfg_if! {
))] {
mod getrandom;
pub use getrandom::*;
} else if #[cfg(all(feature = "rustix", any(target_os = "android", target_os = "linux")))] {
mod linux_rustix;
pub use linux_rustix::*;
} else if #[cfg(any(
// Rust supports Android API level 19 (KitKat) [0] and the next upgrade targets
// level 21 (Lollipop) [1], while `getrandom(2)` was added only in
Expand Down
32 changes: 0 additions & 32 deletions src/backends/linux_rustix.rs

This file was deleted.

0 comments on commit d898a78

Please sign in to comment.