thread 'main' panicked at 'called Result::unwrap() on an Err value: RuntimeTerminated(TerminationDetails::BlockOnNeedsAsync)'
lucet version is latest master branch
git clone https://github.com/bytecodealliance/lucet.git
Follow is my steps:
cd ~/workplace
mkdir hello
cd hello
vim hello.c
#include <stdio.h>
int main(void)
{
puts("Hello world");
return 0;
}
wasm32-wasi-clang -Ofast -o hello.wasm hello.c
lucetc-wasi -o hello.so hello.wasm
lucet-wasi hello.so
output:
Hello world
cd lucet/docs/lucet-runtime-example
cp hello.so into docs/lucet-runtime-example/
src/main.rs content:
use lucet_runtime::{DlModule, Limits, MmapRegion, Region};
use lucet_wasi::WasiCtxBuilder;
fn main() {
// ensure the WASI symbols are exported from the final executable
lucet_wasi::export_wasi_funcs();
// load the compiled Lucet module
let dl_module = DlModule::load("hello.so").unwrap();
// create a new memory region with default limits on heap and stack size
let region = MmapRegion::create(1, &Limits::default().with_heap_memory_size(100 * 16 * 64 * 1024)).unwrap();
// instantiate the module in the memory region
let mut instance = region.new_instance(dl_module).unwrap();
// prepare the WASI context, inheriting stdio handles from the host executable
let wasi_ctx = WasiCtxBuilder::new().inherit_stdio().build();
instance.insert_embed_ctx(wasi_ctx);
// run the WASI main function
instance.run("_start", &[]).unwrap();
}
project files:
drwxr-xr-x 4 root root 4096 Jul 8 12:50 ./
drwxr-xr-x 4 root root 4096 Jul 8 11:23 ../
drwxr-xr-x 2 root root 4096 Jul 8 11:23 .cargo/
-rw-r--r-- 1 root root 290 Jul 8 11:23 Cargo.toml
-rwxr-xr-x 1 root root 389216 Jul 8 12:27 example.so*
-rwxr-xr-x 1 root root 39016 Jul 8 12:50 hello.so*
drwxr-xr-x 2 root root 4096 Jul 8 12:51 src/
cargo run
Result:
Compiling lucet-runtime-example v0.1.0 (/home/ubuntu/workplace/lucet/docs/lucet-runtime-example)
Finished dev [unoptimized + debuginfo] target(s) in 10.30s
Running /home/ubuntu/workplace/lucet/target/debug/lucet-runtime-example
thread 'main' panicked at 'called Result::unwrap() on an Err value: RuntimeTerminated(TerminationDetails::BlockOnNeedsAsync)', docs/lucet-runtime-example/src/main.rs:17:33
Who can tell me why? thanks a lot
thread 'main' panicked at 'called
Result::unwrap()on anErrvalue: RuntimeTerminated(TerminationDetails::BlockOnNeedsAsync)'lucet version is latest master branch
git clone https://github.com/bytecodealliance/lucet.git
Follow is my steps:
cd ~/workplace
mkdir hello
cd hello
vim hello.c
wasm32-wasi-clang -Ofast -o hello.wasm hello.c
lucetc-wasi -o hello.so hello.wasm
lucet-wasi hello.so
output:
Hello world
cd lucet/docs/lucet-runtime-example
cp hello.so into docs/lucet-runtime-example/
src/main.rs content:
project files:
cargo run
Result:
Compiling lucet-runtime-example v0.1.0 (/home/ubuntu/workplace/lucet/docs/lucet-runtime-example)
Finished dev [unoptimized + debuginfo] target(s) in 10.30s
Running
/home/ubuntu/workplace/lucet/target/debug/lucet-runtime-examplethread 'main' panicked at 'called
Result::unwrap()on anErrvalue: RuntimeTerminated(TerminationDetails::BlockOnNeedsAsync)', docs/lucet-runtime-example/src/main.rs:17:33Who can tell me why? thanks a lot