From e3036613d1151ce64ae32839a785a8b972495e3e Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Wed, 18 Jan 2023 10:20:27 +0100 Subject: [PATCH 1/3] 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`. --- library/std/src/sys/unix/rand.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/library/std/src/sys/unix/rand.rs b/library/std/src/sys/unix/rand.rs index a6fe07873d7ee..0f347ffab42fe 100644 --- a/library/std/src/sys/unix/rand.rs +++ b/library/std/src/sys/unix/rand.rs @@ -20,7 +20,8 @@ pub fn hashmap_random_keys() -> (u64, u64) { not(target_os = "netbsd"), not(target_os = "fuchsia"), not(target_os = "redox"), - not(target_os = "vxworks") + not(target_os = "vxworks"), + not(target_os = "emscripten") ))] mod imp { use crate::fs::File; @@ -174,7 +175,7 @@ mod imp { } } -#[cfg(target_os = "openbsd")] +#[cfg(any(target_os = "openbsd", target_os = "emscripten"))] mod imp { use crate::sys::os::errno; From 4d40cdfe2bed80f1fa7c1fe2a1526adb284d1c1d Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Tue, 14 Mar 2023 12:57:38 +0100 Subject: [PATCH 2/3] Update libc dependency of std to 0.2.140 --- Cargo.lock | 4 ++-- library/std/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 51332919fe755..745209c82ec34 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2879,9 +2879,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.139" +version = "0.2.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" dependencies = [ "rustc-std-workspace-core", ] diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index 598a4bf928290..6345db240548d 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -15,7 +15,7 @@ cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] } panic_unwind = { path = "../panic_unwind", optional = true } panic_abort = { path = "../panic_abort" } core = { path = "../core" } -libc = { version = "0.2.139", default-features = false, features = ['rustc-dep-of-std'] } +libc = { version = "0.2.140", default-features = false, features = ['rustc-dep-of-std'] } compiler_builtins = { version = "0.1.87" } profiler_builtins = { path = "../profiler_builtins", optional = true } unwind = { path = "../unwind" } From 7b40eb71a90d93e825e32394d30f199a8492342d Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Wed, 29 Mar 2023 11:20:36 +0200 Subject: [PATCH 3/3] Update Emscripten on CI to 2.0.5 `getentropy()` is available since Emscripten 2.0.5. See: https://github.com/emscripten-core/emscripten/pull/12240 --- src/ci/docker/scripts/emscripten.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ci/docker/scripts/emscripten.sh b/src/ci/docker/scripts/emscripten.sh index 56dc96283edc1..3f5e2c6ff1dca 100644 --- a/src/ci/docker/scripts/emscripten.sh +++ b/src/ci/docker/scripts/emscripten.sh @@ -20,5 +20,5 @@ exit 1 git clone https://github.com/emscripten-core/emsdk.git /emsdk-portable cd /emsdk-portable -hide_output ./emsdk install 1.39.20 -./emsdk activate 1.39.20 +hide_output ./emsdk install 2.0.5 +./emsdk activate 2.0.5