Skip to content

Add examples of linking and WASI #1369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

alexcrichton
Copy link
Member

This commit adds two example programs, one for linking two modules
together and one for instantiating WASI. The linkage example
additionally uses WASI to get some meaningful output at this time.

cc #1272

Copy link
Member

@sunfishcode sunfishcode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great example! Can we mention this example in the book docs somewhere, so that people reading the book can easily discover it?

wasm_byte_vec_t error;
if (wasmtime_wat2wasm(engine, &wat, bytes, &error) == 0) {
fprintf(stderr, "failed to parse wat %.*s\n", (int) error.size, error.data);
exit(0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should exit with a non-zero status.

This commit adds two example programs, one for linking two modules
together and one for instantiating WASI. The linkage example
additionally uses WASI to get some meaningful output at this time.

cc bytecodealliance#1272
@alexcrichton alexcrichton force-pushed the inter-module-examples branch from 55b6820 to be304e6 Compare March 20, 2020 21:10
@alexcrichton
Copy link
Member Author

Good idea! I've added all the examples as pages to the book, @sunfishcode want to take another look?

@github-actions github-actions bot added the wasmtime:docs Issues related to Wasmtime's documentation label Mar 20, 2020
@@ -3,7 +3,7 @@
This document shows an example of how to embed Wasmtime using the [Rust
API][apidoc] to execute a simple wasm program. Be sure to also check out the
[full API documentation][apidoc] for a full listing of what the [`wasmtime`
crate][crate] has to offer.
crate][wasmtime] has to offer.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to mention the examples here too, just to make sure people who skip ahead to the embedding chapter don't miss the examples that go along with it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

Copy link
Member

@sunfishcode sunfishcode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@alexcrichton alexcrichton merged commit e245e6d into bytecodealliance:master Mar 20, 2020
@alexcrichton alexcrichton deleted the inter-module-examples branch March 21, 2020 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wasmtime:docs Issues related to Wasmtime's documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants