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

Support more functionality for wasm targets #513

Open
Niederb opened this issue Apr 4, 2023 · 4 comments
Open

Support more functionality for wasm targets #513

Niederb opened this issue Apr 4, 2023 · 4 comments
Labels
F8-newfeature Introduces a new feature Q9-needsdesign

Comments

@Niederb
Copy link
Contributor

Niederb commented Apr 4, 2023

We would like to provide more functionality for webassembly targets. See the findings in #272.
Ideally we could build the complete client unchanged:
cargo b --target wasm32-wasi
or
cargo b --target wasm32-unknown-unknown

@dotChris90
Copy link

@Niederb @haerdib hello you two - we are also interested into web assembly support and would like to ask - if there is a documentation related to what is possible for WASM target and what are the limitations regarding to substrate-api-client?

@Niederb
Copy link
Contributor Author

Niederb commented Apr 25, 2024

@dotChris90 Good question. In general we support in WebAssembly what is available in a no_std environment. The "no_std build" from the README documents a bit what is available.
The WebAssembly eco-system is still in constant flux. I can have a look if one of our roadblocks has been removed.

@Niederb
Copy link
Contributor Author

Niederb commented Apr 25, 2024

I just did a test with the latest nightly and doing a cargo update. The command cargo build --target wasm32-wasip1 gives me:

error: Only features sync,macros,io-util,rt,time are supported on wasm.
   --> /home/tniederberger/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/lib.rs:470:1
    |
470 | compile_error!("Only features sync,macros,io-util,rt,time are supported on wasm.");
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0433]: failed to resolve: use of undeclared crate or module `platform`
  --> /home/tniederberger/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustls-native-certs-0.7.0/src/lib.rs:58:42
   |
58 |     load_certs_from_env().unwrap_or_else(platform::load_native_certs)
   |                                          ^^^^^^^^ use of undeclared crate or module `platform`

For more information about this error, try `rustc --explain E0433`.
error: could not compile `rustls-native-certs` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `tokio` (lib) due to 1 previous error

@Niederb
Copy link
Contributor Author

Niederb commented Apr 25, 2024

There is indeed some good news. By updating our dependencies it is now possible to compile with the following command:
cargo build --target wasm32-wasi --no-default-features --features sync-api,staking-xt,contracts-xt,std
I will create a PR regarding that in the next couple of days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F8-newfeature Introduces a new feature Q9-needsdesign
Projects
None yet
Development

No branches or pull requests

3 participants