Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
brocaar opened this issue Mar 26, 2025 · 2 comments
Closed

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

brocaar opened this issue Mar 26, 2025 · 2 comments
Labels
C-bug Category: bug

Comments

@brocaar
Copy link

brocaar commented Mar 26, 2025

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

@newpavlov
Copy link
Contributor

Should be fixed by #4346.

@brocaar
Copy link
Author

brocaar commented Mar 27, 2025

@newpavlov a thanks! That is great news. Then this should be fixed by the next release.

@brocaar brocaar closed this as completed Mar 27, 2025
brocaar added a commit to chirpstack/chirpstack-concentratord that referenced this issue Mar 27, 2025
The latest cross-rs release (0.2.5) does not work with the latest Rust
release, until a new release is out we need to install from git.

There is still an issue when compiling for mips, which will be
resolved when a new libc crate release is out:
rust-lang/libc#4354
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants