get rid of linker Rc cycle, and add debug info to test programs
This commit is contained in:
@@ -44,6 +44,7 @@ mod wasi_tests {
|
|||||||
|
|
||||||
fn build_tests(testsuite: &str, out_dir: &Path) -> io::Result<()> {
|
fn build_tests(testsuite: &str, out_dir: &Path) -> io::Result<()> {
|
||||||
let mut cmd = Command::new("cargo");
|
let mut cmd = Command::new("cargo");
|
||||||
|
cmd.env("CARGO_PROFILE_RELEASE_DEBUG", "1");
|
||||||
cmd.args(&[
|
cmd.args(&[
|
||||||
"build",
|
"build",
|
||||||
"--release",
|
"--release",
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use wasi_c2::{
|
|||||||
virt::pipe::{ReadPipe, WritePipe},
|
virt::pipe::{ReadPipe, WritePipe},
|
||||||
WasiCtx,
|
WasiCtx,
|
||||||
};
|
};
|
||||||
use wasmtime::{Linker, Module, Store};
|
use wasmtime::{Config, Engine, Linker, Module, Store};
|
||||||
|
|
||||||
pub fn instantiate(data: &[u8], bin_name: &str, workspace: Option<&Path>) -> anyhow::Result<()> {
|
pub fn instantiate(data: &[u8], bin_name: &str, workspace: Option<&Path>) -> anyhow::Result<()> {
|
||||||
let stdout = WritePipe::new_in_memory();
|
let stdout = WritePipe::new_in_memory();
|
||||||
@@ -40,13 +40,12 @@ pub fn instantiate(data: &[u8], bin_name: &str, workspace: Option<&Path>) -> any
|
|||||||
snapshot1.add_to_linker(&mut linker)?;
|
snapshot1.add_to_linker(&mut linker)?;
|
||||||
|
|
||||||
let module = Module::new(store.engine(), &data).context("failed to create wasm module")?;
|
let module = Module::new(store.engine(), &data).context("failed to create wasm module")?;
|
||||||
|
let instance = linker.instantiate(&module)?;
|
||||||
linker
|
let start = instance.get_func("_start").unwrap();
|
||||||
.module("", &module)
|
let with_type = start.get0::<()>()?;
|
||||||
.and_then(|m| m.get_default(""))
|
with_type().map_err(anyhow::Error::from)
|
||||||
.and_then(|f| f.get0::<()>())
|
|
||||||
.and_then(|f| f().map_err(Into::into))
|
|
||||||
};
|
};
|
||||||
|
|
||||||
match r {
|
match r {
|
||||||
Ok(()) => Ok(()),
|
Ok(()) => Ok(()),
|
||||||
Err(trap) => {
|
Err(trap) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user