Skip to content

Commit dc8e573

Browse files
feat: initial wasi p1 implementation
Signed-off-by: Henry <mail@henrygressmann.de>
1 parent 741955a commit dc8e573

24 files changed

Lines changed: 2753 additions & 23 deletions

File tree

Cargo.lock

Lines changed: 291 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ publish = false
88
[workspace]
99
resolver = "3"
1010
members = ["crates/*"]
11-
default-members = [".", "crates/parser", "crates/tinywasm", "crates/types"]
11+
default-members = [".", "crates/parser", "crates/tinywasm", "crates/types", "crates/wasi"]
1212

1313
[workspace.package]
1414
version = "0.11.0-pre.0"
@@ -23,6 +23,7 @@ categories = ["compilers", "embedded", "no-std", "virtualization", "wasm"]
2323
tinywasm = { path = "crates/tinywasm", version = "0.11.0-pre.0", default-features = false }
2424
tinywasm-parser = { path = "crates/parser", version = "0.11.0-pre.0", default-features = false }
2525
tinywasm-types = { path = "crates/types", version = "0.11.0-pre.0", default-features = false }
26+
tinywasm-wasi = { path = "crates/wasi", version = "0.11.0-pre.0" }
2627

2728
anyhow = "1.0"
2829
log = "0.4"
@@ -37,6 +38,12 @@ wat = "1.259"
3738

3839
criterion = { version = "0.8", default-features = false, features = ["cargo_bench_support", "rayon"] }
3940

41+
[workspace.lints.cargo]
42+
unused_dependencies = "allow" # false-positive on libm
43+
44+
[workspace.lints.rust]
45+
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(rust_analyzer)"] }
46+
4047
[[example]]
4148
name = "rust"
4249
test = false
@@ -61,12 +68,13 @@ name = "tinywasm_modes"
6168
anyhow.workspace = true
6269
criterion.workspace = true
6370
pretty_env_logger.workspace = true
64-
tinywasm = { path = "crates/tinywasm" }
71+
tinywasm = { path = "crates/tinywasm", features = ["state"] }
6572
tinywasm-parser.workspace = true
73+
tinywasm-wasi.workspace = true
6674
wat.workspace = true
6775

68-
[lints.cargo]
69-
unused_dependencies = "allow" # false-positive on libm
76+
[lints]
77+
workspace = true
7078

7179
[profile.bench]
7280
opt-level = 3

crates/cli/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ tinywasm = { workspace = true, features = [
3838
"log",
3939
"std",
4040
] }
41+
tinywasm-wasi.workspace = true
4142
wasm-testsuite = { workspace = true, optional = true }
4243
wast = { workspace = true, optional = true }
4344
wat = { workspace = true, optional = true }
@@ -52,3 +53,6 @@ default = ["wast", "wat"]
5253
tests = ["dep:serde", "dep:serde_json", "dep:wasm-testsuite", "wast"]
5354
wast = ["dep:wast"]
5455
wat = ["dep:wat"]
56+
57+
[lints]
58+
workspace = true

crates/parser/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ std = ["tinywasm-types/std", "wasmparser/std"]
3232
# validate WebAssembly while parsing
3333
validate = ["wasmparser/features", "wasmparser/validate"]
3434

35-
[lints.rust]
36-
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(rust_analyzer)"] }
35+
[lints]
36+
workspace = true

crates/tinywasm/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,6 @@ nightly-tail-calls = []
132132
# note: for x86 backend selection, compile with x86-64-v3 target features
133133
# (for example: `RUSTFLAGS="-C target-cpu=x86-64-v3"`)
134134
simd-x86 = []
135+
136+
[lints]
137+
workspace = true

crates/types/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ std = ["serde?/std"]
2828

2929
# support targets without native atomic CAS
3030
portable-atomic = ["dep:portable-atomic-util"]
31+
32+
[lints]
33+
workspace = true

crates/wasi/Cargo.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[package]
2+
name = "tinywasm-wasi"
3+
version.workspace = true
4+
edition.workspace = true
5+
rust-version.workspace = true
6+
description = "WASI support for TinyWasm"
7+
repository.workspace = true
8+
license.workspace = true
9+
keywords = ["tinywasm", "wasi", "wasm", "webassembly"]
10+
categories = ["wasm"]
11+
publish = false
12+
13+
[dependencies]
14+
cap-fs-ext = "4.0.3"
15+
cap-std = "4.0.3"
16+
getrandom = "0.4.3"
17+
rustix = { version = "1.1.4", features = ["event", "fs", "net"] }
18+
tinywasm = { workspace = true, default-features = false, features = ["state"] }
19+
20+
[dev-dependencies]
21+
tinywasm = { workspace = true, features = ["parser", "state"] }
22+
wat.workspace = true
23+
24+
[lints]
25+
workspace = true

crates/wasi/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# tinywasm-wasi
2+
3+
Experimental WASI support for TinyWasm mainly targeting \*nix systems (Windows support is very limited). Currently unreleased.
4+
5+
Some behavior is based on the Bytecode Alliance `wasi-common` and
6+
`wasmtime-wasi` implementations.
7+
8+
## Future WASI support
9+
10+
Preview 2 and 3 are not planned for TinyWasm, we're probably going to wait for the final WASI 1.0 release and implement that instead.

crates/wasi/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
//! WASI support for TinyWasm.
2+
3+
/// WASI Preview 1
4+
pub mod p1;

0 commit comments

Comments
 (0)