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 Wasm/WASI #598

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Support Wasm/WASI #598

wants to merge 1 commit into from

Conversation

amesgen
Copy link

@amesgen amesgen commented Jan 12, 2025

TL;DR if you want to use this to get your Wasm project to compile:

source-repository-package
  type: git
  location: https://github.com/haskell-wasm/network
  tag: ab92e48e9fdf3abe214f85fdbe5301c1280e14e9

(This is pointing to a branch where the configure script has been checked in.)


This PR adds a bunch of CPP in order to build with the GHC Wasm backend. However, nothing here is actually really Wasm-specific (e.g. the diff doesn't mention Wasm); in principle, there could be other platforms that are also missing certain network functionality similar to Wasm.

This PR probably shouldn't be merged as is; it probably makes sense to wait at least until the Wasm backend updates to WASI preview2 which seems to support more networking stuff.

For a simple example how networking stuff works with Wasm today, see https://gist.github.com/amesgen/8b7d6dc672e7818d951142afa1263dde for a simple echo server example, which can be run via

wasmtime run -S preview2=n -S tcplisten=127.0.0.1:12345 /path/to/wasi-echo-server.wasm

and interacted with via e.g. nc 127.0.0.1 12345.

However, usually, network is just an accidental dependency in projects that don't actually do any networking stuff (e.g. because they depend on streaming-commons somehow). Still, it is useful to have something that compiles on Wasm as one has to patch fewer dependencies this way.

@kazu-yamamoto
Copy link
Collaborator

I have reviewed this PR quickly.
This PR looks good to me.
Since this PR does not depend on Wasm at all, it seems to me that we can merge this PR at this moment, not waiting for anything.
If @amesgen wants to merge this PR soon, I will try to review this more deeply.

@amesgen
Copy link
Author

amesgen commented Jan 14, 2025

Thanks! I would be fine to leave this PR as draft for now, especially as WASI preview2 will probably make a lot of the diff of this PR unnecessary.

@kazu-yamamoto
Copy link
Collaborator

OK. Let's keep this PR open.

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

Successfully merging this pull request may close these issues.

2 participants