Commit Graph

2007 Commits

Author SHA1 Message Date
Dan Gohman
3757b8b1c2 Update local dependency versions too (#173)
* Bump crate versions.

* Update dependency version numbers too.

This is a follow-up to f96b6c9e72ae50fcddd488be47a2d4b5ac7b926b to
update the version numbers in the local dependencies too.
2019-11-05 15:31:39 -08:00
Dan Gohman
ab0c933eff Bump crate versions. (#171) 2019-11-05 15:13:13 -08:00
Dan Gohman
8ebe12f553 Use generated type bindings (#152)
* Use generated type bindings.

Use the witx API descriptions to generate the bulk of the contents of
host.rs, wasi.rs, and wasi32.rs.

This also prunes out many of the miscellaneous libc definitions from
those files which aren't currently in use by wasi-common. If there's
anything removed that's still needed by someone, it's easy to add things
back in.

* Remove unneeded iovec conversion routines.
2019-11-05 14:56:18 -08:00
Josh Triplett
c0c7851cb6 Fix fuzz build (#458)
Update to binaryen 0.8.1, as 0.5.0 doesn't build on current systems.

Update to match API changes in wasmtime and wasmparser.
2019-11-04 20:45:42 -08:00
Josh Triplett
bd60aa8b5e wasmtime-wast: Fix copy-pasted doc comment (#453)
wasmtime-wast's main module had the same comment as wasmtime-jit's main
module; fix it to have its own doc comment.
2019-11-04 20:44:38 -08:00
Josh Triplett
56ce6e9c9f Migrate from failure to thiserror and anyhow (#436)
* Migrate from failure to thiserror and anyhow

The failure crate invents its own traits that don't use
std::error::Error (because failure predates certain features added to
Error); this prevents using ? on an error from failure in a function
using Error. The thiserror and anyhow crates integrate with the standard
Error trait instead.

This change does not attempt to semantically change or refactor the
approach to error-handling in any portion of the code, to ensure that
the change remains straightforward to review. Modules using specific
differentiated error types move from failure_derive and derive(Fail) to
thiserror and derive(Error). Modules boxing all errors opaquely move
from failure::Error to anyhow. Modules using String as an error type
continue to do so. Code using unwrap or expect continues to do so.

Drop Display implementations when thiserror can easily derive an
identical instance.

Drop manual traversal of iter_causes; anyhow's Debug instance prints the
chain of causes by default.

Use anyhow's type alias anyhow::Result<T> in place of
std::result::Result<T, anyhow::Error> whenever possible.

* wasm2obj: Simplify error handling using existing messages

handle_module in wasm2obj manually maps
cranelift_codegen::isa::LookupError values to strings, but LookupError
values already have strings that say almost exactly the same thing.
Rely on the strings from cranelift.

* wasmtime: Rely on question-mark-in-main

The main() wrapper around rmain() completely matches the behavior of
question-mark-in-main (print error to stderr and return 1), so switch to
question-mark-in-main.

* Update to walrus 0.13 and wasm-webidl-bindings 0.6

Both crates switched from failure to anyhow; updating lets us avoid a
translation from failure to anyhow within wasmtime-interface-types.
2019-11-04 20:43:25 -08:00
Josh Triplett
0108622c7d Remove incorrect executable bits (#454)
A few .rs files and a .wasm file have the executable bit set; unset it.
2019-11-04 20:42:16 -08:00
Jakub Konka
f4ac1299b2 Fix path_rename_trailing_slashes test case on Win
This commit adds a utility routine
`strip_trailing_slashes_and_concatenate` which is common for
`path_rename` and `path_symlink` on Windows, and checks if the resolved
`PathGet` indeed contains a trailing slash(es) before striping them
off. Secondly, this commit fixes `path_rename_trailing_slashes` test
case by adding two additional checks for potentially erroneous
conditions, and raising `ENOTDIR` if any happens to be true.
2019-11-04 22:35:51 +01:00
Jakub Konka
74757fdd65 Sync wasmtime and remove wasm32 deprecated module (#165)
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.
2019-11-02 06:33:54 -07:00
Dan Gohman
95578a42ce Remove RIGHTS_SHARED_MEMORY_BASE.
This came from CloudABI, but WASI doesn't include POSIX-style
shared-memory objects.
2019-11-02 09:10:33 +01:00
Dan Gohman
86829d2447 Handle overflow in Linux's dirent_from_host. 2019-11-02 08:53:30 +01:00
Jakub Konka
b42e550d5a Replace wasm32 with wasi and wasi32
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.
2019-11-02 08:49:08 +01:00
Jakub Konka
37ce4ba2ad Fix rights in fd_pwrite; cleanup redundant borrows
This commit fixes incorrect rights check in `fd_pwrite`. Until now,
we were erroneously checking whether the `Descriptor` has
`__WASI_RIGHT_FD_READ` rights instead of `__WASI_RIGHT_FD_WRITE`.

Additionally, this commit removes redundant borrows from
`wasi_ctx.get_fd_entry(..)` calls.
2019-11-01 22:56:32 +01:00
Dan Gohman
a9e3487566 Reorganize host.rs and wasm32.rs. (#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).
2019-11-01 14:21:32 -07:00
Jakub Konka
5f5f31beab Treat all warnings as errors by default (#161)
* Treat all warnings as errors in the CI

* Build only in release mode
2019-10-31 11:45:42 +01:00
Peter Huene
3b7a00f474 Fix unused function warnings on Windows.
Unfortunately the helpers added in #154 were only used from non-Windows
implementations, which caused compiler warnings on Windows.

This commit moves the helper to be unix-specific and removes the tiny wrapper
around calling `str_to_cstring` on `PathGet.path`.
2019-10-30 23:04:27 +01:00
Jakub Konka
f4d3f08fc6 Fix path_get returning ENOTDIR when base not dir (#159)
* Fix path_get returning ENOTDIR when base not dir

This commit makes certain adjustments to `WasiCtx` and `FdEntry`
by introducing methods `get_nonvalidated_fd_entry` and
`get_nonvalidated_fd_entry_mut` which only check if the `FdEntry`
corresponding to the specified raw WASI fd exists in the context
object but **without** automatically validating the rights. Thanks
to postponing the validation until after the `FdEntry` object is
extracted from the context, it is possible to check if the extracted
`FdEntry` object is indeed a valid dir descriptor when processing
paths in `path_get` helper fn. In essence then, this commit closes
 #158.

* Remove potentially useless FdObject struct

This commit removes `FdObject` struct which wasn't really used
in our codebase, and flattens its contents into `FdEntry`. IMHO,
this cleans up a fair amount of code and generally unclutters it.

* Refactor and document `WasiCtx` and `FdEntry`

This commit refactors `WasiCtx` struct by making the collection
of `FdEntry`s stored within private, and only allowing it to be
accessed via the provided set of modifier methods (push, insert,
remove, etc.).

Additionally, this commit documents the methods of `WasiCtx` and
`FdEntry` structs for easier debugging and maintenance in the future.
2019-10-30 14:41:43 -07:00
Dan Gohman
0302f1a164 Make path_get return ENOTDIR when the base isn't a directory.
Return `ENOTDIR` instead of `ENOTCAPABLE` when `*at` functions are
given a non-directory as their base. This is in accordance with POSIX:

https://pubs.opengroup.org/onlinepubs/9699919799/functions/open.html

Currently wasi-libc contains some code to detect such cases and rewrite
`ENOTCAPABLE` to `ENOTDIR`, however it's better for WASI implementations
to just do the right thing in the first place.
2019-10-30 10:20:42 +01:00
Jakub Konka
f3a5186230 Refactor poll_oneoff on *nix (#137)
* Fixes CraneStation/wasmtime#440

This commit introduces a couple of changes/fixes:
* it annotates `log::debug!` messages with "host" to differentiate
  between file descriptors stored on the WASI side (aka the wrappers)
  and those managed by the host (aka the wrapped)
* it fixes CraneStation/wasmtime#440, i.e., incorrect passing of
  file descriptor to `poll_oneoff` where currently errenously we
  pass in the wrapper instead of the wrapped value
* it adds a couple more `log::debug!` macros calls for easier future
  debugging

* Add partial refactorting to poll_oneoff

This commit lays the groundwork for more clean up to come in
subsequent commits.

* Finalise refactoring of `poll_oneoff`

* Fix compilation error on Windows

* Address majority of suggestions and refactor

Co-authored-by: Marcin Mielniczuk <marmistrz.dev@zoho.eu>

* Add poll_oneoff test case

* Leave timeout in nanoseconds in ClockEventData

Instead of converting the timeout value from nanoseconds to
milliseconds in the host-independent impl, move the conversion
to *nix-specific impl as the conversion is currently only warranted
by the POSIX `poll` syscall.

* Don't fail immediately on bad descriptor

If the user specifies an invalid descriptor inside a subscription,
don't fail immediately but rather generate an event with the thrown
WASI error code, and continue with the remaining, potentially
correct subscriptions.
2019-10-30 09:57:59 +01:00
Dan Gohman
aecec187d7 Check for overflow when incrementing the preopen_fd counter. (#157)
If someone somehow defines more preopens than can fit in the
`__wasi_fd_t` index space, we should detect it instead of silently
wrapping around.
2019-10-29 17:11:43 -07:00
Peter Huene
de71dbec0d Implement a helper for converting &str to CString. (#154)
This commit implements a simple helper for converting `&str` to `CString` and
mapping to the appropriate WASI error.

It also adds a `path_cstring` helper method in `PathGet` where the conversion was
used the most.

Fixes #104.
2019-10-29 16:30:22 -07:00
Dan Gohman
9a5c53b3ed Make wasi-common's Error messages prettier. (#156)
Instead of returning the debug formatting, which includes the enum
names, like `Io(...)`, just run the formatting function of the inner
error objects, which is nicer for command-line use.
2019-10-29 15:46:11 -07:00
Yury Delendik
c2ba74b118 [wasmtime-api] run examples as tests (#466)
* [wasmtime-api] run example as tests

* Update wasmtime-api/tests/examples.rs

Co-Authored-By: Nick Fitzgerald <fitzgen@gmail.com>

* disable multi example test on windows
2019-10-29 17:25:54 -05: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
Josh Triplett
06e9170f30 wasmtime-py: Don't use "main.rs" for a wasm example so cargo doesn't test it (#464)
cargo test will test examples that have a "main.rs", but in this case,
the example requires manual compilation as a wasm module, and doesn't
build as a standalone program. Rename it to "demo.rs".
2019-10-29 15:47:49 +01:00
Josh Triplett
b1584aafe2 wasmtime-py: Fix formatting in README (#465) 2019-10-29 15:39:13 +01:00
Marcin Mielniczuk
2659641132 Implement clock_time_get on Windows (#119)
* 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>
2019-10-29 15:05:42 +01:00
Jakub Konka
bb5c879718 Fixes path_symlink_trailing_slashes on Windows
This commit:
* adds missing `ERROR_ALREADY_EXISTS => __WASI_EEXIST` mapping
* re-routes Win errors into correct WASI values in `symlink_*`
  fns when target exists and/or contains a trailing slash
* remaps `ERROR_INVALID_NAME => __WASI_ENOENT`
2019-10-29 11:04:16 +01:00
Josh Triplett
faee3b4bc3 wasmtime-api: reserve_exact on the correct vector (#452)
Fix what looks like a copy-paste issue in wasmtime-api/src/module.rs,
which led to calling reserve_exact on one vector before pushing that
many elements into another.
2019-10-28 12:57:51 -05:00
Jim Posen
71dd73d672 Expose some more internals publicly (#340) 2019-10-28 18:12:11 +01:00
Josh Triplett
f27e0ad53c wasmtime-wasi-c: allow(non_snake_case) to suppress warnings on consecutive underscores (#461)
wasmtime-wasi-c contains many bindgen-generated symbols like
bindgen_test_layout___wasi_event_t___wasi_event_u___wasi_event_u_fd_readwrite_t
that contain triple-underscores in them. rustc doesn't consider those
names snake-case and generates extensive warnings about them. Suppress
those warnings with allow(non_snake_case).
2019-10-28 11:42:46 +01:00
Jakub Konka
59bbfbc0d7 Remove needs_close from FdObject
This commit removes `needs_close` field from `FdObject`, and
stores the underlying `Descriptor` without the `ManuallyDrop`
wrapper.
2019-10-25 17:39:47 +02:00
Maxim Vorobjov
6eb6e342d7 Rebuild misc tests when any of test files change (#150)
* rebuild misc tests when any of test file changes

* fix build formatting

* file change validation -> build_and_generate_tests
2019-10-25 15:48:58 +02:00
Andrew Brown
3053444b57 Add more SIMD spec tests (#388)
* Add more SIMD spec tests

Also provides a helper, extract_name, for building the names needed for the generated code

* Use `cargo test ... -- --nocapture` to see test errors in CI

* Use OS-independent paths for WAST files

* Ignore 'skip-stack-guard-page'

* Temporarily disable SIMD tests

* Re-enable SIMD spec tests and only disable on Windows temporarily
2019-10-25 06:18:41 -07:00
Pat Hickey
f9a8329424 WasiCtxBuilder: add methods to provide Files each for stdio (#147) 2019-10-25 14:23:26 +02:00
Jakub Konka
b0e896e7d0 Add Github Actions badge to README 2019-10-25 11:52:18 +02:00
Jakub Konka
1c5422e052 Remove Azure Pipelines conf 2019-10-25 11:52:18 +02:00
Jakub Konka
997d411870 Bump required rustc to 1.37 in README 2019-10-25 11:52:18 +02:00
Jakub Konka
3821ce28c8 Add beta & nightly builds 2019-10-25 11:52:18 +02:00
Jakub Konka
2ada299b95 Add docs section 2019-10-25 11:52:18 +02:00
Jakub Konka
a04aa5860d Update test configuration 2019-10-25 11:52:18 +02:00
Jakub Konka
10e0b87ebf Update MSRV to 1.37.0 2019-10-25 11:52:18 +02:00
Jakub Konka
be1f8c0325 Update ci.yml 2019-10-25 11:52:18 +02:00
Jakub Konka
b0199ef396 Enable Github Actions 2019-10-25 11:52:18 +02:00
vms
a34439de42 optimize memory.grow 0 (#443) 2019-10-24 15:56:04 -07:00
Artur Jamro
5a10879d5b Enable assert_unlinkable check (#451) 2019-10-24 15:37:01 -07:00
Jakub Konka
8e45a14cec Fast-forward wasmtime to latest rev 2019-10-24 12:07:45 +02:00
Jakub Konka
875eea6052 Update poll_oneoff's signature
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.
2019-10-24 11:47:35 +02:00
Jakub Konka
3a374d0016 Update poll_oneoff API
This commit updates `poll_oneoff`'s API in a potentially least
invasive way. That is, it adds unused `WasiCtx` argument to the
syscall which will be required by #137. I am hopeful that this way
 #137 can pass all tests and hence this commit should aid the review
 process.
2019-10-24 11:19:33 +02:00
Dan Gohman
a7fa6bdb31 Fix fuzz and wasi-c builds (#447)
* Fix the wasmtime-wasi-c crate build and upgrade it to Rust 2018.

* Fix the fuzz build.
2019-10-23 14:05:23 -07:00