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() instead of /dev/urandom on Emscripten #107221

Merged
merged 3 commits into from
Mar 30, 2023

Conversation

kleisauke
Copy link
Contributor

@kleisauke kleisauke commented Jan 23, 2023

/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.

@rustbot
Copy link
Collaborator

rustbot commented Jan 23, 2023

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @joshtriplett (or someone else) soon.

Please see the contribution instructions for more information.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jan 23, 2023
kleisauke added a commit to kleisauke/libc that referenced this pull request Jan 23, 2023
bors added a commit to rust-lang/libc that referenced this pull request Jan 25, 2023
Add getentropy for Emscripten

Required by rust-lang/rust#107221.

~~Marked as draft because I could not find `libc-test/semver/emscripten.txt`, so it doesn't meet the checklist.~~ Fixed with commit 6a7bd43.
`/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`.
@kleisauke kleisauke force-pushed the getentropy-emscripten branch from facd1e3 to 4d40cdf Compare March 14, 2023 11:59
@kleisauke
Copy link
Contributor Author

This is ready for review now that libc 0.2.140 was released.

@kleisauke kleisauke marked this pull request as ready for review March 14, 2023 11:59
@rustbot
Copy link
Collaborator

rustbot commented Mar 14, 2023

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

These commits modify the Cargo.lock file. Random changes to Cargo.lock can be introduced when switching branches and rebasing PRs.
This was probably unintentional and should be reverted before this PR is merged.

If this was intentional then you can ignore this comment.

tatref pushed a commit to tatref/libc that referenced this pull request Mar 20, 2023
@ChrisDenton
Copy link
Member

lgtm

@bors r+

@bors
Copy link
Contributor

bors commented Mar 28, 2023

📌 Commit 4d40cdf has been approved by ChrisDenton

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 28, 2023
@bors
Copy link
Contributor

bors commented Mar 28, 2023

⌛ Testing commit 4d40cdf with merge 8e6b904aeb2f7cd2dc46ea94a5390252d1303d9b...

@bors
Copy link
Contributor

bors commented Mar 28, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 28, 2023
@rust-log-analyzer

This comment has been minimized.

`getentropy()` is available since Emscripten 2.0.5.

See:
emscripten-core/emscripten#12240
@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. labels Mar 29, 2023
@kleisauke
Copy link
Contributor Author

It looks like we need to bump the minimum supported Emscripten version to 2.0.5 for this (which is 2 months newer than 1.39.20), see commit 7b40eb7.

@ChrisDenton
Copy link
Member

Ah, ok. Let's try again...

@bors r+

@bors
Copy link
Contributor

bors commented Mar 29, 2023

📌 Commit 7b40eb7 has been approved by ChrisDenton

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 29, 2023
@bors
Copy link
Contributor

bors commented Mar 30, 2023

⌛ Testing commit 7b40eb7 with merge 1033857...

@bors
Copy link
Contributor

bors commented Mar 30, 2023

☀️ Test successful - checks-actions
Approved by: ChrisDenton
Pushing 1033857 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 30, 2023
@bors bors merged commit 1033857 into rust-lang:master Mar 30, 2023
@rustbot rustbot added this to the 1.70.0 milestone Mar 30, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (1033857): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.2% [1.2%, 1.2%] 1
Regressions ❌
(secondary)
2.9% [2.7%, 3.1%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.7% [-2.7%, -2.7%] 1
All ❌✅ (primary) 1.2% [1.2%, 1.2%] 1

Cycles

This benchmark run did not return any relevant results for this metric.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants