Skip to content

Commit 1033857

Browse files
committed
Auto merge of #107221 - kleisauke:getentropy-emscripten, r=ChrisDenton
Use `getentropy()` instead of `/dev/urandom` on Emscripten `/dev/urandom` is usually available on Emscripten, except when using the special `NODERAWFS` filesystem backend, which replaces all normal filesystem access with direct Node.js operations. Since this filesystem backend directly access the filesystem on the OS, it is not recommended to depend on `/dev/urandom`, especially when trying to run the Wasm binary on OSes that are not Unix-based. This can be considered a non-functional change, since Emscripten implements `/dev/urandom` in the same way as `getentropy()` when not linking with `-sNODERAWFS`.
2 parents 2fb0e8d + 7b40eb7 commit 1033857

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

library/std/src/sys/unix/rand.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ pub fn hashmap_random_keys() -> (u64, u64) {
2020
not(target_os = "netbsd"),
2121
not(target_os = "fuchsia"),
2222
not(target_os = "redox"),
23-
not(target_os = "vxworks")
23+
not(target_os = "vxworks"),
24+
not(target_os = "emscripten")
2425
))]
2526
mod imp {
2627
use crate::fs::File;
@@ -174,7 +175,7 @@ mod imp {
174175
}
175176
}
176177

177-
#[cfg(target_os = "openbsd")]
178+
#[cfg(any(target_os = "openbsd", target_os = "emscripten"))]
178179
mod imp {
179180
use crate::sys::os::errno;
180181

src/ci/docker/scripts/emscripten.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ exit 1
2020

2121
git clone https://github.com/emscripten-core/emsdk.git /emsdk-portable
2222
cd /emsdk-portable
23-
hide_output ./emsdk install 1.39.20
24-
./emsdk activate 1.39.20
23+
hide_output ./emsdk install 2.0.5
24+
./emsdk activate 2.0.5

0 commit comments

Comments
 (0)