Open2
Rustのwasm32-wasip2に関するPull requests, Crates, Cargo.tomlとか集めるスレ
Why
Rust Version 1.82.0 (2024-10-17)にPromote wasm32-wasip2 to Tier 2.がきたのでaxumをWASMで動かすための情報収集をしたい。
自力でaxumをWASMで動かせるようになったらクローズ予定。
Pull requests
mioがwasm32-wasip2サポートしたらtokioもwasm32-wasip2サポート予定。
socket2の
The wasm32-wasip2 target will be a tier 2 target starting with Rust 1.82 and will gain improved socket support in Rust 1.83, so it felt like it made sense to add support for WASIp2 now.
はこのPull requestsのことっぽい。
httpはwasi Crates使う予定なさそう。
smolもやる気なさそう。
現時点でhyper, axumはPull requestsなさそう。
Crates
getrandomは使える。
chronoも使える?
WASI専用のHTTPリクエストクライアント&Webサーバーライブラリ。
wasm32-wasip2で使える。
leptosはwasm32-wasip2サポート予定。
Cargo.toml
数ヶ月前まではlibc, socket2, tokio, hyper, reqwestのPatchを作っていた。
Runtime
$ wasmtime -V
wasmtime-cli 24.0.0 (6fc3d274c 2024-08-20)
$ wasmtime -h
Wasmtime WebAssembly Runtime
Usage: wasmtime [OPTIONS] <WASM>...
wasmtime <COMMAND>
Commands:
run Runs a WebAssembly module
config Controls Wasmtime configuration settings
compile Compiles a WebAssembly module
explore Explore the compilation of a WebAssembly module to native code
serve Serves requests from a wasi-http proxy component
settings Displays available Cranelift settings for a target
wast Runs a WebAssembly test script file
help Print this message or the help of the given subcommand(s)
Arguments:
<WASM>... The WebAssembly module to run and arguments to pass to it
Options:
-O, --optimize <KEY[=VAL[,..]]> Optimization and tuning related options for wasm performance, `-O help` to see all
-C, --codegen <KEY[=VAL[,..]]> Codegen-related configuration options, `-C help` to see all
-D, --debug <KEY[=VAL[,..]]> Debug-related configuration options, `-D help` to see all
-W, --wasm <KEY[=VAL[,..]]> Options for configuring semantic execution of WebAssembly, `-W help` to see all
-S, --wasi <KEY[=VAL[,..]]> Options for configuring WASI and its proposals, `-S help` to see all
--allow-precompiled Allow executing precompiled WebAssembly modules as `*.cwasm` files
--profile <STRATEGY> Profiling strategy (valid options are: perfmap, jitdump, vtune, guest)
--dir <HOST_DIR[::GUEST_DIR]> Grant access of a host directory to a guest
--env <NAME[=VAL]> Pass an environment variable to the program
--invoke <FUNCTION> The name of the function to run
--preload <NAME=MODULE_PATH> Load the given WebAssembly module before the main module
--argv0 <ARGV0> Override the value of `argv[0]`, typically the name of the executable of the application being run
-h, --help Print help (see more with '--help')
-V, --version Print version
If a subcommand is not provided, the `run` subcommand will be used.
Usage examples:
Running a WebAssembly module with a start function:
wasmtime example.wasm
Passing command line arguments to a WebAssembly module:
wasmtime example.wasm arg1 arg2 arg3
Invoking a specific function (e.g. `add`) in a WebAssembly module:
wasmtime --invoke add example.wasm 1 2