Skip to content

Assume JS on wasm32-u-u with wasm_js feature? #675

@dhardy

Description

@dhardy

As noted in #346, we could support wasm32-unknown-unknown on web when the js feature is enabled. The major problem is was (see next comment) what to do when the custom backend is also enabled:

  • Defaulting to the custom backend is not okay: any crate in the dependency tree could overwrite the (secure) random source used by a binary. No longer true: the user must the the getrandom_backend cfg.
  • Defaulting to the js backend is not okay: many crates depend on getrandom with the js feature for convenience, which would prevent support for a custom backend (no longer true; see next comment).

Updated suggestion in next comment.

Original suggestion

We could instead consider this a compiler error. This deviates significantly from standard usage of features which should be additive (i.e. any combination including all of them is valid).

Nevertheless, this might be workable. Any crate which could possibly be used on a non-web wasm32-unknown-unknown platform depending on getrandom with feature js would be a bug, forcing these crates not to do so (or to explicitly not support non-web wasm32-u-u targets).

This is (I believe) the simplest solution for wasm32-u-u which doesn't block getrandom from supporting non-web targets.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions