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

It can't build to wasm #134

Open
aewc opened this issue Aug 29, 2022 · 3 comments
Open

It can't build to wasm #134

aewc opened this issue Aug 29, 2022 · 3 comments

Comments

@aewc
Copy link

aewc commented Aug 29, 2022

When I use this dependency in my wasm project, it will report error when compiling:

error: the wasm32-unknown-unknown target is not supported by default, you may need to enable the "js" feature. For more information see: https://docs.rs/getrandom/#webassembly-support
   --> /Users/xxx/.cargo/registry/src/github.com-1ecc6299db9ec823/getrandom-0.2.7/src/lib.rs:235:9
    |
235 | /         compile_error!("the wasm32-unknown-unknown target is not supported by \
236 | |                         default, you may need to enable the \"js\" feature. \
237 | |                         For more information see: \
238 | |                         https://docs.rs/getrandom/#webassembly-support");
    | |________________________________________________________________________^

error[E0433]: failed to resolve: use of undeclared crate or module `imp`
   --> /Users/xxx/.cargo/registry/src/github.com-1ecc6299db9ec823/getrandom-0.2.7/src/lib.rs:262:5
    |
262 |     imp::getrandom_inner(dest)
    |     ^^^ use of undeclared crate or module `imp`

error: failed to run custom build command for `gmp-mpfr-sys v1.4.10`

Caused by:
  process didn't exit successfully: `/Users/xxx/workspace/github-aewc/infinity-swap/evm-canister/target/release/build/gmp-mpfr-sys-d8a467da99dcac09/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at 'Cross compilation from aarch64-apple-darwin to wasm32-unknown-unknown not supported! Use the `force-cross` feature to cross compile anyway.', /Users/xxx/.cargo/registry/src/github.com-1ecc6299db9ec823/gmp-mpfr-sys-1.4.10/build.rs:111:9
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
For more information about this error, try `rustc --explain E0433`.
error: could not compile `getrandom` due to 2 previous errors

is there any features that without using the getrandom?

@aurexav
Copy link

aurexav commented Mar 18, 2023

Same. It can still be reproduced in 2023.

@devinpearson
Copy link

You need to add getrandom with the feature flag of JS. This is not libsecp256k1, but its dependency rand which depends on getrandom.
https://docs.rs/getrandom/latest/getrandom/#webassembly-support

getrandom = { version = "0.2", features = ["js"]}

@aurexav
Copy link

aurexav commented Jul 21, 2023

Fixed by upgrading Substrate to polkadot-v0.9.43.

This issue may also be related to cargo workspace dependencies. I suspect there was a potential bug when handling the individual default-feature = false.

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