Skip to content

Compilation for WASM target fails #450

@mi-prata

Description

@mi-prata

Hello,

Trying to run:

cargo b --features aws_lc_rs --target wasm32-unknown-unknown

Results in compilation errors:

error: the wasm*-unknown-unknown targets are not supported by default, you may need to enable the "js" feature. For more information see: https://docs.rs/getrandom/#webassembly-support
   --> /home/mpr@appeartv.lan/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.2.16/src/lib.rs:346:9
    |
346 | /         compile_error!("the wasm*-unknown-unknown targets are not supported by \
347 | |                         default, you may need to enable the \"js\" feature. \
348 | |                         For more information see: \
349 | |                         https://docs.rs/getrandom/#webassembly-support");
    | |________________________________________________________________________^

error[E0433]: failed to resolve: use of unresolved module or unlinked crate `imp`
   --> /home/mpr@appeartv.lan/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.2.16/src/lib.rs:402:9
    |
402 |         imp::getrandom_inner(dest)?;
    |         ^^^ use of unresolved module or unlinked crate `imp`
    |
    = help: if you wanted to use a crate named `imp`, use `cargo add imp` to add it to your `Cargo.toml`

For more information about this error, try `rustc --explain E0433`.

I can confirm that enabling the "js" feature in Cargo.toml:

[target.'cfg(target_arch = "wasm32")'.dependencies]
js-sys = "0.3"
getrandom = { version = "0.2", features = ["js"] }

does solve this particular issue for the rust_crypto feature, but not aws_lc_rs.

Is any of this an expected outcome?

Thanks in advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions