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 wasm32-wasi compilation target - fix net2 dependency #505

Open
dunnock opened this issue Nov 11, 2019 · 5 comments
Open

Support wasm32-wasi compilation target - fix net2 dependency #505

dunnock opened this issue Nov 11, 2019 · 5 comments
Labels

Comments

@dunnock
Copy link

dunnock commented Nov 11, 2019

This is not directly related with this crate's source code, rather some dependencies.

Though when compiling to WASI for instance there are lots of errors from net2 which should be fixable as os::wasi has implementation for missing values/methods:

error[E0425]: cannot find value `SOL_SOCKET` in this scope
   --> /Users/max/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.33/src/ext.rs:993:33
    |
993 |         get_opt(self.as_sock(), SOL_SOCKET, SO_BROADCAST)
    |                                 ^^^^^^^^^^ not found in this scope
@dunnock
Copy link
Author

dunnock commented Nov 11, 2019

It appears some issues were fixed in net2:master with deprecrated/net2-rs#84 though net2 version was not released.

Adding direct git target to Cargo.toml does not fix it yet

[patch.crates-io]
net2 = { git="https://github.com/rust-lang-nursery/net2-rs" }

it seems there are more issues now, due to wasi implementation changes:

   Compiling net2 v0.2.33 (https://github.com/rust-lang-nursery/net2-rs#eda403f0)
error[E0432]: unresolved import `libc::__wasi_fd_t`
  --> /Users/max/.cargo/git/checkouts/net2-rs-4b5319289a3d25c1/eda403f/src/sys/wasi/mod.rs:12:25
   |
12 | use libc::{self, c_int, __wasi_fd_t};
   |                         ^^^^^^^^^^^ no `__wasi_fd_t` in the root

error[E0432]: unresolved import `sys::c::__wasi_fd_t`
 --> /Users/max/.cargo/git/checkouts/net2-rs-4b5319289a3d25c1/eda403f/src/sys/wasi/impls.rs:5:17
  |
5 | use sys::{self, c::__wasi_fd_t};
  |                 ^^^^^^^^^^^^^^ no `__wasi_fd_t` in `sys::c`

@niklasad1
Copy link

it seems that net2 is replaced with socket2 but socket2 doesn't support WASI either.

@teohhanhui
Copy link

async-io is already excluded on wasm32-unknown-unknown target, using a very weird way:

async-std/Cargo.toml

Lines 85 to 89 in f4b8c7a

[target.'cfg(not(target_os = "unknown"))'.dependencies]
async-global-executor = { version = "2.0.0", optional = true, features = ["async-io"] }
async-io = { version = "1.0.1", optional = true }
futures-lite = { version = "1.0.0", optional = true }
async-process = { version = "1.0.1", optional = true }

This exclusion should apply to wasm32-wasi target as well. (How?)

@teohhanhui
Copy link

teohhanhui commented Nov 5, 2021

Never mind, it's a lot more complicated than that.

wasm32-wasi is just a very different target compared to wasm32-unknown-unknown.

Among other things, wasm-bindgen does not support the wasm32-wasi target:

I was able to get async-std to build for the wasm32-wasi target with some simple search and replace, but what's the point if everything is not working?

@folex
Copy link

folex commented Jan 8, 2023

Shouldn't local spawning work on wasm32-wasi same way as wasm32-unknown-unknown?

Looking to understand how wasm32-wasi is different in regards to async-std

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants