Skip to content

wasmtime-wiggle: make it possible to add host funcs to a config under an alias - #2761

Merged
alexcrichton merged 2 commits into
mainfrom
pch/wasmtime_wiggle_alias_host_funcs
Mar 25, 2021
Merged

wasmtime-wiggle: make it possible to add host funcs to a config under an alias#2761
alexcrichton merged 2 commits into
mainfrom
pch/wasmtime_wiggle_alias_host_funcs

Conversation

@pchickey

Copy link
Copy Markdown
Contributor

This addition to wasmtime-wiggle makes it possible to add a function to a Config under an arbitrary name.

Embeddings that allow Wasm functions defined by wiggle to be imported under additional names (for example, for legacy compatibility) can do so by writing their own Linker invocation, but functions were added to a Config under only the name specified by the witx file. Now, in addition to the default add_to_config behavior, you can add_<functionname>_to_config(&mut config, module: &str, field: &str) as well.

@pchickey
pchickey requested a review from alexcrichton March 25, 2021 02:01
@github-actions github-actions Bot added the wasi Issues pertaining to WASI label Mar 25, 2021
@github-actions

Copy link
Copy Markdown

Subscribe to Label Action

cc @kubkon

Details This issue or pull request has been labeled: "wasi"

Thus the following users have been cc'd because of the following labels:

  • kubkon: wasi

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

@alexcrichton alexcrichton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would this be something we could perhaps configure at the wiggle-macro-invocation level? It seems like this would add a lot of functions that are rarely used, which isn't necessarily a bad thing just wondering if we could move this to compile time instead of runtime.

Comment thread crates/wiggle/wasmtime/macro/src/lib.rs Outdated
@pchickey

Copy link
Copy Markdown
Contributor Author

Yeah, we could do this at compile time instead of at run-time. This does add a lot of API surface but effectively its just out-lining the functionality that is already there for add_to_config, which is implemented in terms of these new functions.

I'd like to defer adding compile-time config for this for a little bit. It is an optimization, but for code should get called once per engine creation. I expect plenty more structural changes to wiggle coming down the pipe as witx and friends evolve, so I don't want to add more complexity to the macro right now if we don't have to.

@alexcrichton

Copy link
Copy Markdown
Member

Ok sounds reasonable!

@alexcrichton
alexcrichton merged commit 8bb1f8a into main Mar 25, 2021
@alexcrichton
alexcrichton deleted the pch/wasmtime_wiggle_alias_host_funcs branch March 25, 2021 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wasi Issues pertaining to WASI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants