I recently added timezones to wasi-clocks https://github.com/WebAssembly/wasi-clocks/pull/61 using the @unstable
wit feature that @Yoshua Wuyts has been working on. Unfortunately I can't seem to build the wasmtime binary and component adapter to run a trivial example. I was able to get the example to work if I don't add the @unstable
flags to the wit files, so I'm clearly missing something related to the wit feature.
Is there anything obvious I'm doing wrong here in this PR? https://github.com/bytecodealliance/wasmtime/pull/6899
Here is the example:
wit_bindgen::generate!({
features: ["clocks-timezone"],
});
fn main() {
let datetime = wasi::clocks::wall_clock::now();
let timezone_display = wasi::clocks::timezone::display(datetime);
println!("{:?}", timezone_display.name);
}
When I run cargo expand on the example, it shows the timezone code bindings. Creating the component with the adapter does not throw an error, but when I try to run the example with my wasmtime changes I get the following:
wasm-tools component new --adapt ~/workspaces/github/bytecodealliance/wasmtime/target/wasm32-wasi/release/wasi_snapshot_preview1.wasm -o component0.wasm ~/workspaces/colmurph/clock-test/target/wasm32-wasi/debug/clock-test.wasm
~/workspaces/github/bytecodealliance/wasmtime/target/debug/wasmtime component0.wasm
Error: failed to run main module `component0.wasm`
Caused by:
0: component imports instance `wasi:clocks/timezone@0.2.0`, but a matching implementation was not found in the linker
1: instance export `display` has the wrong type
2: function implementation is missing
I just realized that I was manually editing generated files. My additions were features: ["clocks-timezone"],
as an argument to bindgen!
. I'll try to figure out how those files are generated.
It looks like the component was built using time zones correctly and all but the wasmtime
binary was missing support (or it's gated by a flag). I think you might need to update/add some add_to_linker
calls in the main CLI?
Yes. Exactly right. I forgot to add_to_linker
in crates/wasi/src/lib.rs
. All set now. Thank you!
Last updated: Dec 23 2024 at 13:07 UTC