Skip to content
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

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

Closed
Frazzer951 opened this issue Nov 2, 2022 · 5 comments
Closed

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

Frazzer951 opened this issue Nov 2, 2022 · 5 comments

Comments

@Frazzer951
Copy link

Frazzer951 commented Nov 2, 2022

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

@schungx
Copy link
Contributor

schungx commented Nov 3, 2022

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.

@schungx
Copy link
Contributor

schungx commented Nov 5, 2022

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

@schungx
Copy link
Contributor

schungx commented Nov 5, 2022

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.

@schungx
Copy link
Contributor

schungx commented Nov 5, 2022

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.

@tkaitchuck
Copy link
Owner

Fixed

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

No branches or pull requests

3 participants