Commit Graph

187 Commits

Author SHA1 Message Date
Dan Gohman
e41cae7db9 Fix the WASI-tutorial to handle short writes properly. (#991)
If write doesn't write the full buffer, start the next write at the
point where the write left off.

Also, usize `ssize_t` for the return types of `read` and `write`.
2020-02-25 23:12:43 -06:00
Alex Crichton
c7fb135452 Test book documentation on CI
Make sure the embedding API follows what's currently implemented!
2020-02-25 08:52:43 -08:00
Gustav Eiman
09a091802b Update rust embed example (#967) (#968)
* Update rust embed example (#967)

Ensures that the example works with the current API.
Drops mention of HostRef as the example is complete without it.

* Cleanup
2020-02-25 09:45:21 -06:00
Alex Crichton
12cff023b6 Document and codify the release process
The `wasmtime` release procees seems like it's been a bit ad-hoc up to
this point, so I figured it'd be good to try to document what we do
today and codify what should be done as well as a form of release
checklist.

I've noticed that we have a number of releases (like v0.11.0) but the
`Cargo.toml` files in the repository don't reflect the current version
of `wasmtime`. Additionally I've noticed that the [most recent release]
ended up having failed tests because `Cargo.toml` was modified but
`Cargo.lock` wasn't updated. I'm hoping that by having a checklist we
can avoid these sorts of accidental issues in the future!

[release]: https://github.com/bytecodealliance/wasmtime/runs/434690272
2020-02-24 10:46:50 -08:00
Benjamin Brittain
372cc9fa7a Update broken URL to Fuchsia docs (#936) 2020-02-12 15:37:09 +01:00
Alex Crichton
045d6a7310 Remove the need for HostRef<Store> (#771)
* Remove the need for `HostRef<Store>`

This commit goes through the public API of the `wasmtime` crate and
removes the need for `HostRef<Store>`, as discussed in #708. This commit
is accompanied with a few changes:

* The `Store` type now also implements `Default`, creating a new
  `Engine` with default settings and returning that.

* The `Store` type now implements `Clone`, and is documented as being a
  "cheap clone" aka being reference counted. As before there is no
  supported way to create a deep clone of a `Store`.

* All APIs take/return `&Store` or `Store` instead of `HostRef<Store>`,
  and `HostRef<T>` is left as purely a detail of the C API.

* The `global_exports` function is tagged as `#[doc(hidden)]` for now
  while we await its removal.

* The `Store` type is not yet `Send` nor `Sync` due to the usage of
  `global_exports`, but it is intended to become so eventually.

* Touch up comments on some examples

* Run rustfmt
2020-01-07 16:29:44 -06:00
Peter Huene
59258730c2 Use structopt instead of docopt.
This commit refactors the Wasmtime CLI tools to use `structopt` instead of
`docopt`.

The `wasmtime` tool now has the following subcommands:

* `config new` - creates a new Wasmtime configuration file.
* `run` - runs a WebAssembly module.
* `wasm2obj` - translates a Wasm module to native object file.
* `wast` - runs a test script file.

If no subcommand is specified, the `run` subcommand is used. Thus,
`wasmtime foo.wasm` should continue to function as expected.

The `wasm2obj` and `wast` tools still exist, but delegate to the same
implementation as the `wasmtime` subcommands.  The standalone `wasm2obj` and
`wast` tools may be removed in the future in favor of simply using `wasmtime`.

Included in this commit is a breaking change to the default Wasmtime
configuration file: it has been renamed from `wasmtime-cache-config.toml` to
simply `config.toml`.  The new name is less specific which will allow for
additional (non-cache-related) settings in the future.

There are some breaking changes to improve command line UX:

* The `--cache-config` option has been renamed to `--config`.
* The `--create-config-file` option has moved to the `config new` subcommand.
As a result, the `wasm2obj` and `wast` tools cannot be used to create a new
config file.
* The short form of the `--optimize` option has changed from
`-o` to `-O` for consistency.
* The `wasm2obj` command takes the output object file as a
required positional argument rather than the former required output *option*
(e.g. `wasmtime wasm2obj foo.wasm foo.obj`).
2020-01-07 13:15:28 -08:00
Alex Crichton
b9dc38f4e1 Remove need for HostRef<Engine> (#762)
This commit removes the need to use `HostRef<Engine>` in the Rust API.
Usage is retained in the C API in one location, but otherwise `Engine`
can always be used directly.

This is the first step of progress on #708 for the `Engine` type.
Changes here include:

* `Engine` is now `Clone`, and is documented as being cheap. It's not
  intended that cloning an engine creates a deep copy.
* `Engine` is now both `Send` and `Sync`, and asserted to be so.
* Usage of `Engine` in APIs no longer requires or uses `HostRef`.
2020-01-06 15:17:03 -06:00
Las
1f8921ef09 Fix typo in WASI-background.md (#755)
"loose" -> "lose"
"waidpid" -> "waitpid"
2019-12-31 12:29:27 -06:00
Mischa Spiegelmock
0e3dcaeb6e typo (#752) 2019-12-31 12:26:02 -06:00
pk
6c97cfed1e Fix broken link to polyfill source (#745)
Fix a broken link to polyfill source
2019-12-24 11:40:59 -08:00
Jonathan Reyes
fe34c8e2e5 Update WASI API C header file path (#717)
The [previous link][1] was 404ing.

[1]: https://github.com/CraneStation/wasi-libc/blob/master/libc-bottom-half/headers/public/wasi/core.h
2019-12-16 10:18:13 -06:00
Cedric Hutchings
bb5f063edf Replace 'traget' with 'target' (#687) 2019-12-09 07:28:32 -08:00
Jakub Konka
570bd7ec56 Add sections on WASI integration tests
This commit adds relevant sections on contributing new WASI
integration tests to `wasmtime`.
2019-12-04 22:27:24 +01:00
Nick Fitzgerald
06280401e0 docs: Wordsmith the specification-style tests contributing docs 2019-12-04 08:57:58 -08:00
Nick Fitzgerald
9c7079fd15 docs: Add a section about how to fuzz Wasmtime 2019-12-03 17:31:31 -08:00
Nick Fitzgerald
b74b0bc49e docs: Add a section about how to test Wasmtime 2019-12-03 17:31:10 -08:00
Nick Fitzgerald
aaa0dc4f19 docs: Add initial how-to-build documentation 2019-12-03 16:14:59 -08:00
Nick Fitzgerald
4ba52205d7 docs: Fill out the top-level contributing page a little 2019-12-03 15:15:43 -08:00
Nick Fitzgerald
14823de237 docs: Include the code of conduct directly into the mdbook
Also update the link to the organizational code of conduct so that it works in
the rendered mdbook as well as when viewed on github.
2019-12-03 15:15:43 -08:00
Josh Triplett
204b4d376a embed-rust: Find exported function by name rather than assuming index 0
While the wasm file has only one export, our introduction should set a
good example for how to find functions even for wasm files that have
multiple exports. Find the answer function by name rather than assuming
index 0.

Minor variable name change to avoid having to wrap the line.
2019-11-20 09:49:34 +01:00
Josh Triplett
4ab6445dae embed-rust: fix grammatical typo 2019-11-20 09:43:05 +01:00
Josh Triplett
2635ccb742 Rename the wasmtime_api library to match the containing wasmtime crate (#594)
* Rename the `wasmtime_api` library to match the containing `wasmtime` crate

Commit d9ca508f80 renamed the
`wasmtime-api` crate to `wasmtime`, but left the name of the library it
contains as `wasmtime_api`.

It's fairly unusual for a crate to contain a library with a different
name, and it results in rather confusing error messages for a user; if
you list `wasmtime = "0.7"` in `Cargo.toml`, you can't `use
wasmtime::*`, you have to `use wasmtime_api::*;`.

Rename the `wasmtime_api` library to `wasmtime`.

* Stop renaming wasmtime to api on imports

Various users renamed the crate formerly known as wasmtime_api to api,
and then used api:: prefixes everywhere; change those all to wasmtime::
and drop the renaming.
2019-11-19 14:47:39 -08:00
Alex Crichton
39e57e3e9a Migrate back to std:: stylistically (#554)
* Migrate back to `std::` stylistically

This commit moves away from idioms such as `alloc::` and `core::` as
imports of standard data structures and types. Instead it migrates all
crates to uniformly use `std::` for importing standard data structures
and types. This also removes the `std` and `core` features from all
crates to and removes any conditional checking for `feature = "std"`

All of this support was previously added in #407 in an effort to make
wasmtime/cranelift "`no_std` compatible". Unfortunately though this
change comes at a cost:

* The usage of `alloc` and `core` isn't idiomatic. Especially trying to
  dual between types like `HashMap` from `std` as well as from
  `hashbrown` causes imports to be surprising in some cases.
* Unfortunately there was no CI check that crates were `no_std`, so none
  of them actually were. Many crates still imported from `std` or
  depended on crates that used `std`.

It's important to note, however, that **this does not mean that wasmtime
will not run in embedded environments**. The style of the code today and
idioms aren't ready in Rust to support this degree of multiplexing and
makes it somewhat difficult to keep up with the style of `wasmtime`.
Instead it's intended that embedded runtime support will be added as
necessary. Currently only `std` is necessary to build `wasmtime`, and
platforms that natively need to execute `wasmtime` will need to use a
Rust target that supports `std`. Note though that not all of `std` needs
to be supported, but instead much of it could be configured off to
return errors, and `wasmtime` would be configured to gracefully handle
errors.

The goal of this PR is to move `wasmtime` back to idiomatic usage of
features/`std`/imports/etc and help development in the short-term.
Long-term when platform concerns arise (if any) they can be addressed by
moving back to `no_std` crates (but fixing the issues mentioned above)
or ensuring that the target in Rust has `std` available.

* Start filling out platform support doc
2019-11-18 22:04:06 -08:00
Daniel Salvadori
038a387471 Fix typo (#553) 2019-11-12 12:12:43 -08:00
Dan Gohman
c78196bd01 Update repository URLs for the Bytecode Alliance. (#550) 2019-11-12 09:18:59 -08:00
Alex Crichton
1530f2e1c6 Fill out book chapter on writing WebAssembly with Rust
* Cover `cargo wasi`
* Cover a "Hello, world!" binary
* Cover a "Hello, world!" library
* Cover a more advanced example with WebAssembly interface types
* Importing/exporting functionality basics
2019-11-11 15:09:36 -08:00
Dan Gohman
39b0d670c5 rustfmt and trim trailing whitespace. 2019-11-08 17:15:37 -08:00
Alex Crichton
cf0af20162 Move cache configuration documentation into book
Moves `CACHE_CONFIGURATION.md` into the `cli-cache.md` page of the
book. Additionally removes this from the release tarballs.
2019-11-08 13:29:01 -08:00
Dan Gohman
24218c960a Move CACHE_CONFIGURATION.md to the docs directory. 2019-11-08 09:56:02 -08:00
Dan Gohman
d9ca508f80 Rename wasmtime-api to wasmtime. 2019-11-08 06:43:07 -08:00
Dan Gohman
43b761ef5f Update the top-level README.md and embedding documentation. (#508)
* Update the top-level README.md and embedding documentation.

wasmtime-api is now the primary external API crate, so recommend that
instead of wasmtime-jit.

Also, enable wasmtime-api's C API by default, so that it shows up on
docs.rs, and to make it easier to use.

And, add basic embedding documentation and link to it from the
README.md. Credit to @yurydelendik for the content.

* Use the new wasm-c-api URL.

* Don't pass --features wasm-c-api, as it is now on by default.
2019-11-07 16:47:54 -08:00
Alex Crichton
bf526b62d3 Add book documentation skeleton and auto-publish from CI (#435)
This commit adds the skeleton of a new set of documentation for
`wasmtime` in the existing `docs` directory. This documentation is
organized and compiled with [mdbook] which the Rust project uses for
most of its own documentation as well. At a previous meeting we
brainstormed a rough skeleton of what the documentation in this book
would look like, and I've transcribed that here for an example of how
this is rendered and how it can be laid out. No actual documentation is
written yet.

This commit also additionally adds necessary support to auto-publish
both this book documentation and API documentation every time a commit
is pushed to the `master` branch. All HTML will be automatically pushed
to the `gh-pages` branch so long as the CI passes, and this should get
deployed to https://cranestation.github.io/wasmtime.

I've done a few dry-runs and I think this'll all work, but we'll likely
tweak a few things here and there after running this through CI to make
sure everything looks just as we'd like. My hope though is that after
this lands we can start actually filling out all the documentation and
being able to review it as well.

[mdbook]: https://crates.io/crates/mdbook
2019-10-29 15:55:51 +01:00
YAMAMOTO Yuji
d05561ff78 Fix deadlink to WASI API header (#431)
Fix documentation link to wasi-libc headers
2019-10-17 11:21:44 +02:00
Paul Jackson
ab8707223c clarify posix_fallocate vs fd_allocate in docs 2019-09-25 21:21:57 -07:00
Zack Slayton
1497825173 Updating link to Fuchsia blog post 2019-09-06 14:19:17 -07:00
Artur Jamro
17d676ecbc Allow colons in Windows host paths (#235) 2019-08-06 16:44:26 -07:00
Dan Gohman
6b7ebfdddc Rust 1.36, with wasm32-wasi support, is now stable! 2019-07-10 12:27:21 -07:00
Van der Auwermeulen Grégoire
d900a5f6ef Update WASI-tutorial.md
consistent
2019-06-19 07:13:51 -07:00
Van der Auwermeulen Grégoire
3425553dc6 Update WASI-tutorial.md
Update README based on feedback
2019-06-19 07:13:51 -07:00
Van der Auwermeulen Grégoire
15b85dc285 Update WASI-tutorial.md 2019-06-19 07:13:51 -07:00
Sendil Kumar
ab8f8ef5d8 Adds an explicit way to use the args inside the WebAssembly Module 2019-06-19 07:10:56 -07:00
Dan Gohman
61eb4738fe wasi-sysroot is now named wasi-libc. (#167) 2019-05-31 10:15:52 +02:00
Van der Auwermeulen Grégoire
658b5aabcc Update WASI-tutorial.md 2019-05-21 06:45:28 -07:00
Dan Gohman
2b5be77fa5 "wasm32-unknown-wasi" is now "wasm32-wasi". 2019-05-13 21:40:56 -07:00
Alan Foster
1c0efd03b3 Add example of compiling wat and running with wasmtime 2019-05-12 15:12:54 +02:00
Jakub Konka
e41d333878 Update WASI tutorial with Rust howto as well 2019-05-02 22:02:19 +02:00
Jakub Konka
5c14d1eb6f Add link to Rust version of the WASI tutorial
I thought it might be useful for future WASI users to have the WASI tutorial written not only in C but also in Rust.

I'm also happy to keep the tutorial up to date with the current state of WASI target in Rust.
2019-05-02 15:49:30 +02:00
Dan Gohman
26cbbaab41 Clarify that path_open's path is a relative path. 2019-04-29 07:34:28 -07:00
Dan Gohman
29c2616484 Update the documentation about C/C++ toolchain limitations.
Document that `setjmp`/`longjmp` and C++ exceptions are unsupported, and
update the documentation about the function signature mismatch bug to
reflect that it's now just a warning rather than a fatal error.
2019-04-28 16:41:58 -07:00