Skip to content
This repository has been archived by the owner on Mar 24, 2022. It is now read-only.

Commit

Permalink
lucet-runtime-example: fix regression from #655 (#664)
Browse files Browse the repository at this point in the history
closes #663
  • Loading branch information
Pat Hickey authored Jul 15, 2021
1 parent 7d25f16 commit d49c479
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/lucet-runtime-example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2018"
[dependencies]
lucet-runtime = { path = "../../lucet-runtime" }
lucet-wasi = { path = "../../lucet-wasi" }
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }

# or, if compiling against released crates.io versions:
# lucet-runtime = "0.5.1"
Expand Down
10 changes: 6 additions & 4 deletions docs/lucet-runtime-example/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use lucet_runtime::{DlModule, Limits, MmapRegion, Region};
use lucet_wasi::WasiCtxBuilder;

fn main() {
#[tokio::main]
async fn main() {
// ensure the WASI symbols are exported from the final executable
lucet_wasi::export_wasi_funcs();
// load the compiled Lucet module
Expand All @@ -10,9 +11,10 @@ fn main() {
let region = MmapRegion::create(1, &Limits::default()).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
// prepare the WASI context, inheriting stdio handles from the host executable.
// Since we are using lucet-wasi, we need to run the instance as async!
let wasi_ctx = WasiCtxBuilder::new().inherit_stdio().build();
instance.insert_embed_ctx(wasi_ctx);
// run the WASI main function
instance.run("main", &[]).unwrap();
// run the WASI entrypoint.
instance.run_async("_start", &[], None).await.unwrap();
}

0 comments on commit d49c479

Please sign in to comment.