From bd2c6ab076ffcbbf7b5cf2063d1cac7f9e2b7d3b Mon Sep 17 00:00:00 2001 From: Scott Andrews Date: Fri, 12 Dec 2025 13:16:42 -0500 Subject: [PATCH] Update wasi interfaces to 0.2.6 Signed-off-by: Scott Andrews --- .github/workflows/ci.yaml | 8 -- Makefile | 5 +- README.md | 2 +- components/levels/src/lib.rs | 1 + components/to-stdout/src/lib.rs | 1 + rust-toolchain.toml | 3 + .../package.wit | 91 +++++++++++-------- .../package.wit | 60 +++++++++++- .../package.wit | 6 +- .../package.wit | 2 +- .../package.wit | 2 +- .../package.wit | 16 ++-- wit/worlds.wit | 4 +- wkg.lock | 12 +-- 14 files changed, 141 insertions(+), 72 deletions(-) create mode 100644 rust-toolchain.toml rename wit/deps/{wasi-cli-0.2.3 => wasi-cli-0.2.6}/package.wit (71%) rename wit/deps/{wasi-clocks-0.2.3 => wasi-clocks-0.2.6}/package.wit (60%) rename wit/deps/{wasi-filesystem-0.2.3 => wasi-filesystem-0.2.6}/package.wit (96%) rename wit/deps/{wasi-io-0.2.3 => wasi-io-0.2.6}/package.wit (98%) rename wit/deps/{wasi-random-0.2.3 => wasi-random-0.2.6}/package.wit (91%) rename wit/deps/{wasi-sockets-0.2.3 => wasi-sockets-0.2.6}/package.wit (93%) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fa2e07f..bc16c6d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,10 +14,6 @@ jobs: steps: - uses: actions/checkout@v6 - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - toolchain: 1.84.1 - components: rustfmt - target: wasm32-unknown-unknown,wasm32-wasip2 - name: Install cargo binstall uses: cargo-bins/cargo-binstall@main - name: Install cargo component @@ -61,10 +57,6 @@ jobs: steps: - uses: actions/checkout@v6 - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - toolchain: 1.84.1 - components: rustfmt - target: wasm32-unknown-unknown - name: Install cargo binstall uses: cargo-bins/cargo-binstall@main - name: Install wkg diff --git a/Makefile b/Makefile index c27992c..141a5b2 100644 --- a/Makefile +++ b/Makefile @@ -20,9 +20,8 @@ components: $(foreach component,$(COMPONENTS),lib/$(component).wasm $(foreach co define BUILD_COMPONENT lib/$1.wasm: Cargo.toml Cargo.lock wit/deps $(shell find components/$1 -type f) - @$(eval TARGET := $(if $(findstring $1,keyvalue-to-filesystem),wasm32-wasip2,wasm32-unknown-unknown)) - cargo component build -p $1 --target $(TARGET) --release - cp target/$(TARGET)/release/$(subst -,_,$1).wasm lib/$1.wasm + cargo component build -p $1 --target wasm32-unknown-unknown --release + cp target/wasm32-unknown-unknown/release/$(subst -,_,$1).wasm lib/$1.wasm cp components/$1/README.md lib/$1.wasm.md lib/$1.debug.wasm: Cargo.toml Cargo.lock wit/deps $(shell find components/$1 -type f) diff --git a/README.md b/README.md index 2ab95e0..5833593 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ A collection of utility components that remix wasi:logging types and interfaces. ## Build Prereqs: -- a rust toolchain with a recent nightly (`rustup toolchain install nightly`) +- a rust toolchain - [`cargo component`](https://github.com/bytecodealliance/cargo-component) - [`wkg`](https://github.com/bytecodealliance/wasm-pkg-tools) diff --git a/components/levels/src/lib.rs b/components/levels/src/lib.rs index 69792ec..2db0969 100644 --- a/components/levels/src/lib.rs +++ b/components/levels/src/lib.rs @@ -111,6 +111,7 @@ fn level_map(level: Level) -> logging::Level { wit_bindgen::generate!({ path: "../../wit", world: "levels", + features: ["clocks-timezone"], generate_all }); diff --git a/components/to-stdout/src/lib.rs b/components/to-stdout/src/lib.rs index 508cedb..0816daa 100644 --- a/components/to-stdout/src/lib.rs +++ b/components/to-stdout/src/lib.rs @@ -43,6 +43,7 @@ impl Guest for LoggingToStdout { wit_bindgen::generate!({ path: "../../wit", world: "to-stdout", + features: ["clocks-timezone"], generate_all }); diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..798c4ad --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.91" +targets = [ "wasm32-unknown-unknown", "wasm32-wasip2" ] diff --git a/wit/deps/wasi-cli-0.2.3/package.wit b/wit/deps/wasi-cli-0.2.6/package.wit similarity index 71% rename from wit/deps/wasi-cli-0.2.3/package.wit rename to wit/deps/wasi-cli-0.2.6/package.wit index b86dfec..d7a3ca4 100644 --- a/wit/deps/wasi-cli-0.2.3/package.wit +++ b/wit/deps/wasi-cli-0.2.6/package.wit @@ -1,4 +1,4 @@ -package wasi:cli@0.2.3; +package wasi:cli@0.2.6; @since(version = 0.2.0) interface environment { @@ -28,6 +28,17 @@ interface exit { /// Exit the current instance and any linked instances. @since(version = 0.2.0) exit: func(status: result); + + /// Exit the current instance and any linked instances, reporting the + /// specified status code to the host. + /// + /// The meaning of the code depends on the context, with 0 usually meaning + /// "success", and other values indicating various types of failure. + /// + /// This function does not return; the effect is analogous to a trap, but + /// without the connotation that something bad has happened. + @unstable(feature = cli-exit-with-code) + exit-with-code: func(status-code: u8); } @since(version = 0.2.0) @@ -40,7 +51,7 @@ interface run { @since(version = 0.2.0) interface stdin { @since(version = 0.2.0) - use wasi:io/streams@0.2.3.{input-stream}; + use wasi:io/streams@0.2.6.{input-stream}; @since(version = 0.2.0) get-stdin: func() -> input-stream; @@ -49,7 +60,7 @@ interface stdin { @since(version = 0.2.0) interface stdout { @since(version = 0.2.0) - use wasi:io/streams@0.2.3.{output-stream}; + use wasi:io/streams@0.2.6.{output-stream}; @since(version = 0.2.0) get-stdout: func() -> output-stream; @@ -58,7 +69,7 @@ interface stdout { @since(version = 0.2.0) interface stderr { @since(version = 0.2.0) - use wasi:io/streams@0.2.3.{output-stream}; + use wasi:io/streams@0.2.6.{output-stream}; @since(version = 0.2.0) get-stderr: func() -> output-stream; @@ -134,11 +145,11 @@ world imports { @since(version = 0.2.0) import exit; @since(version = 0.2.0) - import wasi:io/error@0.2.3; + import wasi:io/error@0.2.6; @since(version = 0.2.0) - import wasi:io/poll@0.2.3; + import wasi:io/poll@0.2.6; @since(version = 0.2.0) - import wasi:io/streams@0.2.3; + import wasi:io/streams@0.2.6; @since(version = 0.2.0) import stdin; @since(version = 0.2.0) @@ -156,33 +167,35 @@ world imports { @since(version = 0.2.0) import terminal-stderr; @since(version = 0.2.0) - import wasi:clocks/monotonic-clock@0.2.3; + import wasi:clocks/monotonic-clock@0.2.6; @since(version = 0.2.0) - import wasi:clocks/wall-clock@0.2.3; + import wasi:clocks/wall-clock@0.2.6; + @unstable(feature = clocks-timezone) + import wasi:clocks/timezone@0.2.6; @since(version = 0.2.0) - import wasi:filesystem/types@0.2.3; + import wasi:filesystem/types@0.2.6; @since(version = 0.2.0) - import wasi:filesystem/preopens@0.2.3; + import wasi:filesystem/preopens@0.2.6; @since(version = 0.2.0) - import wasi:sockets/network@0.2.3; + import wasi:sockets/network@0.2.6; @since(version = 0.2.0) - import wasi:sockets/instance-network@0.2.3; + import wasi:sockets/instance-network@0.2.6; @since(version = 0.2.0) - import wasi:sockets/udp@0.2.3; + import wasi:sockets/udp@0.2.6; @since(version = 0.2.0) - import wasi:sockets/udp-create-socket@0.2.3; + import wasi:sockets/udp-create-socket@0.2.6; @since(version = 0.2.0) - import wasi:sockets/tcp@0.2.3; + import wasi:sockets/tcp@0.2.6; @since(version = 0.2.0) - import wasi:sockets/tcp-create-socket@0.2.3; + import wasi:sockets/tcp-create-socket@0.2.6; @since(version = 0.2.0) - import wasi:sockets/ip-name-lookup@0.2.3; + import wasi:sockets/ip-name-lookup@0.2.6; @since(version = 0.2.0) - import wasi:random/random@0.2.3; + import wasi:random/random@0.2.6; @since(version = 0.2.0) - import wasi:random/insecure@0.2.3; + import wasi:random/insecure@0.2.6; @since(version = 0.2.0) - import wasi:random/insecure-seed@0.2.3; + import wasi:random/insecure-seed@0.2.6; } @since(version = 0.2.0) world command { @@ -191,11 +204,11 @@ world command { @since(version = 0.2.0) import exit; @since(version = 0.2.0) - import wasi:io/error@0.2.3; + import wasi:io/error@0.2.6; @since(version = 0.2.0) - import wasi:io/poll@0.2.3; + import wasi:io/poll@0.2.6; @since(version = 0.2.0) - import wasi:io/streams@0.2.3; + import wasi:io/streams@0.2.6; @since(version = 0.2.0) import stdin; @since(version = 0.2.0) @@ -213,33 +226,35 @@ world command { @since(version = 0.2.0) import terminal-stderr; @since(version = 0.2.0) - import wasi:clocks/monotonic-clock@0.2.3; + import wasi:clocks/monotonic-clock@0.2.6; @since(version = 0.2.0) - import wasi:clocks/wall-clock@0.2.3; + import wasi:clocks/wall-clock@0.2.6; + @unstable(feature = clocks-timezone) + import wasi:clocks/timezone@0.2.6; @since(version = 0.2.0) - import wasi:filesystem/types@0.2.3; + import wasi:filesystem/types@0.2.6; @since(version = 0.2.0) - import wasi:filesystem/preopens@0.2.3; + import wasi:filesystem/preopens@0.2.6; @since(version = 0.2.0) - import wasi:sockets/network@0.2.3; + import wasi:sockets/network@0.2.6; @since(version = 0.2.0) - import wasi:sockets/instance-network@0.2.3; + import wasi:sockets/instance-network@0.2.6; @since(version = 0.2.0) - import wasi:sockets/udp@0.2.3; + import wasi:sockets/udp@0.2.6; @since(version = 0.2.0) - import wasi:sockets/udp-create-socket@0.2.3; + import wasi:sockets/udp-create-socket@0.2.6; @since(version = 0.2.0) - import wasi:sockets/tcp@0.2.3; + import wasi:sockets/tcp@0.2.6; @since(version = 0.2.0) - import wasi:sockets/tcp-create-socket@0.2.3; + import wasi:sockets/tcp-create-socket@0.2.6; @since(version = 0.2.0) - import wasi:sockets/ip-name-lookup@0.2.3; + import wasi:sockets/ip-name-lookup@0.2.6; @since(version = 0.2.0) - import wasi:random/random@0.2.3; + import wasi:random/random@0.2.6; @since(version = 0.2.0) - import wasi:random/insecure@0.2.3; + import wasi:random/insecure@0.2.6; @since(version = 0.2.0) - import wasi:random/insecure-seed@0.2.3; + import wasi:random/insecure-seed@0.2.6; @since(version = 0.2.0) export run; diff --git a/wit/deps/wasi-clocks-0.2.3/package.wit b/wit/deps/wasi-clocks-0.2.6/package.wit similarity index 60% rename from wit/deps/wasi-clocks-0.2.3/package.wit rename to wit/deps/wasi-clocks-0.2.6/package.wit index a78edc8..d638f1a 100644 --- a/wit/deps/wasi-clocks-0.2.3/package.wit +++ b/wit/deps/wasi-clocks-0.2.6/package.wit @@ -1,4 +1,4 @@ -package wasi:clocks@0.2.3; +package wasi:clocks@0.2.6; /// WASI Monotonic Clock is a clock API intended to let users measure elapsed /// time. @@ -11,7 +11,7 @@ package wasi:clocks@0.2.3; @since(version = 0.2.0) interface monotonic-clock { @since(version = 0.2.0) - use wasi:io/poll@0.2.3.{pollable}; + use wasi:io/poll@0.2.6.{pollable}; /// An instant in time, in nanoseconds. An instant is relative to an /// unspecified initial value, and can only be compared to instances from @@ -92,12 +92,66 @@ interface wall-clock { resolution: func() -> datetime; } +@unstable(feature = clocks-timezone) +interface timezone { + @unstable(feature = clocks-timezone) + use wall-clock.{datetime}; + + /// Information useful for displaying the timezone of a specific `datetime`. + /// + /// This information may vary within a single `timezone` to reflect daylight + /// saving time adjustments. + @unstable(feature = clocks-timezone) + record timezone-display { + /// The number of seconds difference between UTC time and the local + /// time of the timezone. + /// + /// The returned value will always be less than 86400 which is the + /// number of seconds in a day (24*60*60). + /// + /// In implementations that do not expose an actual time zone, this + /// should return 0. + utc-offset: s32, + /// The abbreviated name of the timezone to display to a user. The name + /// `UTC` indicates Coordinated Universal Time. Otherwise, this should + /// reference local standards for the name of the time zone. + /// + /// In implementations that do not expose an actual time zone, this + /// should be the string `UTC`. + /// + /// In time zones that do not have an applicable name, a formatted + /// representation of the UTC offset may be returned, such as `-04:00`. + name: string, + /// Whether daylight saving time is active. + /// + /// In implementations that do not expose an actual time zone, this + /// should return false. + in-daylight-saving-time: bool, + } + + /// Return information needed to display the given `datetime`. This includes + /// the UTC offset, the time zone name, and a flag indicating whether + /// daylight saving time is active. + /// + /// If the timezone cannot be determined for the given `datetime`, return a + /// `timezone-display` for `UTC` with a `utc-offset` of 0 and no daylight + /// saving time. + @unstable(feature = clocks-timezone) + display: func(when: datetime) -> timezone-display; + + /// The same as `display`, but only return the UTC offset. + @unstable(feature = clocks-timezone) + utc-offset: func(when: datetime) -> s32; +} + @since(version = 0.2.0) world imports { @since(version = 0.2.0) - import wasi:io/poll@0.2.3; + import wasi:io/poll@0.2.6; @since(version = 0.2.0) import monotonic-clock; @since(version = 0.2.0) import wall-clock; + @unstable(feature = clocks-timezone) + import timezone; } diff --git a/wit/deps/wasi-filesystem-0.2.3/package.wit b/wit/deps/wasi-filesystem-0.2.6/package.wit similarity index 96% rename from wit/deps/wasi-filesystem-0.2.3/package.wit rename to wit/deps/wasi-filesystem-0.2.6/package.wit index 1111df1..78bbb1e 100644 --- a/wit/deps/wasi-filesystem-0.2.3/package.wit +++ b/wit/deps/wasi-filesystem-0.2.6/package.wit @@ -1,8 +1,8 @@ -package wasi:filesystem@0.2.3; +package wasi:filesystem@0.2.6; interface types { - use wasi:io/streams@0.2.3.{input-stream, output-stream, error}; - use wasi:clocks/wall-clock@0.2.3.{datetime}; + use wasi:io/streams@0.2.6.{input-stream, output-stream, error}; + use wasi:clocks/wall-clock@0.2.6.{datetime}; type filesize = u64; diff --git a/wit/deps/wasi-io-0.2.3/package.wit b/wit/deps/wasi-io-0.2.6/package.wit similarity index 98% rename from wit/deps/wasi-io-0.2.3/package.wit rename to wit/deps/wasi-io-0.2.6/package.wit index adcf1f4..c66abac 100644 --- a/wit/deps/wasi-io-0.2.3/package.wit +++ b/wit/deps/wasi-io-0.2.6/package.wit @@ -1,4 +1,4 @@ -package wasi:io@0.2.3; +package wasi:io@0.2.6; interface poll { resource pollable { diff --git a/wit/deps/wasi-random-0.2.3/package.wit b/wit/deps/wasi-random-0.2.6/package.wit similarity index 91% rename from wit/deps/wasi-random-0.2.3/package.wit rename to wit/deps/wasi-random-0.2.6/package.wit index bc1f891..7adcffa 100644 --- a/wit/deps/wasi-random-0.2.3/package.wit +++ b/wit/deps/wasi-random-0.2.6/package.wit @@ -1,4 +1,4 @@ -package wasi:random@0.2.3; +package wasi:random@0.2.6; interface random { get-random-bytes: func(len: u64) -> list; diff --git a/wit/deps/wasi-sockets-0.2.3/package.wit b/wit/deps/wasi-sockets-0.2.6/package.wit similarity index 93% rename from wit/deps/wasi-sockets-0.2.3/package.wit rename to wit/deps/wasi-sockets-0.2.6/package.wit index e7236e1..6bd7f21 100644 --- a/wit/deps/wasi-sockets-0.2.3/package.wit +++ b/wit/deps/wasi-sockets-0.2.6/package.wit @@ -1,6 +1,8 @@ -package wasi:sockets@0.2.3; +package wasi:sockets@0.2.6; interface network { + use wasi:io/error@0.2.6.{error}; + resource network; enum error-code { @@ -57,6 +59,8 @@ interface network { ipv4(ipv4-socket-address), ipv6(ipv6-socket-address), } + + network-error-code: func(err: borrow) -> option; } interface instance-network { @@ -66,7 +70,7 @@ interface instance-network { } interface udp { - use wasi:io/poll@0.2.3.{pollable}; + use wasi:io/poll@0.2.6.{pollable}; use network.{network, error-code, ip-socket-address, ip-address-family}; record incoming-datagram { @@ -115,9 +119,9 @@ interface udp-create-socket { } interface tcp { - use wasi:io/streams@0.2.3.{input-stream, output-stream}; - use wasi:io/poll@0.2.3.{pollable}; - use wasi:clocks/monotonic-clock@0.2.3.{duration}; + use wasi:io/streams@0.2.6.{input-stream, output-stream}; + use wasi:io/poll@0.2.6.{pollable}; + use wasi:clocks/monotonic-clock@0.2.6.{duration}; use network.{network, error-code, ip-socket-address, ip-address-family}; enum shutdown-type { @@ -166,7 +170,7 @@ interface tcp-create-socket { } interface ip-name-lookup { - use wasi:io/poll@0.2.3.{pollable}; + use wasi:io/poll@0.2.6.{pollable}; use network.{network, error-code, ip-address}; resource resolve-address-stream { diff --git a/wit/worlds.wit b/wit/worlds.wit index c8c50ec..e12a40e 100644 --- a/wit/worlds.wit +++ b/wit/worlds.wit @@ -7,7 +7,7 @@ world levels { } world to-stdout { - import wasi:cli/stdout@0.2.3; - import wasi:clocks/wall-clock@0.2.3; + import wasi:cli/stdout@0.2.6; + import wasi:clocks/wall-clock@0.2.6; export wasi:logging/logging@0.1.0-draft; } diff --git a/wkg.lock b/wkg.lock index 9e89169..6aff212 100644 --- a/wkg.lock +++ b/wkg.lock @@ -7,18 +7,18 @@ name = "wasi:cli" registry = "wasi.dev" [[packages.versions]] -requirement = "=0.2.3" -version = "0.2.3" -digest = "sha256:8f97d837e1f856a225422869d5c34752204d1befb5a04d0cd80541aec17a20c1" +requirement = "=0.2.6" +version = "0.2.6" +digest = "sha256:fdbe84136b3dd46d94305ef37f24f3cf04a70cc2026dca2592ac2ec0c9de15c7" [[packages]] name = "wasi:clocks" registry = "wasi.dev" [[packages.versions]] -requirement = "=0.2.3" -version = "0.2.3" -digest = "sha256:3bbed4e582d6209cf281cfe94e51d64fd0c9507635c5e1c68795f493b6cdada9" +requirement = "=0.2.6" +version = "0.2.6" +digest = "sha256:569984cc45d3f5a362a3b2897aabbaa3cc4184a6113bfcbbf03c1bd7fc20338c" [[packages]] name = "wasi:config"