Skip to content

Conversation

maldrake
Copy link

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.

@Copilot Copilot AI review requested due to automatic review settings June 30, 2025 13:25
Copy link

@Copilot Copilot AI left a 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 the wasm_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 set RUSTFLAGS) when building for wasm32-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"] }
Copy link

Copilot AI Jun 30, 2025

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.

Suggested change
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"] }
Copy link

Copilot AI Jun 30, 2025

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.

Suggested change
getrandom = { version = "0.3.3", optional = true, features = ["wasm_js"] }
getrandom = { version = "0.3.3", features = ["wasm_js"] }

Copilot uses AI. Check for mistakes.

@schungx
Copy link
Contributor

schungx commented Oct 13, 2025

Can this PR work to resolve the getrandom breaking issue?

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.

2 participants