rust-random / getrandom

A small cross-platform library for retrieving random data from (operating) system source
Apache License 2.0
275 stars 180 forks source link

The newly updated version "0.2.13" cannot run on mipsel #407

Closed vnt-dev closed 5 months ago

vnt-dev commented 5 months ago

It can run normally before you update 0.2.13

thread 'main' panicked at 'could not initialize thread_rng: Function not implemented', /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rand-0.8.5/src/rngs/thread.rs:72:17 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace Aborted

josephlr commented 5 months ago

This is almost certainly caused by https://github.com/rust-random/getrandom/pull/396

That PR removed certain fallback code on certain Linux CPU architectures (all CPU architectures that aren't ARM, x86, PowerPC, or s390). On such architectures (like mipsel), a sufficiently new kernel is already required. Looking at the list of Rust Targets the mipsel-unknown-linux-gnu target requires kernel 4.4, which should have support for the getrandom syscall.

@lbl8603 to help us debug further:

josephlr commented 5 months ago

CC @newpavlov @briansmith (who worked on #396)

vnt-dev commented 5 months ago
josephlr commented 5 months ago

Looking at the platform list, it seems like the musl targets don't list a minimum kernel version (they just require MUSL 1.2.3 which requires kernel 2.6 or later), while for mipsel-unknown-linux-gnu the minim kernel version is 4.4. I'm wondering if we should reach out to see what the actual minimum supported kernel version for Rust is on -musl targets.

@lbl8603 out of curiosity what system/distro are you running on? Based on the uname it looks like some sort of old router?

@newpavlov @briansmith should we support MUSL systems with kernels older than 3.17?

newpavlov commented 5 months ago

Hm, mipsel-unknown-linux-gnu requires kernel 4.4, so we assumed that mipsel-unknown-linux-musl would require it as well. Could you please find an official link that Rust officially supports pre-4.4 kernels for this target?

Adding a MUSL exception looks like an obvious solution for now.

josephlr commented 5 months ago

Hm, mipsel-unknown-linux-gnu requires kernel 4.4, so we assumed that mipsel-unknown-linux-musl would require it as well. Could you please find an official link that Rust officially supports pre-4.4 kernels for this target?

I'm wondering if MUSL might target an older kernel version. It seems like a lot of the folks who target very old kernels intentionally use MUSL to avoid depending on an ancient glibc.

EDIT: Looking at https://github.com/rust-lang/compiler-team/issues/493 it seems like the only reason Linux 3.2 is even required by rust is to support GLIBC (whose newer versions have that as the minimum kernel version).

vnt-dev commented 5 months ago

Compiling target mipsel-unknown-linux-musl requires using versions prior to Rust 1.71.1. I encountered this bug on the router