Commit Graph

2269 Commits

Author SHA1 Message Date
Jakub Konka
cf0bef84cc Fix filestat_from_nix conversion fn 2019-08-20 23:38:53 -07:00
Dan Gohman
8ea883a603 Workaround a rounding difference in the strtof function in Centos 6. (#290)
* 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.
2019-08-20 23:29:19 -07:00
Dan Gohman
b2b2612305 Topologically sort package ordering in publish-all.sh. 2019-08-20 23:28:54 -07:00
Dan Gohman
2c4118a694 Update for Cranelift 0.40 API changes. 2019-08-20 23:28:54 -07:00
Dan Gohman
d4f27dcc91 Update Cargo.toml metadata for publishing. 2019-08-20 23:28:54 -07:00
Dan Gohman
f37b672c8d Update the pinned wasmtime revision.
This resynchronizes the versions of cranelift used in wasi-common
and wasmtime to 0.40.
2019-08-21 07:46:18 +02:00
Dan Gohman
6921782fbf Add license declarations to headers. 2019-08-20 16:17:36 -07:00
Dan Gohman
500bf83082 Update to latest cranelift and target-lexicon. 2019-08-20 16:17:36 -07:00
Dan Gohman
44367ba99a Bump version to 0.2.0 2019-08-20 16:07:57 -07:00
Yury Delendik
b4a505d5d3 Generate simulated DWARF for rest of the functions 2019-08-20 14:24:13 -07:00
Marcin Mielniczuk
065fbea252 Implement path_filestat_set_times using nix instead of libc.
As advised in #16.
2019-08-20 17:28:25 +02:00
Dan Gohman
4937dd0632 Fix the name of the wast command in its usage string. 2019-08-19 16:58:33 -07:00
Artur Jamro
c3215f4f1b Tests for cache system 2019-08-19 16:56:29 -07:00
Dan Gohman
697fa59b55 Remove broken links in README.md. 2019-08-19 12:53:31 -07:00
Artur Jamro
3c33fe63a1 Add command line option for custom cache directory 2019-08-19 11:29:52 -07:00
dependabot-preview[bot]
7dc81cbbc0 Update wabt requirement from 0.8 to 0.9
Updates the requirements on [wabt](https://github.com/pepyakin/wabt-rs) to permit the latest version.
- [Release notes](https://github.com/pepyakin/wabt-rs/releases)
- [Commits](https://github.com/pepyakin/wabt-rs/compare/0.8.0...0.9.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-08-19 11:23:49 -07:00
Alex Crichton
d1b1500d19 Add an example #[wasmtime] Rust macro (#283)
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!
2019-08-19 19:45:42 +02:00
Dan Gohman
54dd085e27 Add a default-run, so that "cargo run" doesn't need a --bin option.
default-run is a new feature in Rust 1.37.
2019-08-19 05:55:27 -07:00
Alex Crichton
af2b4e4946 Add initial support for WebAssembly Interface Types (#282)
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>
2019-08-19 13:32:13 +02:00
Artur Jamro
7009c8dd73 Add dyn to traits and bump Rust version 2019-08-16 13:46:09 -07:00
Till Schneidereit
9a57580258 Rename release bundle for mac to replace 'apple' with 'macos' (#281) 2019-08-16 18:03:36 +02:00
Jakub Konka
a38af109b3 Fix linter warnings 2019-08-14 12:59:00 +02:00
Dan Gohman
05852977ac Use char/byte literals instead of single-char/byte string literals. 2019-08-14 12:59:00 +02:00
Dan Gohman
2809be666a Minor simplifications to get_path_by_handle. 2019-08-14 12:59:00 +02:00
Dan Gohman
8b576779f2 Use fs::read instead of doing it manually. 2019-08-14 12:59:00 +02:00
Jakub Konka
b14570e887 Move checks into error handling of std::fs::rename (where possible) 2019-08-14 12:10:34 +02:00
Jakub Konka
1b7d9bed2b Implement path_rename on Windows 2019-08-14 12:10:34 +02:00
Jakub Konka
b980c2aa11 Disable path_rename testcase on Windows 2019-08-14 11:56:04 +02:00
Jakub Konka
b1e29869fd Add testcase for path_rename 2019-08-14 11:56:04 +02:00
Alex Crichton
5fe550f533 Conform to Cargo's conventional file layout
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.
2019-08-13 12:51:51 -07:00
Jakub Konka
5c7373959c Fix linter warnings 2019-08-13 21:34:35 +02:00
Marcin Mielniczuk
550cfb90e7 Bump filetime to 0.2.7 2019-08-13 21:34:35 +02:00
Marcin Mielniczuk
74d1c11fbe Fix fd_filestat_set_times and enable the fd_filestat_set test on Windows. 2019-08-13 21:34:35 +02:00
Marcin Mielniczuk
2f1afc4846 Implement fd_filestat_set_times using the filetime crate. 2019-08-13 21:34:35 +02:00
dependabot-preview[bot]
e7fd72bd5c Update hashbrown requirement from 0.5.0 to 0.6.0 (#274)
Updates the requirements on [hashbrown](https://github.com/rust-lang/hashbrown) to permit the latest version.
- [Release notes](https://github.com/rust-lang/hashbrown/releases)
- [Changelog](https://github.com/rust-lang/hashbrown/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/hashbrown/compare/v0.5.0...v0.6.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-08-13 06:44:30 -07:00
Jakub Konka
46c41abd60 Update tests for pread_pwrite and seek_tell 2019-08-12 11:23:28 +02:00
Jakub Konka
aac7fa766d Add testcase for unbuffered fd_write 2019-08-12 10:44:48 +02:00
Alex Crichton
47eee434d4 Build Linux binary in an older docker container (#268)
Currently our Linux binaries aren't quite as portable as they otherwise could
be. There's two primary reasons for this, and one of them is that the binary is
produced in a relatively recent Linux distribution (Ubuntu 16.04) which means
it has a relatively recent requirement in terms of glibc versions. On
OSX/Windows we can set some flags to rely on older libc implementations, but on
Linux we have to actually build against an older version.

This commit switches the container for the build to CentOS 6 instead of the
default Ubuntu 16.04. The main trick here is also finding a C++11-capable
compiler to compile wabt. Turns out though there's a helpful tutorial for this
at https://edwards.sdsu.edu/research/c11-on-centos-6/ and it was as easy as
installing a few packages.

The second portability concern of our Linux binaries is that they link
dynamically to `libstdc++.so` which isn't always installed on target systems,
or even if it is it may be too old or have a different ABI. This is solved by
statically linking to `libstdc++.a` in the build on Azure by doing a bit of
trickery with libraries and what's available.

After these results the glibc requirements drops from 2.18 (released in 2013)
to 2.6 (released in 2007) and avoids the need for users to have libstdc++.so
installed. We may eventually want to investigate fully-static musl binaries,
but finding a musl compiler for C++ is something I'm not that good at, so I
figure this is probably good enough for now.
2019-08-10 01:07:16 +02:00
Marcin Mielniczuk
b9834e3016 Disable the test on Windows, because it depends on fd_filestat_set_times, which is not implemented yet 2019-08-09 22:20:20 +02:00
Marcin Mielniczuk
a52eb205a4 Add a testcase for fd_filestat_set_*
This PR matches https://github.com/CraneStation/wasi-misc-tests/pull/14.
The file was created using `cargo build --release --target=wasm32-wasi`
2019-08-09 22:20:20 +02:00
Alex Crichton
3039caf65c Delete Travis/AppVeyor configurations (#266)
Now that this repo has migrated to Azure Pipelines they shouldn't be
necessary any more!
2019-08-09 17:43:03 +02:00
Alex Crichton
6def6de5e0 Remove the LLVM/bindgen/cmake dependencies from wasmtime-runtime (#253)
* 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
2019-08-09 10:11:13 +02:00
Yury Delendik
4f04d7d873 Transform ranges and simple expressions (#63) 2019-08-08 20:44:45 -07:00
Dan Gohman
36b4ff8031 Say "memory" instead of "__wasi_memory" in error messages.
While the "__wasi_memory" name is something we considered, the name
currently being used for the memory exported to WASI is "memory", so
adjust the error message accordingly.
2019-08-08 21:17:59 +02:00
Marcin Mielniczuk
4c9be5909a Add an overflow check
The check will be removed when rust-lang/rust#63326 is fixed
2019-08-08 18:41:41 +02:00
Marcin Mielniczuk
e731965fbb Implement fd_filestat_set_size using libstd 2019-08-08 18:41:41 +02:00
Marcin Mielniczuk
92c2b563fc Reuse errno_from_ioerror to simplify error handling 2019-08-08 18:22:58 +02:00
Jakub Konka
e18175c556 path_get refactor and implementation of missing path_ hostcalls on Windows (#41)
* Move path_get outside of sys module

* Add implementation of readlinkat

* Clean up path_open; use OpenOptions as much as possible

* Enable close_preopen test

* Implement path_create_directory; fix path_open

* Refactor path concatenation onto a descriptor

* Implement path_remove_directory

* Implement path_unlink_file

* Rewrite path_open using specific access mask

* Fix error mapping when unlinking file

* Fix readlinkat to pass nofollow_errors testcase

* Clean up winerror to WASI conversion

* Spoof creating dangling symlinks on windows (hacky!)

* Add positive testcase for readlink

* Implement path_readlink (for nonzero buffers for now)

* Clean up

* Add Symlink struct immitating *nix symlink

* Fix path_readlink

* Augment interesting_paths testcase with trailing slashes example

* Encapsulate path_get return value as PathGet struct

* Remove dangling symlink emulation

* Extract dangling symlinks into its own testcase

This way, we can re-enable nofollow_errors testcase
on Windows also.

* Return __WASI_ENOTCAPABLE if user lacks perms to symlink
2019-08-08 17:06:01 +02:00
Till Schneidereit
1491f31531 Don't publish the Windows installer's wixpdb file (#263)
This file is only useful for debugging the installer itself, which our users really shouldn't need to do.
2019-08-08 13:29:34 +02:00
Jakub Konka
085d700cdc Bump wasi-common rev 2019-08-08 11:06:27 +02:00