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.
* Simple module compilation cache
* Fix base64 encoding bug
* Use warn! everywhere in cache system
* Remove unused import
* Temporary workaround for long path on Windows
* Remove unused import for non-windows builds
* Add command line argument to enable cache system + apply minor review feedback
Even though this somehow passed on Travis on [the
PR](https://github.com/CraneStation/wasmtime/pull/209), it fails on
Travis on master, and I can reproduce the failure.
The failure is on spec_testsuite/names.wast:
```
$ RUST_BACKTRACE=1 target/debug/wast spec_testsuite/names.wast
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: FromUtf8Error { bytes: [255], error: Utf8Error { valid_up_to: 0, error_len: Some(1) } }', src/libcore/result.rs:999:5
stack backtrace:
[...]
9: core::result::Result<T,E>::unwrap
at /rustc/a53f9df32fbb0b5f4382caaad8f1a46f36ea887c/src/libcore/result.rs:800
10: wabt::script::jstring_to_rstring
at [...]/.cargo/registry/src/github.com-1ecc6299db9ec823/wabt-0.8.0/src/script/mod.rs:261
11: wabt::script::parse_action
at [...]/.cargo/registry/src/github.com-1ecc6299db9ec823/wabt-0.8.0/src/script/mod.rs:274
12: wabt::script::ScriptParser<F32,F64>::next
at [...]/.cargo/registry/src/github.com-1ecc6299db9ec823/wabt-0.8.0/src/script/mod.rs:504
13: wasmtime_wast::wast::WastContext::run_buffer
at wasmtime-wast/src/wast.rs:202
14: wasmtime_wast::wast::WastContext::run_file
at wasmtime-wast/src/wast.rs:472
15: wast::main
at src/wast.rs:107
[...]
```
* Rewrite FdEntry reusing as much libstd as possible
* Use the new FdEntry, FdObject, Descriptor struct in *nix impl
* Adapt Windows impl
* Remove unnecessary check in fd_read
Check `host_nread == 0` caused premature FdEntry closure and removal
which ultimately was resulting in an attempt at "double closing" of
the same file descriptor at the end of the Wasm program:
...
fd_close(fd=4)
-> errno=WASI_ESUCCESS
fd_close(fd=4)
-> errno=WASI_EBADF
* Use libstd vectored IO
* Use std:🧵:yield_now to implement sched_yield
* Add logging to integration tests
* Add preliminary support for host-specific errors
* Operate on std::fs::File in path_get on *nix
* Add cross-platform RawString type encapsulating OsStrExt
* Fix Windows build
* Update Travis and README to Rust v1.36
* Remove unused winx::handle::close helper
* Refactor Descriptor into raw handles/fds
* Strip readlinkat in prep for path_get host-independent
* Strip openat in prep for path_get host-independent
* Move ManuallyDrop up one level from Descriptor to FdObject
* Make (c)iovec host fns unsafe
* Swap unwraps/expects for Results in fdentry_impl on nix
* Rewrite fd_pread/write and implement for Win
* Use File::sync_all to impl fd_sync
* Use File::sync_data to impl fd_datasync
* Rewind file cursor after fd_p{read, write} on Windows
* Add fd_p{read, write} tests
* Handle errors instead of panicking in path_get
* Use File::set_len to impl fd_allocate
* Add test for fd_allocate
* Replace all panics with Results
* Document the point of RawString