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

wasm compilation not working #1824

Closed
ncitron opened this issue Nov 3, 2022 · 4 comments · Fixed by #1854
Closed

wasm compilation not working #1824

ncitron opened this issue Nov 3, 2022 · 4 comments · Fixed by #1854
Labels
bug Something isn't working

Comments

@ncitron
Copy link
Contributor

ncitron commented Nov 3, 2022

Version
1.0.0

Description
WASM compilation currently only works if you compile the example in examples/ethers-wasm while its still inside the main ethers-rs repo. If you copy the entire contents of the folder somewhere else, compilation will fail with dozens of errors relating to the meo crate (I think it is a dependency of tokio). It seems that any crate the imports ethers-rs fails this way when compiling to wasm in my testing.

Here is what the errors look like: https://pastebin.com/BwcEi9Zk

@ncitron ncitron added the bug Something isn't working label Nov 3, 2022
@mattsse
Copy link
Collaborator

mattsse commented Nov 3, 2022

for some reason tokio is pulled in if you directly depend on ethers.

however I've checked all default features and tokio usage in all subcrates which should be ignored for the wasm target, however iirc there are some issues with mutually exclusive cfg(condition) and cfg(not(condition)) cfgs, which could be relevant here.

@slumber
Copy link

slumber commented Mar 5, 2023

This is still reproducible if you have ethers-wasm as a workspace member. I.e. create folder with the following Cargo.toml:

[workspace]
members = ["ethers-wasm"]

And then try to

cargo build -p ethers-wasm --target wasm32-unknown-unknown

This will try to compile ~70 additional targets and in the end produces the same huge list of errors related to mio.

Probably caused by https://nickb.dev/blog/cargo-workspace-and-the-feature-unification-pitfall/

@QYuQianchen
Copy link

Running into the similar issue here. Our project has one crate for smart contracts where it contains foundry-generated contract bindings, and another crate which uses those bindings and compiles to wasm with wasm-bindgen. The same sets of errors related to mio are reported when running cargo build.

@slumber
Copy link

slumber commented Mar 10, 2023

Running into the similar issue here. Our project has one crate for smart contracts where it contains foundry-generated contract bindings, and another crate which uses those bindings and compiles to wasm with wasm-bindgen. The same sets of errors related to mio are reported when running cargo build.

As a workaround you can move wasm crate into a subworkspace via adding

[workspace]
# nothing here

to the bottom of its Cargo.toml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants