* Remove cmake/bindgen/llvm from wasmtime-runtime This commit removes the cmake/bindgen dependency (which removes the need for `llvm-config`) from the `wasmtime-runtime` crate. The C++ code is instead compiled with the `cc` crate (it's just one file anyway) and the interface is handwritten since it's quite small anyway. Some other changes are: * The `TrapContext` type in C++ was removed since it was unused, and it was moved to Rust with a `Cell` on each field. * Functions between Rust/C++ now return `int` instead of `bool` to make them a bit more FFI compatible portably. * The `jmp_buf` type has a workaround that will be fixed in the next commit. * Move setjmp/longjmp to C++ This commit moves the definition of setjmp and longjmp into C++. This is primarily done because it's [debatable whether it's possible to call `setjmp` from Rust][rfc]. The semantics of `setjmp` are that it returns twice but LLVM doesn't actually know about this because rustc isn't telling LLVM this information, so it's unclear whether it can ever be safe. Additionally this removes the need for Rust code to know the definition of `jmp_buf` which is a pretty hairy type to define in Rust across platforms. The solution in this commit is to move all setjmp/longjmp code to C++, and that way we should be able to guarantee that jumps over wasm JIT code should always go from C++ to C++, removing Rust from the equation for now from needing to get any fiddly bits working across platforms. This should overall help it be a bit more portable and also means Rust doesn't have to know about `jmp_buf` as a type. The previous `Vec` of `jmp_buf` is now replaced with one thread-local pointer where previous values are stored on the stack and restored when the function returns. This is intended to be functionally the same as the previous implementation. [rfc]: https://github.com/rust-lang/rfcs/issues/2625 * rustfmt * Use volatile loads/stores * Remove mention of cmake from README
81 lines
3.6 KiB
Markdown
81 lines
3.6 KiB
Markdown
# Wasmtime: a WebAssembly Runtime.
|
|
|
|
Wasmtime is a standalone wasm-only runtime for [WebAssembly], using the [Cranelift] JIT.
|
|
|
|
It runs WebAssembly code [outside of the Web], and can be used both as a command-line
|
|
utility or as a library embedded in a larger application.
|
|
|
|
[WebAssembly]: https://webassembly.org/
|
|
[Cranelift]: https://github.com/CraneStation/cranelift
|
|
[outside of the Web]: https://webassembly.org/docs/non-web/
|
|
|
|
[](https://dev.azure.com/CraneStation/Wasmtime/_build/latest?definitionId=4&branchName=master)
|
|
[](https://gitter.im/CraneStation/Lobby)
|
|

|
|
|
|
Wasmtime passes the WebAssembly spec testsuite, and supports a new system
|
|
API proposal called [WebAssembly System Interface], or WASI.
|
|
|
|
Wasmtime includes a git submodule; in order to build it, it's necessary to
|
|
obtain a full checkout, like this:
|
|
```
|
|
git clone --recurse-submodules https://github.com/CraneStation/wasmtime.git
|
|
```
|
|
|
|
To build an optimized version of Wasmtime, use Cargo:
|
|
|
|
```
|
|
cargo build --release
|
|
```
|
|
|
|
There are Rust, C, and C++ toolchains that can compile programs with WASI. See
|
|
the [WASI intro][WASI intro] for more information, and the [WASI tutorial][WASI tutorial]
|
|
for a tutorial on compiling and running programs using WASI and wasmtime, as
|
|
well as an overview of the filesystem sandboxing system.
|
|
|
|
Wasmtime does not yet implement Spectre mitigations, such as those being
|
|
pioneered [by](https://www.wasmjit.org/blog/spectre-mitigations-part-1.html)
|
|
[wasmjit](https://www.wasmjit.org/blog/spectre-mitigations-part-2.html),
|
|
however this is a subject of ongoing research.
|
|
|
|
[CloudABI]: https://cloudabi.org/
|
|
[WebAssembly System Interface]: docs/WASI-overview.md
|
|
[WASI intro]: docs/WASI-intro.md
|
|
[WASI tutorial]: docs/WASI-tutorial.md
|
|
|
|
Additional goals for Wasmtime include:
|
|
- Support a variety of host APIs (not just WASI Core), with fast calling sequences,
|
|
and develop proposals for additional API modules to be part of WASI.
|
|
[Reference Sysroot](https://github.com/WebAssembly/reference-sysroot).
|
|
- Implement the [proposed WebAssembly C API].
|
|
- Facilitate testing, experimentation, and development around the [Cranelift] and
|
|
[Lightbeam] JITs.
|
|
- Develop a native ABI used for compiling WebAssembly suitable for use in both
|
|
JIT and AOT to native object files.
|
|
|
|
[proposed WebAssembly C API]: https://github.com/rossberg/wasm-c-api
|
|
[Cranelift]: https://github.com/CraneStation/cranelift
|
|
[Lightbeam]: https://github.com/CraneStation/lightbeam
|
|
|
|
#### Including Wasmtime in your project
|
|
Wasmtime exposes an API for JIT compilation through the `wasmtime-jit` subcrate, which depends on `wasmtime-environ` and `wasmtime-runtime` for the ABI and runtime support respectively. However, this API is not documented and subject to change. Please use at your own risk!
|
|
|
|
Build the individual crates as such:
|
|
|
|
```
|
|
cargo build --package wasmtime-jit
|
|
```
|
|
|
|
Wasmtime does not currently publish these crates on crates.io. They may be included as a git dependency, like this:
|
|
|
|
```toml
|
|
[dependencies]
|
|
wasmtime-environ = { git = "https://github.com/CraneStation/wasmtime", rev = "somecommithash" }
|
|
wasmtime-runtime = { git = "https://github.com/CraneStation/wasmtime", rev = "somecommithash" }
|
|
wasmtime-jit = { git = "https://github.com/CraneStation/wasmtime", rev = "somecommithash" }
|
|
```
|
|
|
|
All three crates must be specified as dependencies for `wasmtime-jit` to build correctly, at the moment.
|
|
|
|
It's Wasmtime.
|