Skip to content

Cannot compile to wasm without wasm-bindgen with v0.8.1 #140

Closed

Description

@Frazzer951

In the latest update getrandom now includes wasm-bindgen which causes problems in my project because I'm just compiling raw WASM.

Is there a way to compile this library for wasm that doesn't force the js feature in getrandom?

This has also been pointed out at #129 (comment) which is on the pull-request which made the change to cause this issue

Activity

  1. schungx commented on Nov 3, 2022

    @schungx
    Contributor

    I agree adding a js feature that maps to getrandom/js is best.

    I used to manually set getrandom/js whenever I see wasm-bindgen so ahash works properly but then the new version now has no way to turn it off.

  2. schungx commented on Nov 5, 2022

    @schungx
    Contributor

    This also causes #141 which breaks no-std builds.

  3. schungx commented on Nov 5, 2022

    @schungx
    Contributor

    In fact, the standard ahash with default-features = false will ALWAYS bring in wasm-bindgen (you can tell by inspecting Cargo.lock) for ANY TARGET and all its dependencies for no apparent reason, all because getrandom/js is turned on.

    That is because cargo seems to merge the features regardless of whether they only showed up in specific target sections. Once it shows up in one target, it shows up in all targets.

    [target."cfg(not(any(target_arch = \"wasm32\", target_abi = \"unknown\")))".dependencies.getrandom] does not appear to prevent the js feature from being added to getrandom (not to mention target_abi does not seem to be stabilized yet) even when the target is not wasm32.

    Therefore, there is no way to "turn off" getrandom/js, which breaks no-std in a major way.

  4. schungx commented on Nov 5, 2022

    @schungx
    Contributor

    rust-lang/cargo#4866 and rust-lang/cargo#1197 document the fact that target-specific features are not supported. All features are merged regardless of target.

    Supposedly resolver = "2" will resolve (pun intended) this target-specific features issue, but in my tests this is not the case, as confirmed by the GitHub issues. resolver = "2" doesn't prevent features set on targets not built to be merged.

  5. tkaitchuck commented on Nov 10, 2022

    @tkaitchuck
    Owner

    Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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