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

Implement Component::define_unknown_imports_as_traps #8672

Merged
merged 3 commits into from
May 21, 2024

Conversation

rylev
Copy link
Contributor

@rylev rylev commented May 21, 2024

Fixes #8645

This will search through a components imports, find any imports
that have not yet been defined in the linker and add a definition
which will trap upon being called.
@rylev rylev requested a review from a team as a code owner May 21, 2024 14:10
@rylev rylev requested review from fitzgen and removed request for a team May 21, 2024 14:10
Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Could this be written with a recursive helper that operates on a &ComponentType (or similar) and a LinkerInstance? That'll help remove some minor duplication here and additionally handle the fully general case of all component imports.

Additionally could this return an error for unsupported imports? For example this can't fill in the import of a component or import of a module at this time so I think those should return an error rather than being silently ignored.

And finally, mind adding a test or two for this?

@github-actions github-actions bot added the wasmtime:api Related to the API of the `wasmtime` crate itself label May 21, 2024
rylev added 2 commits May 21, 2024 20:46
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
@rylev rylev requested a review from alexcrichton May 21, 2024 18:50
@alexcrichton alexcrichton enabled auto-merge May 21, 2024 18:57
@alexcrichton alexcrichton added this pull request to the merge queue May 21, 2024
Merged via the queue into bytecodealliance:main with commit 8bde231 May 21, 2024
35 checks passed
@rylev rylev deleted the defined-unknonw branch May 22, 2024 08:21
alexcrichton added a commit to alexcrichton/wasmtime that referenced this pull request Jul 26, 2024
This was implemented in bytecodealliance#8672 and is an easy addition to the CLI.

Closes bytecodealliance#9019
github-merge-queue bot pushed a commit that referenced this pull request Jul 26, 2024
* Add support for `-Wunknown-imports-trap` to components

This was implemented in #8672 and is an easy addition to the CLI.

Closes #9019

* Fix non-component CLI build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wasmtime:api Related to the API of the `wasmtime` crate itself
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Give wasmtime::component::Linker ability to stub out implementations
2 participants