Since `wasmtime` now uses `wasi` and `wasi32` modules, we can now
safely remove the `wasm32` module. This commit also updates `wasmtime`
to the latest upstream.
This commit syncs `wasmtime-wasi` crate with the latest refactoring
applied to `wasi-common` crate. Namely, `wasm32` is replaced with
two modules: `wasi` and `wasi32`. This change can be tracked via
CraneStation/wasi-common#151.
* Reorganize host.rs and wasm32.rs.
Reorganize host.rs and wasm32.rs into host.rs, wasi.rs, and wasi32.rs.
Most of the contents of host.rs was not actually host-specific, as most
of the types are fixed-size types like u32 or i64. These types are now
in wasi.rs.
The few types which do have pointer or usize-sized values now remain,
in two versions: host.rs has versions which use actual raw pointers and
usize, and wasi32.rs has versions which use u32 to represent them.
* Fix compilation on BSD
* Fix compilation on Windows
* Fully encapsulate endianness in memory.rs.
This refactors memory.rs to fully encapsulte endianness concerns, so
that outside that file, all values are in host-endian order.
This adds a dependency on the `num` crate, though it's only used for
the `PrimInt` trait, for handling endianness in a generic way.
* Use pub(crate).
* Fix some Windows warnings.
* Implement clock_time_get on Windows.
Also update misc_testsuite to include latest clock_time_get test
changes.
* improve comments
* Remove a leftover import.
Co-Authored-By: Jakub Konka <kubkon@jakubkonka.com>
This PR updates `wasmtime_wasi` crate by adjusting `poll_oneoff`'s
signature to that introduced in `wasi_common` in
CraneStation/wasi-common#137. This change is required in order to
fix#440.
This commit syncs tests with latest wasmtime revision.
As such, it now utilises the `wasmtime-api` crate for
runtime setup.
Closes#126, #127, #128, #129.
* Switch lightbeam from `wabt` to `wast`
Switch from a C++-based `*.wat` parser to a Rust-based parser
* Remove unneeded `wabt` dev-dependency from wasmtime-api
* Rewrite `wasmtime-wast` crate with `wast-parser`
This commit moves the `wasmtime-wast` crate off the `wabt` crate on to
the `wast-parser` crate which is a Rust implementation of a `*.wast` and
`*.wat` parser. The intention here is to continue to reduce the amount
of C++ required to build wasmtime!
* Use new `wat` and `wast` crate names
* deps: bump wasmparser to 0.39.2
This has a bug fix for multi-value Wasm validation that is required for getting
the spec tests passing.
https://github.com/yurydelendik/wasmparser.rs/pull/135
* Update cranelift to 0.46.1 to get multi-value Wasm support
The `cranelift_wasm` APIs had to change a little bit to maintain state necessary
when translating multi-value Wasm blocks. The `translate_module` function now
returns a `ModuleTranslationState` that is borrowed during each function's
translation.
* Enable multi-value proposal's spec tests
This enables all the Wasm multi-value proposal's spec tests other than the ones
that rely on functions having more return values than registers available on the
target. That is not supported by cranelift yet.
* wasmtime-interface-types: always use multi-value Wasm
And remove the return pointer hacks that work around the lack of multi-value.
* Put misc_testsuite behind a feature gate
This PR puts building and generating of misc_testsuite behind
a feature gate "misc_testsuite". This is mainly to allow projects
which pull `wasi-common` as a dependency not to have to have
`wasm32-wasi` target installed in order to build it as it currently
is.
* Update the CI
* Rename feature to wasm_tests
* Explain integration testing in the README
In trying to build the lightbeam feature in wasmtime there are
compile errors mostly related to outdated or missing trait
definitions. This patch moves the current cranelift codegen
dependence to 0.44 in support of that, though other changes
are still needed in wasmtime to get the feature to build.
Changes:
* use [tempfile] crate for auto mgmt of temp dirs
* use concrete types in place of generics in `utils` module
[tempfile]: https://github.com/Stebalien/tempfile
Internal modules `memory` and `host` can indeed be internal hidden
behind public-private visibility as `wasmtime-wasi` has already
been updated not to use the said modules (see
CraneStation/wasmtime#298).
* Workaround a rounding difference in the strtof function in Centos 6.
This difference causes the spec test const.wast to fail, so disable the
test on platforms where we detect the rounding difference occurs.
This commit adds a `wasmtime-rust` crate to the `misc` folder next to
the previously added Python extension. The intention is that this
showcases loading a WebAssembly file natively in Rust and how with an
attribute macro it can feel lightweight in terms of boilerplate.
The macro itself is pretty non-featureful today beyond the bare bones to
get anything working, but there's all sorts of possibilities like
JIT-compiled entry stubs we could eventually do with all the type
information!
This commit adds initial support for [WebAssembly Interface
Types][proposal] to wasmtime. This is all intended to be quite
experimental, so experimental in fact that even the name of the
[proposal] is still in flux. (this has otherwise been known as "host
bindings" or "webidl bindings" or "wasm bindings").
The goal of this commit is to start adding support the wasmtime set of
crates for WebAssembly Interface Types. A new `wasmtime-interface-types`
crate has been added with very basic support for dynamically invoking
and inspecting the various bindings of a module. This is in turn powered
by the `wasm-webidl-bindings` crate which is shared with the
`wasm-bindgen` CLI tool as a producer of this section.
Currently the only integration in `wasmtime`-the-binary itself is that
when passed the `--invoke` argument the CLI will now attempt to invoke
the target function with arguments as parsed from the command line
itself. For example if you export a function like:
fn render(&str) -> String
Then passing `--invoke render` will require one argument on the command
line, which is the first argument as a string, and the return value is
printed to the console. This differs from today's interpretation of
`--invoke` where it is a failure if the invoked function takes more than
one argument and the return values are currently ignored.
This is intended to also be the basis of embedding wasmtime in other
contexts which also want to consume WebAssembly interface types. A
Python extension is also added to this repository which implements the
`wasmtime` package on PyPI. This Python extension is intended to make it
as easy as `pip3 install wasmtime` to load a WebAssembly file with
WebAssembly Interface Types into Python. Extensions for other languages
is of course possible as well!
One of the major missing pieces from this is handling imported functions
with interface bindings. Currently the embedding support doesn't have
much ability to support handling imports ergonomically, so it's intended
that this will be included in a follow-up patch.
[proposal]: https://github.com/webassembly/webidl-bindings
Co-authored-by: Yury Delendik <ydelendik@mozilla.com>
Move `src/*.rs` to `src/bin/*.rs` which are automatically inferred as
binaries and move `src/utils.rs` to `src/lib.rs` which is compiled as a
reusable library for each of the binaries we're building.