Open martijneken opened 3 hours ago
Yes, I think that would make sense.
There is a simple implementation in wasi-libc already: https://github.com/WebAssembly/wasi-libc/blob/main/libc-bottom-half/sources/getentropy.c
Would you like the send a PR? I imagine the hardest part would be figuring out where/how to test it.
Please include the following in your bug report:
Version of emscripten/emsdk: 3.1.67 (and likely latest)
Failing command line in full:
Compiling absl::random code in standalone mode results in a wasm module that crashes. Sample code:
The reason is that Abseil under Emscripten uses the
getentropy()
syscall as a seed: https://github.com/abseil/abseil-cpp/blob/07fff76ed619672bb7bf00939231ba45aef2b043/absl/random/internal/seed_material.cc#L60-L64And standalone Emscripten defaults to a crashing implementation: https://github.com/emscripten-core/emscripten/blob/b53978ee3f540dc74761eba127aa7f1b8761a125/system/lib/standalone/standalone.c#L139-L143
Would it be reasonable to use
wasi_snapshot_preview1.random_get()
to implementgetentropy()
?