Commit Graph

1997 Commits

Author SHA1 Message Date
Dan Gohman
58c5906f5c Fix a path to wasmtime Cargo.toml. 2019-11-08 10:00:08 -08:00
Dan Gohman
24218c960a Move CACHE_CONFIGURATION.md to the docs directory. 2019-11-08 09:56:02 -08:00
Dan Gohman
fff777d4c3 Tidy up the top-level directory by moving misc. scripts into a subdirectory. 2019-11-08 09:56:02 -08:00
Dan Gohman
a40e3b734a Update paths in cranelift-version.sh 2019-11-08 09:46:29 -08:00
Dan Gohman
31e1b1c383 Update the path to wasmtime-py. 2019-11-08 09:45:10 -08:00
Dan Gohman
9253e55321 Update the workflows for the wasmtime-api rename. 2019-11-08 09:41:34 -08:00
Dan Gohman
771e51c5c5 Fix the exclude path for wasi-misc-tests. 2019-11-08 09:37:31 -08:00
Dan Gohman
c3436ddcdf rustfmt 2019-11-08 09:06:55 -08:00
Dan Gohman
1903d66ca6 Update a path in .gitmodules. 2019-11-08 08:38:50 -08:00
Dan Gohman
b1f4e130cc Publish wasi-common and wasmtime-cli. 2019-11-08 06:43:07 -08:00
Dan Gohman
d9ca508f80 Rename wasmtime-api to wasmtime. 2019-11-08 06:43:07 -08:00
Dan Gohman
22641de629 Initial reorg.
This is largely the same as #305, but updated for the current tree.
2019-11-08 06:35:40 -08:00
Dan Gohman
2c69546a24 Merge pull request #502 from CraneStation/wasi-common
Merge wasi-common into wasmtime
2019-11-08 05:59:24 -08:00
Yury Delendik
3a8c2bbb82 Adds WASI support to markdown rust example. (#509)
* Adds WASI support to markdown rust example.

* Rename has_wasi -> find_wasi_module_name
2019-11-08 07:57:53 -06:00
Jakub Konka
4982878a95 Fix bug in fd_readdir impl on BSD
This commit fixes a subtle bug in `fd_readdir` implementation on
BSD-style nixes. In particular, the bug only resurfaced when testing in
release mode, and I can only assume it was due to a unlucky combination
of compiler optimizations and at first sight correct casting of `d_name`
pointer from `const* i8` to `const* u8`. This is now fixed by first
converting `d_name` to `std::str` by using `std::ffi::CStr::to_str`, and
then using the resultant `std::str` to copy the properly validated `u8`
contents into the Wasm buffer.

Furthermore, this commit fixes incorrect handling of the `readdir` loop
break condition. Although undocumented in BSD man pages, the signalling
is the same as on Linux where a null ptr returned by `readdir` signals
the end of the dir stream when the errno code has not changed since
before calling `readdir` inside a loop. Upon a fault such as an invalid
file descriptor, the errno *will* change after executing `readdir`.
2019-11-08 10:49:15 +01:00
Jakub Konka
ac40eff871 Fix compilation of integration tests 2019-11-08 06:58:05 +01:00
Jakub Konka
73f85f5c4b Merge branch 'master' into wasi-common 2019-11-08 06:53:18 +01:00
Dan Gohman
43b761ef5f Update the top-level README.md and embedding documentation. (#508)
* Update the top-level README.md and embedding documentation.

wasmtime-api is now the primary external API crate, so recommend that
instead of wasmtime-jit.

Also, enable wasmtime-api's C API by default, so that it shows up on
docs.rs, and to make it easier to use.

And, add basic embedding documentation and link to it from the
README.md. Credit to @yurydelendik for the content.

* Use the new wasm-c-api URL.

* Don't pass --features wasm-c-api, as it is now on by default.
2019-11-07 16:47:54 -08:00
Dan Gohman
001272fa7d rustfmt 2019-11-07 16:28:57 -08:00
Alex Crichton
59b15eab13 Simplify #[test] generation for *.wast files (#507)
This commit simplifies the build script slightly for generating tests by
doing a few dull refactorings:

* Leaves formatting to `rustfmt`
* Extract bulk of code execution into a top-level shared `run_wast`
  function so each test is a one-liner
* Use `anyhow` for errors both in the script and in tests
2019-11-07 17:01:17 -06:00
Alex Crichton
2411831964 Ensure wasi-common tests always have an unreadable stdin
Some wasi-common tests assume that stdin is never ready to be read, but
on CI stdin is closed so it's always ready to be read. Work around this
by guaranteeing that wasi-common tests always have an unreadable stdin
pipe by creating our own pipe.
2019-11-07 14:57:43 -08:00
Alex Crichton
f579dac34f Run beta/nightly test on ubuntu, not macos (#506)
This commit switches the beta/nightly tests to happen on Ubuntu instead
of macOS. Turns out GitHub Actions has scheduling limitations on macOS
that limit repositories to 5 concurrent jobs per repository, so let's
reduce the load a bit by running more builds on Linux than mac.
2019-11-07 13:51:09 -08:00
Dan Gohman
6aabdaa038 Update lightbeam's "bench" tests to use wat. (#504)
The rest of lightbeam switched from `wabt` to `wat` already, this just
updates some of the tests which aren't enabled by default.
2019-11-07 13:33:48 -08:00
Dan Gohman
d896cc34c2 Remove an obsolete workaround. (#505)
We needed a workaround when using wabt on old Linux distros due to using
old versions of `strtof`. With the switch to `wat`, we no longer need
these workarounds.
2019-11-07 13:33:17 -08:00
Peter Huene
a6b150c9d1 Merge pull request #462 from peterhuene/windows-unwind
Implement registering JIT unwind information on Windows.
2019-11-07 10:35:25 -08:00
Yury Delendik
6632a7da37 [wasmtime-api] reduce examples complexity: hostref for store/engine (#489)
* reduce amount of store.clone()

* use HostRef Engine as ref / use Engine::default()
2019-11-07 11:39:23 -06:00
Alex Crichton
55eb06ecc2 Reformat with new stable rustfmt
Fixes CI!
2019-11-07 17:20:17 +01:00
Jakub Konka
cd1e54487c Merge wasi-common into wasmtime
This commit merges [CraneStation/wasi-common] repo as a subdir of
this repo while preserving **all** of git history. There is an
initiative to pull `wasi-common` into [CraneStation/wasmtime], and
[CraneStation/wasmtime] becoming a monorepo. This came about for
several reasons with a common theme of convenience, namely,
having a monorepo:
1. cleans up the problem of dependencies (as we have seen first
   hand with dependabot enabled, it can cause some grief)
2. completely removes the problem of syncing the closely dependent
   repos (e.g., updating `wasi-common` with say a bugfix generally
   implies creating a "sync" commit for pulling in the changes into
   the "parent" repo, in this case, `wasmtime`)
3. mainly for the two reasons above, makes publishing to crates.io
   easier
4. hopefully streamlines the process of getting the community
   involved in contributing to `wasi-common` as now everything
   is one place

[CraneStation/wasi-common]: https://github.com/CraneStation/wasi-common
[CraneStation/wasmtime]: https://github.com/CraneStation/wasmtime
2019-11-07 15:45:58 +01:00
Jakub Konka
3793fa3b09 Merge wasi-misc-tests repo as a subdir (#174)
* Initial checkin.

* Update to rust-lang libc.

* Add a .gitignore file.

* Factor out functions for cleaning up files and directories.

* Fix a typo in a comment.

* Print a "Success!" message if all tests passed.

* Factor out code for creating directories.

* Add wrappers around WASI functions.

These wrappers handle converting from &str to pointer+length and handle
unsafe.

* More refactoring.

* Refactor a fd_close helper.

* Move utility functions into a separate file.

* cargo update

* Add a basic test for random_get.

* Test that directories aren't resizable.

* Test clearing __WASI_RIGHT_PATH_FILESTAT_SET_SIZE.

Ensure that clearing __WASI_RIGHT_PATH_FILESTAT_SET_SIZE succeeds before
testing file truncation.

* cargo update

* Modularise tests for easier use with wasi-common crate

* Add a Code of Conduct and CONTRIBUTING.md.

* Fix typo

* Add testcase for fd_allocate

* Add positive test for fd_renumber

* Assert bufused in readlink_no_buffer testcase

* Add positive readlink testcase

* Add testcase for fd_seek and fd_tell

* Add fd_p{read, write} test

* Add README

* Add cases with trailing slashes to interesting_paths

* Split nofollow_errors testcase into two

* nofollow_errors now operators on symlinks to existing resources
* dangling_symlink covers danling symlinks tests

* Factor out a `create_file` helper function.

* Switch from the error crate to `std::io::Error::last_os_error()`.

* Use `create_file` in the readlink test too.

* Add a test for fd_filestat_set_*

* Minor refactoring

Add missing cleanup_file calls to file_pread_pwrite and
file_seek_tell.

* Add testcase for unbuffered fd_write; fixes #11

* Add testcase for path_rename

* Use the wasi crate.

Switch from depending on libc to depending on the new wasi crate to provide
the low-level WASI interfaces.

See also https://github.com/rust-lang/libc/pull/1461.

* Add a test for path_filestat_*

* Add a test for fd_readdir

* Use expect instead of unwrap

* Add a check for ino.

* Fix the build

* Don't assume a specific order of dirents

* Better test

* Test cookie value

* Fix file types

* Fix the test

* Fix the test

* Fix the test

* Cleanup

* Minor formatting tidying in README.md.

* Fix miscellaneous clippy warnings.

* Rename the crate to wasi-misc-tests.

* Update to wasi 0.7.0.

This switches from using the libc wasi bindings to using the wasi
crate's bindings. This eliminates a git dependency on libc, updates
to the new-style bindings which use Result where possible, and treats
functions that operate on raw file descriptors as unsafe.

* Add various tests for trailing-slash behavior.

* Sync new testcases with latest upstream

* Fix path_filestat testcase

* Add smoke test for fd_advise

This test is a true smoke test as it only tests whether issuing
an advise call to the host's kernel doesn't yield an error. The
consequence of issuing such a syscall is not tested.

* Check if CLOCK_MONOTONIC is actually monotonic

* Refactor the inequality assertions for more debuggable errors.

* Bump libc from 0.2.62 to 0.2.65

Bumps [libc](https://github.com/rust-lang/libc) from 0.2.62 to 0.2.65.
- [Release notes](https://github.com/rust-lang/libc/releases)
- [Commits](https://github.com/rust-lang/libc/compare/0.2.62...0.2.65)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Fix compilation error

* Enable Actions and add rust.yml (#35)

* Enable Actions and add rust.yml

This commit enables Github Actions and adds corresponding configuration in rust.yml file.

* Update rust.yml

* Fix formatting

* Add empty .rustfmt.toml config file

* Add badge to README

* Update README

* Clean up Github Actions and README

* Add test case for `poll_oneoff` syscall (#38)

* Add test case for `poll_oneoff` syscall

This commit adds a test case for `poll_oneoff` syscall. In particular,
it builds on the excellent test use case provided by @dunnock in their
repo [poll_oneoff_tests] (thanks!), and tests:
* simple timeout
* stdin read with timeout
* fd read and fd write polls

[poll_oneoff_tests]: https://github.com/dunnock/poll_oneoff_tests

* Apply suggestions and negative test for bad fd

Co-authored-by: Maxim Vorobjov <maxim.vorobjov@gmail.com>

* Add smoke test for STDOUT/ERR readwrite poll

* Add comment on stdin/out/err

* Add a test for `*at`-style functions returning `ENOTDIR` when `dirfd` is not a dir.

* Remove misc_testsuite submodule

* Add "publish=false" to Cargo.toml; remove LICENSE
2019-11-07 13:58:57 +01:00
Adam C. Foltzer
ab3cd945bc Use new WasiCtxBuilder types from wasi-common (#490)
* use new `WasiCtxBuilder` types from wasi-common

* Update wasi-common deps
2019-11-07 12:25:43 +01:00
Adam C. Foltzer
2fe353044f Improvements to WasiCtxBuilder, and a couple bug fixes (#175)
* fix Linux `isatty` implementation

* defer `WasiCtxBuilder` errors to `build()`; don't change API yet

This changes the fields on the builder to types that let the various `.arg()`, `.env()`, etc methods
infallible, so we don't have to worry about handling any errors till we actually build. This reduces
line noise when using a builder in a downstream application.

Deferring the processing of the builder fields also has the advantage of eliminating the opening and
closing of `/dev/null` for the default stdio file descriptors unless they're actually used by the
resulting `WasiCtx`.

Unicode errors when inheriting arguments and environment variables no longer cause a panic, but
instead go through `OsString`. We return `ENOTCAPABLE` at the end if there are NULs, or if UTF-8
conversion fails on Windows.

This also changes the bounds on some of the methods from `AsRef<str>` to `AsRef<[u8]>`. This
shouldn't break any existing code, but allows more flexibility when providing arguments. Depending
on the outcome of https://github.com/WebAssembly/WASI/issues/8 we may eventually want to require
these bytes be UTF-8, so we might want to revisit this later.

Finally, this fixes a tiny bug that could arise if we had exactly the maximum number of file
descriptors when populating the preopens.

* make `WasiCtxBuilder` method types less restrictive

This is a separate commit, since it changes the interface that downstream clients have to use, and
therefore requires a different commit of `wasmtime` for testing. That `wasmtime` commit is currently
on my private fork, so this will need to be amended before merging.

Now that failures are deferred until `WasiCtxBuilder::build()`, we don't need to have `Result` types
on the other methods any longer.

Additionally, using `IntoIterator` rather than `Iterator` as the trait bound for these methods is
slightly more general, and saves the client some typing.

* enforce that arguments and environment variables are valid UTF-8

* remove now-unnecessary platform-specific OsString handling

* `ENOTCAPABLE` -> `EILSEQ` for failed arg/env string conversions

* fix up comment style

* Apply @acfoltzer's fix to isatty on Linux to BSD
2019-11-07 11:50:47 +01:00
Marcin Mielniczuk
12972c7fd3 Implement fd_readdir (#116)
* Reimpleent fd_readdir on Linux using quasi-nix.

* Implement fd_readdir on Windows.

* wip

* Adapt to upstream changes.

* Cleanup dir.rs

* Address review

* Fix macos build

* host -> wasi

* Partially address review, more to come later.

* Address more review comments

* Fix compilation on Windows
2019-11-07 11:23:52 +01:00
Peter Huene
920728d14d Implement registering JIT unwind information on Windows.
This commit implements registering unwind information for JIT functions on
Windows so that the operating system can both walk and unwind stacks containing
JIT frames.

Currently this only works with Cranelift as lightbeam does not emit unwind
information yet.

This commit also resets the stack guard page on Windows for stack overflow
exceptions, allowing reliable stack overflow traps.

With these changes, all previously disabled test suite tests (not including
the multi-value tests) on Windows are now passing.

Fixes #291.
2019-11-06 20:27:32 -08:00
Peter Huene
9e373d1b6b Merge pull request #500 from sunfishcode/update-faerrie
Update faerie to 0.12 to finish the `target-lexicon` update story.
2019-11-06 18:03:38 -08:00
Dan Gohman
325e973474 Update faerie to 0.12 to finish the target-lexicon update story. 2019-11-06 17:00:00 -08:00
Johnnie Birch
c46d6b7269 Removes build warnings for usused code for lightbeam build (#493) 2019-11-06 16:21:12 -08:00
Peter Huene
ab80785c05 Bump Cranelift to 0.49.0 and target-lexicon to 0.9.0. (#499)
This commit bumps Cranelift to 0.49.0 and target-lexicon to 0.9.0 to fix the
failing build to due an updated faerie crate that violated semver with an
updated 0.9.0 target-lexicon dependency.

Fixes #491.
2019-11-06 15:30:54 -08:00
Andrew Brown
a8afdff972 Add error causes to failed WAST directives (#477) 2019-11-06 13:58:29 -06:00
Marcin Mielniczuk
22494057df Try to somehow implement clock_res_get on Windows. (#124)
* Implement clock_time_get on Windows.

Also update misc_testsuite to include latest clock_time_get test
changes.

* Try to somehow implement clock_res_get on Windows.

* Fix 55ms

* Cache the perf counter resolution

* Fix integration tests
2019-11-06 17:02:58 +01:00
Alex Crichton
10f27197b5 Migrate from Azure Pipelines to Github Actions (#474)
This commit migrates wasmtime's CI infrastructure from Azure Pipelines
to Github Actions. Using Github Actions has a few benefits over other
offerings:

* Being natively integrated with Github means that there's no degree of
  user account configuration or access control management, it's all
  inherent via already existing Github permissions.

* Github Actions gives 20 parallel builders instead of Azure's 10 by
  default, which is a nice boost to have!

Overall I've found Github Actions to feel a bit cleaner than Azure
Pipelines as well. Subjectively I've found the configuration to be more
readable and more pleasant to work with, although they're both just as
"powerful" I think. Additionally Github Actions has been pretty solid in
my own personal testing for a number of other projects.

The main trickiness with wasmtime's CI is the rolling `dev` release of
the master branch as well as binary releases for tags. Github Actions
doesn't have quite as much built in functionality as Azure Pipelines,
but Github Actions does have a nice feature where you can define the
code for an action locally rather than only using built-in actions.

This migration adds three local actions with some associated JS code to
run the action (currently it looks like it basically requires JS)

* An `install-rust` action papers over the gotchas about installing
  Rust, allowing Rust installation to be a one-liner in the configuration.

* A `binary-compatible-builds` action allows easily configuring the
  wheels and the binaries to be "more binary compatible" and handles
  things like compilation flags on OSX and Windows while handling the
  `centos:6` container on Linux.

* The `github-release` action is the logic using the `@actions/github`
  JS package to orchestrate the custom way we manage rolling releases,
  ensuring that a new release is made for the master branch under `dev`
  (deleting the previous tag/release ahead of time) and then also
  manages tagged releases by uploading them there.

I'm hoping that most of the inline actions here will largely go away.
For example `install-rust` should be simply `rustup update $toolchain`
once various environment issues are fixed on Github Actions runner
images. Additionally `github-release` will ideally migrate to something
like https://github.com/actions/create-release or similar once it has
enough functionality. I'm also hoping that the maintenance in the
meantime of these actions is pretty low-cost, but if it becomes an issue
we can look into other solutions!
2019-11-05 17:21:52 -08:00
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