Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge with upstream #40

Merged
merged 11 commits into from
Dec 11, 2023
Merged

Merge with upstream #40

merged 11 commits into from
Dec 11, 2023

Conversation

dhil
Copy link
Member

@dhil dhil commented Dec 11, 2023

No description provided.

alexcrichton and others added 11 commits December 6, 2023 16:35
* Parse and print `//`-style comments as docs

This updates `wit-parser` to account for WebAssembly/component-model#281.
Doc comments are now considered to be all forms of comments and are
collected in the `Docs` structure. The structure already stripped all
leading `/` characters so it works for either `///` or `//`.
Additionally docs are now printed with `//` instead of `///`.

* Update test expectations
…codealliance#1317)

This is useful when doing shared-everything linking and we have a library module
that exports `cabi_realloc`, but not the adapter-specific `cabi_import_realloc`
and `cabi_export_realloc` functions.

For context: this came up while adding Preview 2 support to `wasi-libc` using
bindings generated by `wit-bindgen`, which only exports `cabi_realloc`.  That
works fine if you're statically linking `libc.a` and using `wit-component` the
traditional way, but if you're using `libc.so` and shared-everything linking,
each .so module is treated as an "adapter", which meant `wit-component` was
looking for `cabi_import_realloc` and `cabi_export_realloc`.

Signed-off-by: Joel Dice <[email protected]>
…iance#1320)

This commit updates the `wasm-tools component wit` subcommand to support
wasm inputs which don't necessarily have the `*.wasm` extension (or
`*.wat`). Instead the file contents themselves are always inspected.

Documentation has additionally been updated in a few places to account
for this change.
This commit ensures that if a core wasm binary is fed into the
WIT-decoding process it'll fail quickly with an up-front error message
that it's not a component.
* Update import name validation in `wasmparser`.

This commit updates the import name validation in wasmparser to conform to the
current component-model spec.

It allows for nested namespaces in interface, locked dep, and unlock dep names.

Additionally, locked and unlocked dep names can now contain one or more
projections.

Interface names can now have more than one projection.

A check was added to ensure url and relative-url names don't contain a `<`.

Fixes bytecodealliance#1314.

* Add a feature gate for the extended import names.

This commit adds the `component_model_nested_names` feature which controls
whether or not the validator will except nested namespaces and projections in
import names.

It adds a new test for the extended forms, enabling the feature only for that
test.

* Fix fuzz.
* Allow renaming imports in `ComponentEncoder`.

This commit adds an `import_name_map` option to `ComponentEncoder` to allow
renaming imports in the output component.

Language toolchains can use this option to substitute `unlocked-dep` and
`locked-dep` names in the components they build.

* Add `--import-name` option to `wasm-tools component new`.

This commit adds a `--import-name` option to support renaming import names via
the `wasm-tools component new` command.
…ytecodealliance#1316)

* implement from_reader for ComponentInfo for incremental wit decoding

* preserve wasmparser lifetimes and use from_reader in ComponentInfo::new
)

This commit fixes a bug in `Resolve::merge` which is one of the
workhorses of the `wasm-tools component new` subcommand. Previously it
was assumed that `Resolve::packages` always listed packages in
topological order, but `Resolve::merge` updated the internal state of
`Resolve` to violate this invariant. This happened because new packages
which might be dependencies of existing packages (through newly
discovered interfaces for example) would be appended at the end.

After wrestling with a few options to solve this issue I've settled on
relaxing the invariants of `Resolve` such that it does not always
contain a topologically sorted list of packages. Instead a new method,
`topological_packages`, is explicitly used to order the packages within
`Resolve`. This method is then used as part of `Resolve::merge` which
relies on visiting in a topological order.

For testing this it wasn't previously found via fuzzing because fuzzing
does not execute `Resolve::merge`. Extra validation about
topological-sorted-ness caught the problem in the `merge` tests,
however. The fuzzer for WIT has been updated to test merging and assert
validity now as well too.
* make import_names optional

* Update src/bin/wasm-tools/component.rs

* Update src/bin/wasm-tools/component.rs

---------

Co-authored-by: Peter Huene <[email protected]>
@dhil dhil merged commit 7102709 into wasmfx:main Dec 11, 2023
6 checks passed
@dhil dhil deleted the wasmfx-merge branch December 11, 2023 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants