Skip to content
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

Use getentropy() libc function on Emscripten #275

Closed
josephlr opened this issue Jul 31, 2022 · 2 comments · Fixed by #307
Closed

Use getentropy() libc function on Emscripten #275

josephlr opened this issue Jul 31, 2022 · 2 comments · Fixed by #307
Labels
enhancement New feature or request

Comments

@josephlr
Copy link
Member

josephlr commented Jul 31, 2022

Release 2.0.5: 09/28/2020 of Emscripten introduced a getentropy() call that can be used instead of opening /dev/urandom. We should use this as the preferred (or sole) method to get random data, as it avoids needing to open a file and hold onto a file descriptor.

NOTE: this probably requires getting the emscipten CI working with a recent-ish version

@briansmith
Copy link
Contributor

Release 2.0.5: 09/28/2020 of Emscripten introduced a getentropy() call that can be used instead of opening /dev/urandom. We should use this as the preferred (or sole) method to get random data, as it avoids needing to open a file and hold onto a file descriptor.

I do agree that the file descriptor mechanism is worse. However, isn't Emscripten's getentropy() reimplementing what the getrandom crate does for the browser wasm32 target? Why not just use our own logic instead?

@josephlr
Copy link
Member Author

josephlr commented Oct 22, 2022

However, isn't Emscripten's getentropy() reimplementing what the getrandom crate does for the browser wasm32 target? Why not just use our own logic instead?

IIUC, the point of the Emscripten target is to not use things like wasm-bindgen, but instead link to the EMSDK's libc. Then that libc crate can provide all the necessary functionality to emulate an Unix system while running in a wasm/asm.js environment. More practically, wasm-bindgen doesn't support Emscripten targets, so we couldn't do what we do for wasm32-unknown-unknown on wasm32-unknown-emscripten.

josephlr added a commit that referenced this issue Oct 22, 2022
Part of addressing #275 

Signed-off-by: Joe Richey <joerichey@google.com>
@josephlr josephlr added the enhancement New feature or request label Oct 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants