Commit Graph

2269 Commits

Author SHA1 Message Date
Jakub Konka
9182971697 Add missing import to wasmtime-rust macro (#589)
This commit does two things: 1) it fixes `wasmtime_rust::wasmtime` proc macro by
adding the missing import to the `__rt` module, and fixing the scoping inside
the macro itself; and 2) it augments the `wasmtime_rust::wasmtime` proc macro with
custom error messages in case the implementor forgets the `self` argument in the
trait methods.
2019-11-18 10:39:40 -06:00
Dan Gohman
a2479df329 Update the documentation for running the test-programs tests. 2019-11-16 22:31:16 +01:00
Andrew Brown
ea04aa5b98 Improve error messages received from Cranelift (#583)
As discussed in https://github.com/bytecodealliance/cranelift/pull/1226, the context of Cranelift errors is lost after exiting the scope containing the Cranelift function. `CodegenError` then only contains something like `inst2: arg 0 (v4) has type i16x8, expected i8x16`, which is rarely enough information for investigating a codegen failure. This change uses Cranelift's `pretty_error` function to improve the error messages wrapped in `CompileError`; `CompileError` has lost the reference to `CodegenError` due to `pretty_error` taking ownership but this seems preferable since no backtrace is attached and losing the pretty-printed context would be worse (if `CodegenError` gains a `Backtrace` or implements `Clone` we can revisit this).
2019-11-16 11:42:17 -08:00
Dan Gohman
7d47a04277 Remove unneded prefix argument from instantiate_wasi. (#584)
* Remove unneded prefix argument from `instantiate_wasi`.

This was an artifact of an earlier backwards-compatibility mechanism
which is no longer needed.

* Remove unneeded prefix arg from remaning uses
2019-11-16 11:40:14 -08:00
Daniel Bevenius
0753b1206b Use nested paths for use declarations (#576)
* Use nested paths for use declarations

This commit uses nested paths for cranelift_codegen and some of the
standard library use declarations.

The main motivation for this is that it seems to be consistent with
other use declarations in this file, and saves a few lines.

* squash: fix rustfmt issues
2019-11-16 10:26:45 -08:00
Yury Delendik
ea56118651 Add/use create_wasi_instance() instead of instantiate_wasi(). (#571)
* Add/use create_wasi_instance() instead of instantiate_wasi().

* rm Result from Instance::from_handle
2019-11-15 16:48:05 -08:00
Jakub Konka
9896a5cabd Add test for dangling file/dir handles (#566)
* Add test for dangling file/dir handles

This commit adds a test for dangling file/dir handles. The logic is
quite simple: we first create a resource (file or dir), get a WASI file
descriptor to it, remove the resource without closing the FD, and then
try to re-create it.

* Disable on Windows for now
2019-11-15 23:28:50 +01:00
Jakub Konka
5edbd9b967 Test path_open O_EXCL behaviour 2019-11-15 23:18:52 +01:00
Dan Gohman
c5f998add2 Update the crates.io publishing scripts (#580)
* Fix fuzz target compilation.

* Bump version to 0.7.0

* Temporarily disable fuzz tests

Temporarily disable fuzz tests until https://github.com/bytecodealliance/cranelift/issues/1216 is resolved.

* Fix publish-all.sh to not modify the witx crate.

* Remove the "publish = false" attribute from Lightbeam.

* Add a README.md for wasmtime-interface-types.

* Remove the "rust" category.

This fixes the following warning:

warning: the following are not valid category slugs and were ignored: rust. Please see https://crates.io/category_slugs for the list of all category slugs.

* Mark wasmtime-cli as "publish = false".

* Sort the publishing rules in topological order.

Also, publish nightly-only crates with cargo +nightly.
2019-11-15 12:17:19 -08:00
Jakub Konka
3d5b55c095 Fix rights check for fd_pread and fd_pwrite
This commit fixes rights check for `fd_pread` and `fd_pwrite` to be
conformant with the WASI spec. In the spec, it is clearly stated that
the right to invoke `__wasi_fd_pread()` requires a combination of
`__WASI_RIGHT_FD_READ` with `__WASI_RIGHT_FD_SEEK`, and similarly for
`__wasi_fd_pwrite()` the combination is `__WASI_RIGHT_FD_WRITE` with
`__WASI_RIGHT_FD_SEEK`. Relevant link to the spec: [__wasi_rights_t].

[__wasi_rights_t]: https://github.com/WebAssembly/WASI/blob/master/phases/snapshot/docs/wasi_unstable_preview1.md#__wasi_rights_t-uint64_t-bitfield
2019-11-15 20:59:54 +01:00
Dan Gohman
d4fd229e5e Reorganize wasi-misc-tests. (#575)
* Reorganize wasi-misc-tests.

Move wasi-misc-tests out of wasi-common, to break a dependency cycle;
previously, wasmtime-* depended on wasi-common, but wasi-common
dev-dependended on wasmtime-*.

Now, wasi-common no longer dev-depends on wasmtime-*; instead, the
tests are in their own crate which depends on wasi-common and on
wasmtime-*.

Also, rename wasi-misc-tests to wasi-tests for simplicity.

This also removes the "wasm_tests" feature; it's replaced by the
"test-programs" feature.

* Update the CI script to use the new feature name.

* Update the CI script to use the new feature name in one more place.

* Change a `write!` to a `writeln!`.
2019-11-15 08:03:43 -08:00
Ben Brittain
b0f558aa10 Mark functions as pub if trait is public (#574) 2019-11-14 19:20:45 -06:00
Yury Delendik
36cb806c54 Use embedding api in python extension (#569)
Now embedding API is used in the Python extension, this allows us to remove ModuleData::invoke() from wasmtime-interface-types
2019-11-14 10:40:04 -06:00
Daniel Bevenius
a495418210 Correct minor typo in wasmtime.rs doc comment (#568) 2019-11-14 09:06:30 -06:00
Daniel Bevenius
1ac86c9451 Fix links in CONTRIBUTING.md (#565) 2019-11-14 15:57:56 +01:00
Alex Crichton
399295a708 Remove all checked in *.wasm files to the repo (#563)
* Tidy up the `hello` example for `wasmtime`

* Remove the `*.wat` and `*.wasm` files and instead just inline the
  `*.wat` into the example.

* Touch up comments so they're not just a repeat of the `println!`
  below.

* Move `*.wat` for `memory` example inline

No need to handle auxiliary files with the ability to parse it inline!

* Move `multi.wasm` inline into `multi.rs` example

* Move `*.wasm` for gcd example inline

* Move `*.wat` inline with `import_calling_export` test

* Remove checked in `lightbeam/test.wasm`

Instead move the `*.wat` into the source and parse it into wasm there.

* Run rustfmt
2019-11-13 13:00:06 -06:00
Nick Fitzgerald
5ca38bdd4a Merge pull request #562 from alexcrichton/less-public-api-dependencies
Reduce number of crates needed for `Config` usage
2019-11-13 10:02:51 -08:00
Nick Fitzgerald
f234f1126d Merge pull request #561 from alexcrichton/improper-ctypes-nightly-warnings
Squash improper_ctypes warnings on nightly
2019-11-13 08:57:51 -08:00
Alex Crichton
fb60a21930 Reduce number of crates needed for Config usage
This commit is an attempt to reduce the number of crates necessary to
link to when using `wasmtime::Config` in "default mode" or with only one
or two tweaks. The change moves to a builder-style pattern for `Config`
to only require importing crates as necessary if you configure a
particular setting. This then also propagates that change to `Context`
as well by taking a `Config` instead of requiring that all arguments are
passed alone.
2019-11-13 08:32:13 -08:00
Alex Crichton
8b0cfd9245 Squash improper_ctypes warnings on nightly
Lots more warnings are showing up on nightly compilers due to a recent
change. I've opened rust-lang/rust#66373 on the compiler side for this
as well.
2019-11-13 08:05:55 -08:00
Yury Delendik
98266498af Use embedded API in the wasmtime-rust (#540) 2019-11-13 09:15:37 -06:00
Jakub Konka
2737c5e8e5 Enable WASI tests on Windows (#560)
For some weird reason (probably when migrating the codebase from
`wasi-common` repo to `wasmtime`), these did not get enabled for the
Windows platform.
2019-11-13 09:06:09 -06:00
Jakub Konka
23e8bd8d66 Add test case for path_link syscall (#559)
This commit adds a relatively complete test case for the `path_link`
syscall. This commit should serve as some prep work for implementing
`path_link` on Windows (which will follow in a subsequent PR).
2019-11-13 09:05:17 -06:00
Shawn Tabrizi
c319ebf21b Update lightbeam link (#558) 2019-11-13 14:10:30 +01:00
Alex Crichton
622285790c Fix a few more URLs after project relocation (#555) 2019-11-12 16:11:47 -08:00
Daniel Salvadori
038a387471 Fix typo (#553) 2019-11-12 12:12:43 -08:00
Dan Gohman
c78196bd01 Update repository URLs for the Bytecode Alliance. (#550) 2019-11-12 09:18:59 -08:00
Till Schneidereit
46721f3f92 Make it a Bytecode Alliance project (#549) 2019-11-12 07:51:26 -08:00
Jakub Konka
093629f7eb Refactor common clockid conversion on *nix (#548) 2019-11-12 09:22:19 -06:00
Nick Fitzgerald
79864d0db7 Merge pull request #542 from alexcrichton/doc-rust
Fill out book chapter on writing WebAssembly with Rust
2019-11-11 16:31:59 -08:00
Nick Fitzgerald
ca04e33771 Merge pull request #467 from fitzgen/update-cranelift-for-full-multi-value
Update cranelift for full multi-value
2019-11-11 16:17:54 -08:00
Nick Fitzgerald
01ab20e372 Bump cranelift deps to 0.50.0 2019-11-11 15:52:49 -08:00
Nick Fitzgerald
4c4699a226 Test the multi-value example on windows 2019-11-11 15:39:48 -08:00
Nick Fitzgerald
a29303dedd Expand the muli-value example for wasmtime-api to use many return values
This should exercise the Rust-calling-Wasm code path for when there are more
return values than fit into return registers.
2019-11-11 15:39:48 -08:00
Nick Fitzgerald
b3b7ce4f6b Enable all Wasm multi-value proposal tests! 2019-11-11 15:39:48 -08:00
Alex Crichton
cd8cc4d375 Enable multi-value in the Python extension (#541)
This commit enables the multi-value features in the Python extension
to be usable by-default with interface types. Additionally this removes
some code which panics on multi-value but doesn't end up getting used
today.
2019-11-11 17:19:33 -06:00
Alex Crichton
1530f2e1c6 Fill out book chapter on writing WebAssembly with Rust
* Cover `cargo wasi`
* Cover a "Hello, world!" binary
* Cover a "Hello, world!" library
* Cover a more advanced example with WebAssembly interface types
* Importing/exporting functionality basics
2019-11-11 15:09:36 -08:00
Alex Crichton
d9edb95218 Allow using WASI APIs in the Python extension (#533)
* Allow using WASI APIs in the Python extension

This commit adds support to the Python extension to load the WASI
implementation when a WASI module is seen allowing Python to load
WebAssembly modules that use WASI. This is pretty primitive right now
because there's no way to configure the environment/args/preopens/etc,
but it's hoped to be at least a start!

* rustfmt

* Refactor checks for the wasi module name

* Move the check into `wasmtime-wasi` itself
* Make it conservative for now and match anything that says `wasi*`
* Leave a `FIXME` for improving this later on

* Enable missing feature of winapi for `winx`
2019-11-11 11:09:45 -08:00
Jakub Konka
0006a2af95 Dynamically load utimensat if exists on the host (#535)
* Dynamically load utimensat if exists on the host

This commit introduces a change to file time management for *nix based
hosts in that it firstly tries to load `utimensat` symbol, and if it
doesn't exist, then falls back to `utimes` instead. This change is
borrowing very heavily from [filetime] crate, however, it introduces a
couple of helpers and methods specific to WASI use case (or more
generally, to a use case which requires modifying times of entities
specified by a pair `(DirFD, RelativePath)` rather than the typical
file time specification based only absolute path or raw file descriptor
as is the case with [filetime] crate. The trick here is, that on kernels
which do not have `utimensat` symbol, this implementation emulates this
behaviour by a combination of `openat` and `utimes`.

This commit also is meant to address #516.

[filetime]: https://github.com/alexcrichton/filetime

* Fix symlink NOFOLLOW flag setting

* Add docs and specify UTIME_NOW/OMIT on Linux

Previously, we relied on [libc] crate for `UTIME_NOW` and `UTIME_OMIT`
constants on Linux. However, following the convention assumed in
[filetime] crate, this is now changed to directly specified by us
in our crate.

[libc]: https://github.com/rust-lang/libc
[filetime]: https://github.com/alexcrichton/filetime

* Refactor UTIME_NOW/OMIT for BSD

* Address final discussion points
2019-11-11 11:42:28 -06:00
whitequark
5a1845b4ca Add missing x86_64 registers to debug info transformer. (#538) 2019-11-11 08:05:52 -06:00
Marcin Mielniczuk
3206461502 Fix some clippy warnings (#536) 2019-11-10 13:50:19 -08:00
Dan Gohman
ef1cbfdaa8 Merge pull request #534 from sunfishcode/macro_use
Miscellaneous cleanups
2019-11-08 20:42:12 -08:00
Dan Gohman
f5dad66593 Fix a missing use bitflags::bitflags;. 2019-11-08 19:43:17 -08:00
Dan Gohman
061b453255 Remove unneeded extern crate, macro_use, and tidy uses. 2019-11-08 17:55:38 -08:00
Dan Gohman
31f8f124f5 Delete spurious commas. 2019-11-08 17:15:37 -08:00
Dan Gohman
dd27237c74 Avoid capturing a pointer into a temporary CString buffer. 2019-11-08 17:15:37 -08:00
Dan Gohman
5b0031ece8 Use pointer::add instead of pointer::offset with a cast. 2019-11-08 17:15:37 -08:00
Dan Gohman
39b0d670c5 rustfmt and trim trailing whitespace. 2019-11-08 17:15:37 -08:00
Dan Gohman
da89d08fca Update to point to the Wasmtime issue tracker. 2019-11-08 17:15:37 -08:00
Dan Gohman
e8f08193fc Reformat some long lines and macros. 2019-11-08 17:15:37 -08:00