-
Notifications
You must be signed in to change notification settings - Fork 232
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 wasm (in some form) #268
Comments
I'm interested in using socket2 in wasm too. I found that symbols like AF_INET, sa_family_t, sockaddr_in are missing in wasi, so it doesn't have the concept about the address of socket, and we could barely define |
the day, wasi will have them features, will be gold for rust and thus the planet ... but wen X_X |
Isn’t |
The API is in preview I believe, but considering it's implemented by browser backwards compatibility is everything. So I think it's find to add experimental support for wasm/wasi, this is what we did for Mio. |
hi @Thomasdezeeuw do we have any ways to work around now? My lib depends on |
Just do some draft PoC please, we need em sockets and tokio |
You might be able to disable Tokio's network feature, not sure though.
Prs are welcome. |
Tokio only depends on socket2 if you enable the |
can verify trying to use either crate:
Is it assumed until this issue is resolved that we won't be able to use socket2 with wasm or any libs/crates that rely on socket2? |
this should be easier to solve now that wasix exists, I'm not to sure how sockets work so I haven't taken more then a cursory build which resulting in more errors(yes you are reading that right, it seems a lot of the wasix sockets stuff expects more/less args) |
I don't know about wasix, it's doesn't seem like a standard anyone but wasmer is following. I don't really fancy having different code for different wasm runtimes. |
Wasix seems more like a pollyfill. It produces a wasm binary that should work any where |
I highly doubt that. I can't imagine how you would create a socket if the underlying wasm runtime doesn't provide a function/"system call" to create sockets. |
They are able to do this via a npm package and have also forked this repo to allow it to be built to wasm. Having it upstreamed would be very cool |
Cool, a pr with those changes would be welcome. Ideally we can setup some CI as well, running |
We'd love to have It might require some work, but testing with |
Copied from #78:
I would be interested in giving it a try. However, after looking a bit through the codebase, I feel that it might be somewhat complicated and not that easy at the moment.
I think that's still true, but there is an open and active proposal to add the functionality to create sockets (https://github.com/WebAssembly/wasi-sockets/blob/f2ffc745086ec7ab168f1244f2b3ef0342bf9ddc/wit/tcp-create-socket.wit#L26 and https://github.com/WebAssembly/wasi-sockets/blob/f2ffc745086ec7ab168f1244f2b3ef0342bf9ddc/wit/udp-create-socket.wit#L26) which is currently in 'Phase 3 - Implementation Phase (CG + WG)'. The proposal has been already introduced in At the time of writing, WASIX has support via I'm just a random user who stumbled upon this problem: |
I'm ok with supporting WASI preview 2, but rustc isn't quite ready yet I think, see https://blog.rust-lang.org/2024/04/09/updates-to-rusts-wasi-targets.html (which you also linked). I think WASIX is a no-go as that's vendor specific. Maybe as an alternative target, but I'm not how that would work at the moment. Overall I'm also ok with reducing the socket2 to something that is supported on wasi preview 1 (and only wasi) so that it can at least build. |
Yeah, I think it's a bit too early for WASI preview 2. However, I believe that when the target is released, it can be implemented into
I'm also not quite sure how a WASIX implementation should look, and to my knowledge, WASIX is only meant to be a polyfill until the official standard is fully developed.
I think it would also help when implementing I would be really interested in giving this a try, but because of university, I don't have much free time. Do you know if there is some kind of tracking issue for Edit: Or some documentation on how to introduce a new target into |
After a quick search I can't find any tracking issues, but let's focus on preview 1 initially.
There aren't a lot of of docs, but I can give a quick overview. The first thing would be to start running Line 331 in 6923954
not(wasm) to most of the API to begin with.
Once Once it builds/checks, ideally we find a way to run the tests. Since wasm can't create their own sockets (yet), this will be painful as most if not all of the tests do this. Feel free to skip this entirely. Final step would be to add some kind of CI, again tests would be ideal, but running socket2/.github/workflows/main.yml Line 59 in 6923954
socket2/.github/workflows/main.yml Line 97 in 6923954
Line 3 in 6923954
|
@LetsMelon if you have any questions feel free to open a draft pr and ping me. Or you can leave them here. |
@Thomasdezeeuw thanks for your quick reply and your help! I will try to look into the codebase over the weekend. My current plan is to fix all |
any update ? |
No update, nobody is working on this. |
We can support wasm via wasi. Last I looked (for tokio-rs/mio#1395, back in November 2020) it doesn't support creating sockets, but it does support some things like read/write.
Alternatively we could start with an implementation that just panics, just so socket2 can build on wasm.
The text was updated successfully, but these errors were encountered: