Hi, we are continuing the effort for cs-bind-gen that we started at componentize the world with @Dan Chiarlone (danbugs).
We are trying the demo from the component docs to test a simple example but getting the following error. We've build a csharp component for the Adder world but after generating the wasi component with --adapt we get an error.
wasm-tools component embed --world adder wit/calculator.wit Adder_CS/bin/Debug/net7.0/Adder_CS.wasm -o main.embed.wasm
wasm-tools component new main.embed.wasm --adapt wasi_snapshot_preview1.reactor.wasm -o main.component.wasm
wasm-tools validate main.component.wasm --features component-model
#success
wasm-tools compose calculator/target/wasm32-wasi/release/calculator.wasm -d main.component.wasm -o composed.wasm
wasm-tools compose command/target/wasm32-wasi/release/command.wasm -d composed.wasm -o command.wasm
**error: cannot import instance with name `wasi:io/streams` for an instantiation argument of component `composed` because it conflicts with an imported instantiation argument of component `$input`**
We determined this instantiation argument is coming after running wasm-tools component new main.embed.wasm --adapt wasi_snapshot_preview1.reactor.wasm
. Any ideas what might be going wrong? We don't see this output when using the Rust Adder Component.
Without knowing many details here, is that perhaps the adapters and/or WASI APIs being out-of-sync? WASI is defined by the wasi_snapshot_preview1.reactor.wasm
argument you're providing but the */target/wasm32-wasi/release/*.wasm
files, which I'm assuming are created with cargo component
, additionally have their own adapter inside of them. If they all disagree on how WASI is defined it may cause that error
you can test this out I think by using the adapters from cargo component
rather than those downloaded from the dev
release of Wasmtime (unless you're already doing this in which case ignore me)
we can try that, Is there any to see those versions in the components themselves?
oh there is! if you do wasm-tools print
you can hunt for @producers
which I think should have a git rev
nope I take that back, looks like I may be lying
I don't think there's an easy way to learn that, no, but that is a really good idea!
Might even add that to the compose, if those versions don't match then give warning or error?
Ok so using the cargo component wasi_snapshot_preview1.reactor.wasm
got past that error but now we are getting
wasmtime run -W component-model command.wasm 1 2 add
Error: failed to run main module `command.wasm`
Caused by:
0: import `wasi:io/streams` has the wrong type
1: instance export `write` has the wrong type
2: type mismatch with results
3: expected 0-tuple, found 2-tuple
we are using the dev version of the wasmtime executable, should we be using the 12.0.1 release version?
ah ok yeah that's definitely mismatched WASI definitions
12.0.1 doesn't have component model support in the CLI
the 13.0.1 release should work though, but you'll still need to make sure all adapters are in sync
where do we get 13? We built from main and ended up with version 14. I don't see any tags for 13
oh I see a branch release-13.0.0
is there a commit that would be 13.0.1? we are still having issues after building from the release-13.0.0 branch
ok, we went to the commit https://github.com/bytecodealliance/wasmtime/commit/134dddc and we are now executing the wasm module
this matched to the cargo component version
Ah yeah that works as well, but 13 isn't released yet and the branch has what will become the release in a week on the 20th
thanks we can execute modules now, but our module has a bug in it. Going to look into that tomorrow, are there wasm debugging tools? we have a stack trace but its says things are mostly <unknown>
Currently stack traces are the main debugging, and it's up to your compiler to fill in the unknown
With C/C++ that's -g
NativveAot-llvm will populate the stack trace.
Thanks for the help last week! We did get a prototype working https://github.com/danbugs/wit-bindgen-cs. There is a short video at the end of the readme.md that shows it in action
Last updated: Dec 23 2024 at 12:05 UTC