Commit Graph

28 Commits

Author SHA1 Message Date
Pat Hickey
19e2a46aaf bump to latest wasi submodule
witx is now 0.8.6.
2020-08-17 15:58:56 -07:00
Pat Hickey
3bf8c20665 rustfmt.... idk why my editor missed this one 2020-08-04 18:41:06 -07:00
Jakub Konka
5d8271286a Check if named type requires a lifetime and conform if does 2020-08-04 10:53:01 -07:00
Alex Crichton
63d5b91930 Wasmtime 0.19.0 and Cranelift 0.66.0 (#2027)
This commit updates Wasmtime's version to 0.19.0, Cranelift's version to
0.66.0, and updates the release notes as well.
2020-07-16 12:46:21 -05:00
Dan Gohman
caa87048ab Wasmtime 0.18.0 and Cranelift 0.65.0. 2020-06-11 17:49:56 -07:00
Pat Hickey
220733b974 wiggle-generate: add an empty constructor to ErrorTransform
some library users (me, in lucet-wasi) may not care about ErrorTransform YET
2020-06-03 10:54:34 -07:00
Pat Hickey
02c0c68ed2 replace all uses of log with tracing 2020-06-03 10:53:55 -07:00
Pat Hickey
f89fc0ac57 wiggle: can swap in tracing for args 2020-06-03 10:53:32 -07:00
Pat Hickey
994104d615 wiggle: add config options for logging 2020-06-03 10:53:32 -07:00
Dan Gohman
a76639c6fb Wasmtime 0.17.0 and Cranelift 0.64.0. (#1805) 2020-06-02 18:51:59 -07:00
Pat Hickey
1d2a1c4744 Merge remote-tracking branch 'origin/master' into pch/wiggle_error_transforms 2020-05-30 13:20:30 -07:00
Pat Hickey
614723ab7e Update crates/wiggle/generate/src/names.rs 2020-05-30 13:10:47 -07:00
Katelyn Martin
ae9af212ff wiggle: escape rust keywords, allow witx literals
# Overview

This commit makes changes to the `wiggle::from_witx` procedural in order
to allow for escaping strict and reserved Rust keywords.

Additionally, this commit introduces the ability to use a `witx_literal`
field in the `{..}` object provided as an argument to
`wiggle::from_witx`. This field allows for witx documents to be provided
as inline string literals.

Documentation comments are added to the methods of
`wiggle_generate::names::Names` struct responsible for generating
`proc_macro2::Ident` words.

 ## Keyword Escaping

Today, an interface that includes witx identifiers that conflict with
with Rust syntax will cause the `from_witx` macro to panic at
compilation time.

Here is a small example (adapted from
`/crates/wiggle/tests/keywords.rs`) that demonstrates this issue:

```
;; Attempts to define a module `self`, containing a trait `Self`. Both
;; of these are reserved keywords, and will thus cause a compilation
;; error.
(module $self
    (@interface func (export "betchya_cant_implement_this")
    )
)
```

Building off of code that (as of `master` today)
[demonstrates a strategy][esc] for escaping keywords, we introduce an
internal `escaping` module to `generate/src/config.rs` that contains
code responsible for escaping Rust keywords in a generalized manner.

[esc]: 0dd77d36f8/crates/wiggle/generate/src/names.rs (L106)

Some code related to special cases, such as accounting for
[`errno::2big`][err] while generating names for enum variants, is moved
into this module as well.

[err]: https://github.com/WebAssembly/WASI/blob/master/phases/snapshot/docs.md#-errno-enumu16

As mentioned in the document comments of this diff, we do not include
weak keywords like `'static` or `union`. Their semantics do not impact
us in the same way from a code generation perspective.

 ## witx_literal

First, some background. Trait names, type names, and so on use a
camel-cased naming convention.  As such, `Self` is the only keyword that
can potentially conflict with these identifiers. (See the [Rust
Reference][key] for a complete list of strict, reserved, and weak
keywords.)

When writing tests, this meant that many tests had to be outlined into
separate files, as items with the name `$self` could not be defined in
the same namespace. As such, it seemed like a worthwhile feature to
implement while the above work was being developed.

The most important function to note is the `load_document` inherent
method added to `WitxConf`, and that `WitxConf` is now an enum
containing either (a) a collection of paths, identical to its current
functionality, or (b) a single string literal.

Note that a witx document given to `from_witx` using a string literal
provided to `from_witx` cannot include `use (..)` directives, per
the `witx::parse` documentation.
(See: https://docs.rs/witx/0.8.5/witx/fn.parse.html)

Two newtypes, `Paths` and `Literal`, are introduced to facilitate the
parsing of `WitxConf` values. Their public API and trait implementations
has been kept to the minimum required to satisfy compilation in order to
limit the scope of this diff. Additional surface for external consumers
can be added in follow-up commits if deemed necessary in review.
2020-05-30 02:02:38 -04:00
Pat Hickey
9038f91696 wiggle: allow user-configurable error transformations 2020-05-29 12:55:57 -07:00
Pat Hickey
96d6884d33 wiggle: get BorrowChecker from GuestMemory method 2020-05-21 12:37:14 -07:00
Pat Hickey
52e8300f01 wiggle: automate borrow checking, explicitly passing borrow checker throughout 2020-05-20 12:51:28 -07:00
Dan Gohman
864cf98c8d Update release notes, wasmtime 0.16, cranelift 0.63. 2020-04-29 17:30:25 -07:00
Pat Hickey
25cbd8b591 wiggle-generate: paramaterize library on module path to runtime (#1574)
* wiggle-generate: paramaterize library on module path to runtime

This change makes no functional difference to users who only use the
wiggle crate.

Add a parameter to the `Names` constructor that determines the module
that runtime components (e.g. GuestPtr, GuestError etc) of wiggle come
from. For `wiggle` users this is just `quote!(wiggle)`, but other
libraries which consume wiggle-generate may wrap and re-export wiggle
under some other path, and not want their consumers to have to know
about the wiggle dependency, e.g. `quote!(my_crate::some_path::wiggle)`.

* wiggle-generate,macro: move more logic into macro

better for code reuse elsewhere
2020-04-22 09:16:21 -05:00
Pat Hickey
71923c805a Merge pull request #1470 from bytecodealliance/pch/wiggle_error_model
Wiggle: changes to traits used for error conversion and reporting
2020-04-06 19:46:00 -07:00
Pat Hickey
415b19f2d1 bump witx dep to 0.8.5 2020-04-06 13:41:03 -07:00
Pat Hickey
c2cb4ea3ff Wiggle: tweaks to internal interfaces (#1469)
* [wiggle]: wiggle-generate internal interface for Names simplified

im using it in other libraries where I don't want to construct a
wiggle_generate::Config just to use the ctx_type out of it.

* wiggle: define_func can get trait name as argument

this flexibility needed for some customization over in lucet
2020-04-06 09:51:17 -05:00
Pat Hickey
3e97e5f1ae wiggle: revamp error type conversions 2020-04-03 15:27:27 -07:00
Pat Hickey
167a040ea5 GuestErrorType only needs to have a success constructor 2020-04-03 15:26:15 -07:00
Dan Gohman
fde5ddf159 Fixes for 0.15 (#1449)
* Wasmtime 0.15.0 and Cranelift 0.62.0. (#1398)

* Bump more ad-hoc versions.

* Add build.rs to wasi-common's Cargo.toml.

* Update the env var name in more places.

* Remove a redundant echo.
2020-04-03 13:13:37 -07:00
Alex Crichton
968cd76163 Move back to only one WASI submodule (#1434)
* Move back to only one WASI submodule

This commit fixes the issue where we have two WASI submodules for build
reasons in this repository. The fix was to place the submodule in the
`wasi-common` crate, and then anyone using the `wig` crate has to be
sure to define a `WASI_ROOT` env var in a build script to be able to
parse witx files.

With all that in place `wasi-common` becomes the source of truth for the
witx files we're parsing, and crates like `wasmtime-wasi` use
build-scripts shenanigans to read the same witx files. This should
hopefully get us so we're compatible with publishing and still only have
one submodule!

* rustfmt
2020-03-30 14:45:23 -05:00
Jakub Konka
78772cf5e1 Generate trace logs in wiggle albeit behind a feature gate
This commit augments `wiggle` with trace log generation for the shims,
returned errno values, and returned values proper (if any, i.e.,
different than unit type `()`). What that means is that every syscall
will have auto-generated up to 3 traces, for instance,

```
 TRACE wasi_common::wasi::wasi_snapshot_preview1 > fd_prestat_get(fd=Fd(3))
 TRACE wasi_common::wasi::wasi_snapshot_preview1 >      | result=(buf=Dir(PrestatDir { pr_name_len: 1 }))
 TRACE wasi_common::wasi::wasi_snapshot_preview1 >      | errno=No error occurred. System call completed successfully. (Errno::Success(0))
```

Putting logging behind a feature gate in this case means that the log calls
are generated by the `wiggle` crate regardless if the client requested
the feature or not, however, then their usage in the client lib is
dictated by the presence of the feature flag. So, for instance, `wasi-common`
has this feature enabled by default, while any other client lib
using `wiggle` if they don't want tracing enabled, they will just
leave the feature off. I'm not sure if this is what we wanted
but seemed easiest to implement quickly. Lemme y'all know your thoughts
about this!
2020-03-30 19:58:15 +02:00
Dan Gohman
092538cc54 Test 0.14 (#1417)
* Bump Wasmtime to 0.14.0.

* Update the publish script for the wiggle crate wiggle.

* More fixes.

* Fix lightbeam depenency version.

* cargo update

* Cargo update wasi-tests too.

And add cargo update to the version-bump scripts.
2020-03-26 21:53:42 -07:00
Alex Crichton
a628dc315e Shuffle around the wiggle crates (#1414)
* Shuffle around the wiggle crates

This commit reorganizes the wiggle crates slightly by performing the
following transforms:

* The `crates/wiggle` crate, previously named `wiggle`, was moved to
  `crates/wiggle/crates/macro` and is renamed to `wiggle-macro`.

* The `crates/wiggle/crates/runtime` crate, previously named
  `wiggle-runtime`, was moved to `crates/wiggle` and is renamed to
  `wiggle`.

* The new `wiggle` crate depends on `wiggle-macro` and reexports the macro.

The goal here is that consumers only deal with the `wiggle` crate
itself. No more crates depend on `wiggle-runtime` and all dependencies
are entirely on just the `wiggle` crate.

* Remove the `crates/wiggle/crates` directory

Move everything into `crates/wiggle` directly, like `wasi-common`

* Add wiggle-macro to test-all script

* Fixup a test
2020-03-26 18:34:50 -05:00