Add support for wasi_snapshot_preview1. (#592)
* Add support for wasi_snapshot_preview1. This adds support for the new ABI, while preserving compatibility support for the old ABI. * Fix compilation on platforms where nlink_t isn't 64-bit. * rustfmt * Fix Windows build errors.
This commit is contained in:
@@ -33,7 +33,7 @@ pub fn instantiate(data: &[u8], bin_name: &str, workspace: Option<&Path>) -> any
|
||||
|
||||
// Create our wasi context with pretty standard arguments/inheritance/etc.
|
||||
// Additionally register andy preopened directories if we have them.
|
||||
let mut builder = wasi_common::WasiCtxBuilder::new()
|
||||
let mut builder = wasi_common::old::snapshot_0::WasiCtxBuilder::new()
|
||||
.arg(bin_name)
|
||||
.arg(".")
|
||||
.inherit_stdio();
|
||||
@@ -48,11 +48,13 @@ pub fn instantiate(data: &[u8], bin_name: &str, workspace: Option<&Path>) -> any
|
||||
let (reader, _writer) = os_pipe::pipe()?;
|
||||
builder = builder.stdin(reader_to_file(reader));
|
||||
|
||||
// The current stable Rust toolchain uses the old `wasi_unstable` ABI,
|
||||
// aka `snapshot_0`.
|
||||
module_registry.insert(
|
||||
"wasi_unstable".to_owned(),
|
||||
Instance::from_handle(
|
||||
&store,
|
||||
wasmtime_wasi::instantiate_wasi_with_context(
|
||||
wasmtime_wasi::old::snapshot_0::instantiate_wasi_with_context(
|
||||
global_exports.clone(),
|
||||
builder.build().context("failed to build wasi context")?,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user