Commit Graph

277 Commits

Author SHA1 Message Date
Alex Crichton
8ebaaf928d Remove the wasmtime wasm2obj command (#3301)
* Remove the `wasmtime wasm2obj` command

This commit removes the `wasm2obj` subcommand of the `wasmtime` CLI.
This subcommand has a very long history and dates back quite far. While
it's existed, however, it's never been documented in terms of the output
it's produced. AFAIK it's only ever been used for debugging to see the
machine code output of Wasmtime on some modules. With recent changes to
the module serialization output the output of `wasmtime compile`, the
`*.cwasm` file, is now a native ELF file which can be fed to standard
tools like `objdump`. Consequently I dont think there's any remaining
need to keep `wasm2obj` around itself, so this commit removes the
subcommand.

* More code to delete

* Try to fix debuginfo tests
2021-09-08 10:40:58 -05:00
Aaron Turner
191051b644 Docs: Created the Wasmtime Markdown Parser Example (#3193)
* Finished the Markdown Parser Example for Wasmtime

* Made requested changes

* Tiny change to explanation of `--dir` CLI arg

* Add `bash` annotations to shell script code blocks

* Trying to fix the markdown example bug

* Figured out rustdoc, and what needed to be done

* Made requested changes

Co-authored-by: Till Schneidereit <till@tillschneidereit.net>
2021-09-01 12:25:36 -05:00
Aaron Turner
331b0dee30 Updated the AssemblyScript example (#3185) 2021-08-19 09:20:04 -05:00
Aaron Turner
fb32e49ed7 Docs: Removed the extra markdown example from the Summary (#3194) 2021-08-17 11:22:08 +02:00
Alex Crichton
e0c8961333 Add memory64 support to the Wasmtime CLI and C API (#3182)
Accidentally forgotten from #3153!
2021-08-12 12:33:57 -05:00
Pat Hickey
ebbe399725 wasi tutorial: make usage string consistient between rust and c programs (#3098)
closes #3093
2021-07-19 15:04:33 -05:00
Olivier Lemasle
65a902f49d [doc] Update go example (#3065) 2021-07-12 09:01:44 -05:00
Andrew Brown
a83497e0b0 [doc] Add LLDB tips and tricks 2021-07-09 15:45:28 -07:00
Andrew Brown
16379db174 [doc] Add filler text to examples landing page 2021-07-09 06:22:25 -07:00
Andrew Brown
e5d25bc216 [doc] Add some documentation for debugging
The previous documentation only covers how to enable debug info when
embedding Wasmtime. This change should cover the commonly-asked
question: how do I debug in Wasmtime?
2021-07-09 06:22:25 -07:00
Benjamin Bouvier
93b7cdd6a2 Fix a few typos in the architecture doc (#3054) 2021-07-02 13:09:58 -05:00
Alex Crichton
aa5d837428 Start a high-level architecture document for Wasmtime (#3019)
* Start a high-level architecture document for Wasmtime

This commit cleands up some existing documentation by removing a number
of "noop README files" and starting a high-level overview of the
architecture of Wasmtime. I've placed this documentation under the
contributing section of the book since it seems most useful for possible
contributors.

I've surely left some things out in this pass, and am happy to add more!

* Review comments

* More rewording

* typos
2021-07-02 09:02:26 -05:00
Tshepang Lekhonkhobe
a3e08ee535 this option is default since early 2018 (#3042)
WASI was only added in Rust about a year from then
2021-06-30 09:34:34 -05:00
Alex Crichton
7a1b7cdf92 Implement RFC 11: Redesigning Wasmtime's APIs (#2897)
Implement Wasmtime's new API as designed by RFC 11. This is quite a large commit which has had lots of discussion externally, so for more information it's best to read the RFC thread and the PR thread.
2021-06-03 09:10:53 -05:00
Till Schneidereit
3b3b126fe2 Refer to BA security policy (#2912) 2021-05-19 18:24:42 +02:00
Alex Crichton
7ec073cef1 Bring back per-thread lazy initialization (#2863)
* Bring back per-thread lazy initialization

Platforms Wasmtime supports may have per-thread initialization that
needs to run before WebAssembly. For example Unix needs to setup a
sigaltstack and macOS needs to set up mach ports. In #2757 this
per-thread setup was moved out of the invocation of a wasm function,
relying on the lack of Send for Store to initialize the thread at Store
creation time and never worry about it later.

This conflicted with [wasmtime's desired multithreading
story](https://github.com/bytecodealliance/wasmtime/pull/2812) so a new
[`Store::notify_switched_thread` was
added](https://github.com/bytecodealliance/wasmtime/pull/2822) to
explicitly indicate a Store has moved to another thread (if it unsafely
did so).

It turns out though that it's not always easy to determine when a
`Store` moves to a new thread. For example the Go bindings for Wasmtime
are generally unaware when a goroutine switches OS threads. This led to
https://github.com/bytecodealliance/wasmtime-go/issues/74 where a SIGILL
was left uncaught, making it appear that traps aren't working properly.

This commit revisits the decision in #2757 and moves per-thread
initialization back into the path of calling into WebAssembly. This is
differently from before, though, where there's still only one TLS access
on the path of calling into WebAssembly, unlike before where it was a
separate access. This allows us to get the speed benefits of #2757 as
well as the flexibility benefits of not having to explicitly move a
store between threads.

With this new ability this commit deletes the recently added
`Store::notify_switched_thread` method since it's no longer necessary.

* Fix a test compiling
2021-04-28 12:08:27 -05:00
Benjamin Bouvier
ba73b458b8 Introduce a new API that allows notifying that a Store has moved to a new thread (#2822)
* Introduce a new API that allows notifying that a Store has moved to a new thread

* Add backlink to documentation, and mention the new API in the multithreading doc;
2021-04-16 11:15:35 -05:00
Alex Crichton
e43d94033f Document guidance around multithreading and Wasmtime (#2812)
* Document guidance around multithreading and Wasmtime

This commit writes a page of documentation for the Wasmtime book to
serve as guidance for embedders looking to add multithreading with
Wasmtime support. As always with any safe Rust API this reading is
optional because you can't mis-use Wasmtime without `unsafe`, but I'm
hoping that this documentation can serve as a point of reference for
folks who want to add multithreading but are confused/annoyed that
Wasmtime's types do not implement the `Send` and `Sync` traits.

Closes #793

* I can type
2021-04-07 16:34:07 -05:00
Peter Huene
9e7d2fed98 Sort output in wasmtime settings.
This commit sorts the settings output by the `wasmtime settings` command.
2021-04-01 19:38:19 -07:00
Peter Huene
29d366db7b Add a compile command to Wasmtime.
This commit adds a `compile` command to the Wasmtime CLI.

The command can be used to Ahead-Of-Time (AOT) compile WebAssembly modules.

With the `all-arch` feature enabled, AOT compilation can be performed for
non-native architectures (i.e. cross-compilation).

The `Module::compile` method has been added to perform AOT compilation.

A few of the CLI flags relating to "on by default" Wasm features have been
changed to be "--disable-XYZ" flags.

A simple example of using the `wasmtime compile` command:

```text
$ wasmtime compile input.wasm
$ wasmtime input.cwasm
```
2021-04-01 19:38:18 -07:00
Andrew Brown
c43d00fa34 doc: link to where oss-fuzz issues are recorded (#2780) 2021-03-26 13:01:13 -05:00
Alex Crichton
2697a18d2f Redo the statically typed Func API (#2719)
* Redo the statically typed `Func` API

This commit reimplements the `Func` API with respect to statically typed
dispatch. Previously `Func` had a `getN` and `getN_async` family of
methods which were implemented for 0 to 16 parameters. The return value
of these functions was an `impl Fn(..)` closure with the appropriate
parameters and return values.

There are a number of downsides with this approach that have become
apparent over time:

* The addition of `*_async` doubled the API surface area (which is quite
  large here due to one-method-per-number-of-parameters).
* The [documentation of `Func`][old-docs] are quite verbose and feel
  "polluted" with all these getters, making it harder to understand the
  other methods that can be used to interact with a `Func`.
* These methods unconditionally pay the cost of returning an owned `impl
  Fn` with a `'static` lifetime. While cheap, this is still paying the
  cost for cloning the `Store` effectively and moving data into the
  closed-over environment.
* Storage of the return value into a struct, for example, always
  requires `Box`-ing the returned closure since it otherwise cannot be
  named.
* Recently I had the desire to implement an "unchecked" path for
  invoking wasm where you unsafely assert the type signature of a wasm
  function. Doing this with today's scheme would require doubling
  (again) the API surface area for both async and synchronous calls,
  further polluting the documentation.

The main benefit of the previous scheme is that by returning a `impl Fn`
it was quite easy and ergonomic to actually invoke the function. In
practice, though, examples would often have something akin to
`.get0::<()>()?()?` which is a lot of things to interpret all at once.
Note that `get0` means "0 parameters" yet a type parameter is passed.
There's also a double function invocation which looks like a lot of
characters all lined up in a row.

Overall, I think that the previous design is starting to show too many
cracks and deserves a rewrite. This commit is that rewrite.

The new design in this commit is to delete the `getN{,_async}` family of
functions and instead have a new API:

    impl Func {
        fn typed<P, R>(&self) -> Result<&Typed<P, R>>;
    }

    impl Typed<P, R> {
        fn call(&self, params: P) -> Result<R, Trap>;
        async fn call_async(&self, params: P) -> Result<R, Trap>;
    }

This should entirely replace the current scheme, albeit by slightly
losing ergonomics use cases. The idea behind the API is that the
existence of `Typed<P, R>` is a "proof" that the underlying function
takes `P` and returns `R`. The `Func::typed` method peforms a runtime
type-check to ensure that types all match up, and if successful you get
a `Typed` value. Otherwise an error is returned.

Once you have a `Typed` then, like `Func`, you can either `call` or
`call_async`. The difference with a `Typed`, however, is that the
params/results are statically known and hence these calls can be much
more efficient.

This is a much smaller API surface area from before and should greatly
simplify the `Func` documentation. There's still a problem where
`Func::wrapN_async` produces a lot of functions to document, but that's
now the sole offender. It's a nice benefit that the
statically-typed-async verisons are now expressed with an `async`
function rather than a function-returning-a-future which makes it both
more efficient and easier to understand.

The type `P` and `R` are intended to either be bare types (e.g. `i32`)
or tuples of any length (including 0). At this time `R` is only allowed
to be `()` or a bare `i32`-style type because multi-value is not
supported with a native ABI (yet). The `P`, however, can be any size of
tuples of parameters. This is also where some ergonomics are lost
because instead of `f(1, 2)` you now have to write `f.call((1, 2))`
(note the double-parens). Similarly `f()` becomes `f.call(())`.

Overall I feel that this is a better tradeoff than before. While not
universally better due to the loss in ergonomics I feel that this design
is much more flexible in terms of what you can do with the return value
and also understanding the API surface area (just less to take in).

[old-docs]: https://docs.rs/wasmtime/0.24.0/wasmtime/struct.Func.html#method.get0

* Rename Typed to TypedFunc

* Implement multi-value returns through `Func::typed`

* Fix examples in docs

* Fix some more errors

* More test fixes

* Rebasing and adding `get_typed_func`

* Updating tests

* Fix typo

* More doc tweaks

* Tweak visibility on `Func::invoke`

* Fix tests again
2021-03-11 14:43:34 -06:00
Dan Gohman
81c67d9438 Add a link to the wasm-ld documentation. 2021-03-03 13:26:25 -08:00
Dan Gohman
66c2827ac9 Document the -Wl,--stack-first option to clang.
As discussed in WebAssembly/wasi-libc#233, document the
`-Wl,--stack-first` option to help users diagnose stack overflow errors.
2021-03-03 13:26:25 -08:00
Pat Hickey
d8f3a62b32 dont try to make a virtfs today. instead, delete virtfs example. 2021-01-29 17:27:05 -08:00
Nick Fitzgerald
ee7131bc0b Merge pull request #2555 from alexcrichton/doc-module-linking
Document that the module linking proposal is implemented
2021-01-07 13:21:49 -08:00
Nick Fitzgerald
79aaeb5eda docs: Add wasm-{smith,encoder} crates to Wasm proposal checklist (#2554) 2021-01-07 14:11:42 -06:00
Alex Crichton
6354edc7bd Document that the module linking proposal is implemented
Forgot to do this earlier!
2021-01-07 11:41:23 -08:00
hayasshi
4c7e66e58e Fix code in WASI-tutorial.md 2021-01-04 07:06:10 -08:00
Ivan Zvonimir Horvat
309354d9e1 1272: bash script; simple gcd example (#2421) 2020-11-20 11:43:54 -06:00
Nick Fitzgerald
5256cd2e87 Update docs to reflect that reference types work on aarch64 now 2020-11-16 08:23:03 -08:00
Till Schneidereit
fc1cedb2ff Add docs.wasmtime.dev as a CNAME for the Wasmtime docs (#2317)
* Update version of mdbook used in CI

* Configure cname for wasmtime docs
2020-10-25 15:48:20 -05:00
Alex Crichton
e659d5cecd Add initial support for the multi-memory proposal (#2263)
This commit adds initial (gated) support for the multi-memory wasm
proposal. This was actually quite easy since almost all of wasmtime
already expected multi-memory to be implemented one day. The only real
substantive change is the `memory.copy` intrinsic changes, which now
accounts for the source/destination memories possibly being different.
2020-10-13 19:13:52 -05:00
Joshua Warner
eb650f6fe0 filesystem example (#2236) 2020-09-29 13:20:14 -05:00
Nick Fitzgerald
92d3261366 docs: Fix link to contributing sub-page 2020-09-28 13:16:42 -07:00
Kam Y. Tse
5514c74b06 update golang example (#2227) 2020-09-24 19:25:03 -05:00
Steve Phillips
a577667f9f Update introduction.md: typo fixes 2020-08-14 11:47:27 -04:00
Nick Fitzgerald
ef13e80bcf docs: Add contributor docs for implementing and enabling new Wasm proposals 2020-08-07 16:54:51 -07:00
Nick Fitzgerald
5647dcbb8f docs: Document and advertise our support for various Wasm proposals 2020-08-07 16:54:51 -07:00
Nick Fitzgerald
47d3c8de52 docs: Better title formatting for the coding guidelines 2020-08-07 16:54:51 -07:00
Nick Fitzgerald
bf16b33739 docs: Use Title Case for the Table of Contents 2020-08-07 16:54:51 -07:00
Leon Wang
fec77c16ac Fix a typo error in docs (#2098) 2020-08-05 09:16:32 -05:00
Alex Crichton
39ea64140f Expand doc section about "what about #![no_std]?" (#2024)
* Expand doc section about "what about `#![no_std]`?"

This commit expands the `#![no_std]` section of the documentation with
an FAQ-style set of words which explains in more detail about why we
don't support `#![no_std]` at this time, and how we can support it in
the future.

* Review comments

* Add some more words about -Zbuild-std
2020-07-29 12:53:32 -05:00
Peter Huene
9b340f27f7 Update the .NET docs for the current .NET API. (#2069) 2020-07-24 23:49:05 -05:00
Alex Crichton
978070c020 Verify crates are publish-able on CI (#2036)
This commit updates our CI to verify that all crates are publish-able at
all times on every commit. During the 0.19.0 release we found another
case where the crates as they live in this repository weren't
publish-able, so the hope is that this no longer comes up again!

The script added in this commit also takes the time/liberty to remove
the existing bump/publish scripts and instead replace them with one Rust
script originally sourced from wasm-bindgen. The intention of this
script is that it has three modes:

* `./publish bump` - bumps version numbers which are sent as a PR to get
  reviewed (probably with a changelog as well)

* `./publish verify` - run on CI on every commit, builds every crate we
  publish as if it's being published to crates.io, notably without raw
  access to other crates in the repository.

* `./publish publish` - publishes all crates to crates.io, passing the
  `--no-verify` flag to make this a much speedier process than it is
  today.
2020-07-17 16:19:35 -05:00
Alex Crichton
806d197472 Update platform support docs (#2023)
Be sure to mention Linux AArch64 as a supported platform of Wasmtime
now.
2020-07-15 10:22:08 -05:00
Jakub Konka
c3d385e935 Add link to C API docs in the guide (#2006) 2020-07-10 09:29:52 -05:00
Davy Duperron
8d7ba0ad76 wasmtime: fix typo in summary 2020-07-03 14:34:30 +02:00
Alex Crichton
920e0984d3 Link to C API docs and make a landing page
Spice up the landing page a bit for the C API documentation and then
link to it from a few places to ensure it's discoverable.
2020-07-02 08:49:27 -07:00
Alex Crichton
a92a31d850 Rename the master branch to main (#1924)
* This PR is against a branch called `main`
* Internally all docs/CI/etc is updated
* The default branch of the repo is now `main`
* All active PRs have been updated to retarget `main`

Closes #1914
2020-06-25 14:03:21 -05:00