wasi-sockets
test harnessThis is a test harness for prototyping support for
wasi-sockets in the Rust std
library and wasi-libc
.
Note that you can already use wasi-sockets
by calling host functions directly
from C, Rust, Python, and other languages with Component
Model support. What's missing
as of this writing is standard library support for those languages, which is
what this repository is intended to exercise as progress is made.
wasi-sockets
host functions
directlystd::net
. Note that, as
of this writing, tests using this guest will fail unless you use forks of
Rust and wasi-libc
as described below.tokio::net
. As with
client-std
, you'll need to use the forks discussed below.tokio-postgres
on top of tokio::net
. As with client-std
, you'll need to
use the forks discussed below.asyncio
, built as a
component by
componentize-pyredis-py
wasm32-wasi
and wasm32-unknown-unknown
targets installed)In the commands that follow, replace aarch64-apple-darwin
with your host
platform's target triple, and replace macos
with linux
or mingw
(Windows)
as appropriate.
Note that cloning the llvm-project
submodule of the rust
repo may take a
long time.
TODO: Can we speed up the Rust build by excluding tools we don't need?
curl -LO https://github.com/dicej/wasi-sdk/releases/download/wasi-sockets-alpha-5/wasi-sdk-20.46gf3a1f8991535-macos.tar.gz
tar xf wasi-sdk-20.46gf3a1f8991535-macos.tar.gz
export WASI_SDK_PATH=$(pwd)/wasi-sdk-20.46gf3a1f8991535
export WASI_SDK_SYSROOT=$WASI_SDK_PATH/share/wasi-sysroot
cd ..
git clone https://github.com/dicej/rust -b sockets
cd rust
./configure \
--target=wasm32-wasi,wasm32-unknown-unknown,aarch64-apple-darwin \
--set=target.wasm32-wasi.wasi-root=$WASI_SDK_SYSROOT \
--enable-lld \
--tools=cargo \
--prefix=$(pwd)/build/install \
--sysconfdir=$(pwd)/build/etc \
--set=build.docs=false
./x.py install
rustup toolchain link wasi-sockets build/install
export WASI_SOCKETS_TESTS_TOOLCHAIN=wasi-sockets
cd ..
Once the above is complete, you can switch to the server
directory in your
clone of this repo and run the tests:
cd server
cargo test --release
All tests should pass. If they don't, please open an issue on this repo.