Skip to content

Provide the C WASI implementation as an option.#157

Merged
kubkon merged 2 commits intowasi-commonfrom
wasi-common-c
May 21, 2019
Merged

Provide the C WASI implementation as an option.#157
kubkon merged 2 commits intowasi-commonfrom
wasi-common-c

Conversation

@sunfishcode
Copy link
Member

This adds the C WASI implementation as a new crate, wasmtime-wasi-c,
and adds a command-line flag to the wasmtime command-line driver to
select which WASI implementation to use.

This will make it easier to test the C and Rust versions against each other. I'm finding this useful as I'm debugging the test failures in wasi-common. When we're ready to enable wasi-common by default, we can maybe put the C version behind a feature flag so that it doesn't get built by default (and we don't need the C dependencies by default) and keep it around as long as it's useful.

This adds the C WASI implementation as a new crate, wasmtime-wasi-c,
and adds a command-line flag to the wasmtime command-line driver to
select which WASI implementation to use.
@kubkon
Copy link
Member

kubkon commented May 21, 2019

Overall looks good to me. One thing though. How about we put the C version behind a target dependency, so that we don't have to disable it manually whenever we want to build wasmtime on Windows? I was thinking of something along the lines of:

let wasi = if args.flag_wasi_common {
    instantiate_wasi("", global_exports, &preopen_dirs, &argv, &environ)
} else {
    #[cfg(unix)]
    {
        wasmtime_wasi_c::instantiate_wasi_c("", global_exports, &preopen_dirs, &argv, &environ)
    }
    #[cfg(not(unix))]
    {
        unimplemented!("wasmtime-wasi-c requires a *nix")
    }
}
.expect("instantiating wasi");

and in Cargo.toml:

[target.'cfg(unix)'.dependencies]
wasmtime-wasi-c = { path = "wasmtime-wasi-c" }

@sunfishcode
Copy link
Member Author

Makes sense. I've now made this change.

@kubkon
Copy link
Member

kubkon commented May 21, 2019

Looks great, thanks!

@kubkon kubkon merged commit bd5bc94 into wasi-common May 21, 2019
@sunfishcode sunfishcode deleted the wasi-common-c branch May 27, 2019 20:39
kubkon pushed a commit that referenced this pull request Nov 7, 2019
If someone somehow defines more preopens than can fit in the
`__wasi_fd_t` index space, we should detect it instead of silently
wrapping around.
dhil added a commit to dhil/wasmtime that referenced this pull request Apr 15, 2024
avanhatt pushed a commit to wellesley-prog-sys/wasmtime that referenced this pull request Oct 18, 2024
Verify the `iabs` rules.

This did uncover an oddity that the `iabs` 32-bit and lower cases emit
extend
instructions from 32-to-32 bits. This failed at first since our ASLp
generation only generated cases with `from_bits < to_bits`.

Updates #34 #35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants