Stream: wasi

Topic: Testing new WASI function


view this post on Zulip Emiliano Lesende (May 26 2020 at 21:20):

@Dan Gohman I am on the process of testing the new WASI functions. I manage to run test-programs successfully, however when writing a new test my WASI functions doesn't seem to be available. After some poking around, I found that the build.rs that is inside test-programs is using cargo to compile the tests with target wasm32-wasi. It seems to me that the installed target wasm32-wasi ain't picking up my change (understandably so, why would it?). Question is, how can I make this work.

view this post on Zulip Jakub Konka (May 26 2020 at 22:05):

@Emiliano Lesende this is probably a problem with Cargo not picking up on the fact you've just dropped a brand new test case into test-programs/wasi-tests/src/bin. If you run cargo clean and then re-run the tests with cargo test --features test-programs/test_programs --package test-programs, this should hopefully include your tests as well.

view this post on Zulip Emiliano Lesende (May 26 2020 at 22:08):

@Jakub Konka It does include my test. The problem is the fact that my test doesn't compile because the WASI functions I added they are not found.

--- stderr
   Compiling libc v0.2.69
   Compiling wasi v0.9.0+wasi-snapshot-preview1
   Compiling more-asserts v0.2.1
   Compiling wasi-tests v0.16.0 (/Users/emilianolesende/Source/wasmtime/crates/test-programs/wasi-tests)
error[E0412]: cannot find type `Addr` in crate `wasi`
 --> src/bin/addr_resolve.rs:6:54
  |
6 | unsafe fn exec_addr_resolve(host: &str) -> Vec<wasi::Addr> {
  |                                                      ^^^^ not found in `wasi`

view this post on Zulip Jakub Konka (May 26 2020 at 22:12):

Oh, I see. It looks to me like you'd like to find Addr struct/enum in the wasi which so happens is a crate totally separate from anything we have in wasmtime. In fact, wasi crate the error is pointing at is here: https://github.com/bytecodealliance/wasi

Experimental WASI API bindings for Rust. Contribute to bytecodealliance/wasi development by creating an account on GitHub.

view this post on Zulip Jakub Konka (May 26 2020 at 22:12):

What you should then do, at least for testing/debugging, fork wasi crate, add your bindings, and then depend on your fork as a git dependency in test-programs

view this post on Zulip Emiliano Lesende (May 26 2020 at 22:18):

@Jakub Konka Ohhh. That was the part I was missing. I'll try that right now. Thank you. I definitely didn't do that. :)

view this post on Zulip Emiliano Lesende (Jun 03 2020 at 14:31):

@Jakub Konka I've tried compiling my own wasi, I've successfully regenerated lib_generated.rs but now when I try to compile test-programs I get a:

error[E0609]: no field `pr_type` on type `wasi::lib_generated::Prestat`
  --> src/lib.rs:18:21
   |
18 |             if stat.pr_type != wasi::PREOPENTYPE_DIR {
   |                     ^^^^^^^ unknown field
   |
   = note: available fields are: `tag`, `u`

view this post on Zulip Emiliano Lesende (Jun 03 2020 at 15:32):

@Pat Hickey It seems that test-programs hasn't been updated to use your tagged unions change on generate-raw. How I can build a pre-tagged union or is there a version of test-programs that use wasi API that is tagged union compatible?

view this post on Zulip Pat Hickey (Jun 03 2020 at 16:03):

hi, sorry about that, i'm not familiar with test-programs or was aware that it broke

view this post on Zulip Pat Hickey (Jun 03 2020 at 16:04):

the tagged unions change was carefully designed to be ABI compatible, but codegen and tools that consume struct and union fields names needed to be updated as part of the tagged unions change. can you point me to the place this is causing an issue?

view this post on Zulip Emiliano Lesende (Jun 03 2020 at 16:22):

@Pat Hickey I figured that much, I added a PR for the change. https://github.com/bytecodealliance/wasmtime/pull/1810/files

This PR adapts test-programs code to use the new tagged-unions generated code of wasi. Note that wasi dependency has not been updated, we should release a wasi 0.9.1 (which includes the tagged-unio...

view this post on Zulip Emiliano Lesende (Jun 03 2020 at 16:23):

@Pat Hickey You will need to release wasi again as 0.9.1 with the tagged unions.

view this post on Zulip Pat Hickey (Jun 03 2020 at 16:29):

ah, sorry, i didnt realize the wasi crate never got a release after the tagged unions merged. @Alex Crichton takes care of releases for that crate

view this post on Zulip Pat Hickey (Jun 03 2020 at 16:29):

it may be more appropriate to call it 0.10.0 given that its a breaking change, not an addition

view this post on Zulip Emiliano Lesende (Jun 03 2020 at 16:30):

I don't mind, I figured 0.9.1 since it wasn't wasi what changed but the generated code, 0.10.0 wounds good to me.

view this post on Zulip Emiliano Lesende (Jun 03 2020 at 16:35):

@Alex Crichton Once you tell me the version for the crate I'll update the PR

view this post on Zulip Alex Crichton (Jun 03 2020 at 16:35):

@Dan Gohman mind publishing the wasi crate? I don't think I have access on crates.io

view this post on Zulip Alex Crichton (Jun 03 2020 at 16:39):

ah ok I've been added, will publish today

view this post on Zulip Pat Hickey (Jun 03 2020 at 17:02):

thanks alex!

view this post on Zulip Alex Crichton (Jun 03 2020 at 18:34):

Ok @Emiliano Lesende I've published wasi 0.10.0

view this post on Zulip Emiliano Lesende (Jun 03 2020 at 18:43):

@Alex Crichton Thanks

view this post on Zulip Emiliano Lesende (Jun 03 2020 at 18:52):

@Alex Crichton @Pat Hickey PR updated.

view this post on Zulip Emiliano Lesende (Jun 03 2020 at 18:53):

https://github.com/bytecodealliance/wasmtime/pull/1810

This PR adapts test-programs code to use the new tagged-unions generated code of wasi. Note that wasi dependency has not been updated, we should release a wasi 0.9.1 (which includes the tagged-unio...

Last updated: Dec 23 2024 at 13:07 UTC