badeend opened PR #9381 from badeend:unstable-features to bytecodealliance:main:
For extra context, see: https://github.com/bytecodealliance/wasmtime/pull/9276
This PR adds the ability to enable/disable WIT APIs gated by
@unstable(feature = ...)at link-time.Previously, unstable features could only be controlled at compile-time through the
featuresoption ofwasmtime::component::bindgen!. That option has been removed. Bindings for unstable APIs are now generated unconditionally. Instead, the generatedadd_to_linker***functions take an additionalLinkOptionsparameter if the world/interface has any unstable features. The availability of unstable features is now controlled through that.The component bindgen generates a fresh
LinkOptionstype for eachinterfacethat needs it and a singleLinkOptionstype for the entire world, which is a union of all the interface's types. An example is included in the component-macro tests:unstable-features.witproduces:
https://github.com/badeend/wasmtime/compare/245dcab34c2fcae69e0f6c3f2daa15837ea6ff61..4fcfe6f866f36ed663f24199e1744bed3cf0bc2c#diff-ad635965474c257cbafce510463aaf52c1ac813f22168045ae22546d3b3ebfc6
A happy coincidence is that WASI-0.2.1 already includes a tiny but practical first use case:
exit-with-code.
I've implemented that function and is gated behind the-Scli-exit-with-codeCLI flag.@sunfishcode, if I interpret https://github.com/WebAssembly/wasi-cli/issues/11 correctly, you were OK with removing the Windows-specific restriction, right? See: https://github.com/badeend/wasmtime/commit/2f48c77867d0bd02c4c910510f491a71da22a0f0
badeend requested wasmtime-core-reviewers for a review on PR #9381.
badeend requested fitzgen for a review on PR #9381.
badeend updated PR #9381.
badeend edited PR #9381:
For extra context, see: https://github.com/bytecodealliance/wasmtime/pull/9276
This PR adds the ability to enable/disable WIT APIs gated by
@unstable(feature = ...)at link-time.Previously, unstable features could only be controlled at compile-time through the
featuresoption ofwasmtime::component::bindgen!. That option has been removed. Bindings for unstable APIs are now generated unconditionally. Instead, the generatedadd_to_linker***functions take an additionalLinkOptionsparameter if the world/interface has any unstable features. The availability of unstable features is now controlled through that.The component bindgen generates a fresh
LinkOptionstype for eachinterfacethat needs it and a singleLinkOptionstype for the entire world, which is a union of all the options contained in that world. An example is included in the component-macro tests:unstable-features.witproduces:
https://github.com/badeend/wasmtime/compare/245dcab34c2fcae69e0f6c3f2daa15837ea6ff61..4fcfe6f866f36ed663f24199e1744bed3cf0bc2c#diff-ad635965474c257cbafce510463aaf52c1ac813f22168045ae22546d3b3ebfc6
A happy coincidence is that WASI-0.2.1 already includes a tiny but practical first use case:
exit-with-code.
I've implemented that function and is gated behind the-Scli-exit-with-codeCLI flag.@sunfishcode, if I interpret https://github.com/WebAssembly/wasi-cli/issues/11 correctly, you were OK with removing the Windows-specific restriction, right? See: https://github.com/badeend/wasmtime/commit/2f48c77867d0bd02c4c910510f491a71da22a0f0
alexcrichton submitted PR review:
This looks great to me, thanks for this!
In retrospect though given the large number of changes related to
add_to_linkerwhat do you think about:
- Interface/world-level
add_to_linkerretains theLinkOptionsparameter- Top-level
add_to_linkerloses theLinkOptionsparameter, and there's a new top-leveladd_to_linker_with_optionsfunction?Or perhaps this would only affect the helpers we have in
wasmtime-wasiandwasmtime-wasi-http? Basically it looks like there should be a convenience function for "default options" rather than requiring all callers to call it.
alexcrichton created PR review comment:
Could this use a
BTreeSetorIndexSetto ensure it always generates a deterministic order of options?
badeend updated PR #9381.
badeend submitted PR review.
badeend created PR review comment:
Definitely
badeend commented on PR #9381:
- Interface/world-level add_to_linker retains the LinkOptions parameter
- Top-level add_to_linker loses the LinkOptions parameter, and there's a new top-level add_to_linker_with_options function?
Don't know what top-level function you're referring to. I think the Interface/world-level add_to_linker functions are the only ones generated by the bindgen?
I have just updated the wasmtime-wasi's functions back to their old signature and added an extra set of
_with_optionsvariants. I didn't touch the add_to_linker functions generated by bindgen.
alexcrichton submitted PR review:
Ah sorry for my rambling, this is exactly what I was thinking :+1:
badeend updated PR #9381.
badeend commented on PR #9381:
Try again please
alexcrichton has enabled auto merge for PR #9381.
badeend updated PR #9381.
badeend commented on PR #9381:
Sigh.
Try again, again?
alexcrichton has enabled auto merge for PR #9381.
alexcrichton merged PR #9381.
Last updated: Dec 06 2025 at 06:05 UTC