Skip to content

Conversation

@dsherret
Copy link
Contributor

@dsherret dsherret commented May 17, 2025

An alternative to #666 that errors at runtime.

This is useful when needing the crate to compile when targeting wasm32, but this code is never actually hit.

@dsherret dsherret force-pushed the runtime_error_backend branch from c0538d9 to 903c641 Compare May 17, 2025 19:07
@dsherret dsherret force-pushed the runtime_error_backend branch from 903c641 to b7384b7 Compare May 17, 2025 19:07
@dsherret dsherret mentioned this pull request May 17, 2025
Copy link
Member

@newpavlov newpavlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good, but I am not sure about the backend name. How about unsupported since it returns Error::UNSUPPORTED?

@dsherret
Copy link
Contributor Author

I am not sure about the backend name. How about unsupported since it returns Error::UNSUPPORTED?

I wasn't sure about it either. Yeah, I like that better. Updated.

@dsherret dsherret changed the title Add runtime_error backend Add unsupported backend May 19, 2025
Copy link
Member

@newpavlov newpavlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will leave this PR open for some time for @josephlr to take a look on it. Plus we need to fix the failing CI jobs (it looks like a Nightly toolchain issue).

@newpavlov newpavlov requested a review from josephlr May 19, 2025 04:34
@newpavlov
Copy link
Member

newpavlov commented May 19, 2025

Also, please add a changelog entry. You can add the following section:

## [0.3.4] - UNRELEASED

### Added
- Your entry

[0.3.4]: https://github.com/rust-random/getrandom/compare/v0.3.3...HEAD

The diff link goes to the end of the file.

@dsherret dsherret changed the title Add unsupported backend unsupported opt-in backend May 19, 2025
Copy link
Member

@josephlr josephlr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me. Thanks for adding this!

I'm going to try to see if the CI errors are just spurious failures or something we need to fix. Regardless, the failures aren't being caused by this PR.

@newpavlov
Copy link
Member

Thank you!

We probably will wait for some time before releasing v0.3.4 to accumulate other potential changes. Meanwhile, you could temporarily patch getrandom for your project.

@newpavlov newpavlov merged commit d4302b4 into rust-random:master May 19, 2025
73 checks passed
@josephlr josephlr mentioned this pull request Oct 14, 2025
josephlr added a commit that referenced this pull request Oct 14, 2025
## [0.3.4] - 2025-10-14

### Major change to `wasm_js` backend

Now, when the `wasm_js` feature is enabled, the `wasm_js` backend will
be used
by default. Users of `wasm32-unknown-unknown` targeting JavaScript
environments
like the Web and Node.js will no longer need to specify:
```
--cfg getrandom_backend="wasm_js"
```
in `RUSTFLAGS` for the crate to compile. They can now simple enable a
feature.

Note: this should not affect non-JS users of the
`wasm32-unknown-unknown`
target. Using `--cfg getrandom_backend` will still override the source
of
randomness _even if_ the `wasm_js` feature is enabled. This includes
`--cfg getrandom_backend=custom` and `--cfg
getrandom_backend=unsupported`.

For more information, see the discussions in [#671], [#675], and [#730].

### Added
- `unsupported` opt-in backend [#667]
- `windows_legacy` opt-in backend [#724]

### Changed
- Implement Memory Sanitizer unpoisoning more precisely [#678]
- Relax MSRV for the `linux_raw` opt-in backend on ARM targets [#688]
- Use `getrandom` syscall on all RISC-V Linux targets [#699]
- Replaced `wasi` dependency with `wasip2` [#721]
- Enable `wasm_js` backend by default if the `wasm_js` feature is
enabled [#730]

### Removed
- Unstable `rustc-dep-of-std` crate feature [#694]

[#667]: #667
[#671]: #671
[#675]: #675
[#678]: #678
[#688]: #688
[#694]: #694
[#699]: #699
[#721]: #721
[#724]: #724
[#730]: #730

---------

Signed-off-by: Joe Richey <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants