Skip to content

cannot find value getrandom in crate libc (mipsel-unknown-linux-musl) #4354

Closed
@brocaar

Description

@brocaar

It seems that libc::getrandom is not implemented for MIPS target(s). My code depends on rand v0.9.0, which depends on rand_core, which depends on getrandom which uses this crate to call libc::getrandom.

When building the getrandom dependency, it fails with the following error:

error[E0425]: cannot find value `getrandom` in crate `libc`
  --> /home/brocaar/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.2/src/backends/linux_android_with_fallback.rs:34:39
   |
34 |         let fptr: GetRandomFn = libc::getrandom;
   |                                       ^^^^^^^^^ not found in `libc`

libc version is 0.2.171.

As MIPS is a tier-3 target, I'm building my code (using cross-rs):

rustup toolchain add nightly-2025-03-25-x86_64-unknown-linux-gnu
cross +nightly-2025-03-25 build -Z build-std=std --target mipsel-unknown-linux-musl --release

There is no note in the documentation stating that this method is not supported for MIPS target(s):
https://docs.rs/libc/latest/libc/fn.getrandom.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions