-
Notifications
You must be signed in to change notification settings - Fork 130
Added wasm32-unknown-unknown build options for getrandom. #277
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enables builds for the wasm32-unknown-unknown
target by pulling in the getrandom
crate’s wasm_js
backend and setting the necessary compiler flags.
- Adds a target-specific, optional
getrandom
dependency with thewasm_js
feature. - Configures
rustflags
in.cargo/config.toml
to select the WebAssembly backend.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
Cargo.toml | Add WASM-specific getrandom dependency entry with wasm_js . |
.cargo/config.toml | Configure rustflags for wasm32-unknown-unknown builds. |
Comments suppressed due to low confidence (1)
.cargo/config.toml:4
- [nitpick] Add a note to the project README or contributing guide explaining that developers must include this
rustflags
setting (or setRUSTFLAGS
) when building forwasm32-unknown-unknown
.
rustflags = ['--cfg', 'getrandom_backend="wasm_js"']
|
||
# WASM-specific dependencies to enable wasm_js feature for getrandom | ||
[target.'cfg(target_arch = "wasm32")'.dependencies] | ||
getrandom = { version = "0.3.3", optional = true, features = ["wasm_js"] } |
Copilot
AI
Jun 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default, getrandom
enables std
, which may cause build failures on wasm32-unknown-unknown
. Please add default-features = false
to this dependency so only the wasm_js
feature is pulled in.
getrandom = { version = "0.3.3", optional = true, features = ["wasm_js"] } | |
getrandom = { version = "0.3.3", optional = true, default-features = false, features = ["wasm_js"] } |
Copilot uses AI. Check for mistakes.
|
||
# WASM-specific dependencies to enable wasm_js feature for getrandom | ||
[target.'cfg(target_arch = "wasm32")'.dependencies] | ||
getrandom = { version = "0.3.3", optional = true, features = ["wasm_js"] } |
Copilot
AI
Jun 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] This target-specific dependency is marked optional
, but there is no crate-level feature to activate it. Consider defining a wasm
or js-random
feature in your [features]
section that enables this dependency, so consumers can opt in more clearly.
getrandom = { version = "0.3.3", optional = true, features = ["wasm_js"] } | |
getrandom = { version = "0.3.3", features = ["wasm_js"] } |
Copilot uses AI. Check for mistakes.
Can this PR work to resolve the |
Hi,
I put this together to address issue #276. It adds both the getrandom feature flag and the RUSTFLAGS argument needed. I'm happy to take feedback and adjust the PR as necessary to make it suitable.