jrandolf opened PR #14865 from jrandolf:export-type-ascription to bytecodealliance:main:
Wasmtime ignored the type ascribed to an exported instance, as in
(export "a" (instance $i) (instance ...)), and used the type of the definition instead. So exports the ascription hides were still listed inComponent::component_typeand reachable throughget_export_index, andimplements/external-idon nested exports came from the definition rather than the ascription. The same thing happened with an instance passed to a nested component whose import declares a narrower type: if the nested component re-exported it, the host saw the caller's instance, extra exports and attributes included.This views the root component's exports through the types wasmparser validated, which already account for ascriptions and declared import types.
record_exportnow takes an instance's exports, and their attributes, from the instance's type instead of from its definition. The attributes that were carried around next to instance definitions aren't needed anymore, so they're removed.Some behaviour that embedders can see changes:
- Hidden exports no longer show up in
component_type()and can't be looked up.- Components whose narrower type hides an item Wasmtime can't re-export (e.g. an imported function) now compile instead of being rejected.
- Exports of in-component instances are ordered by the instance's type instead of
HashMaporder, so export indices are now deterministic.Ascriptions that narrow a module export aren't handled.
The first commit is the fix. The second adds a test for the nested component case, which the same change fixes.
Closes #14852
Closes #14853
jrandolf edited PR #14865.
jrandolf has marked PR #14865 as ready for review.
jrandolf removed the review request for wasmtime-core-reviewers from PR #14865.
jrandolf requested pchickey for a review on PR #14865.
jrandolf requested wasmtime-core-reviewers for a review on PR #14865.
alexcrichton removed the review request for pchickey from PR #14865.
alexcrichton requested alexcrichton for a review on PR #14865.
:memo: alexcrichton submitted PR review:
Thanks!
:speech_balloon: alexcrichton created PR review comment:
I find this comment a bit confusing as it feels like it's kind of only relevant for this particular PR here. Perhaps something like:
For the root component (
frame.instance_ty.is_none()) re-ascribe exported instances with whatever type wasmparser recorded for that instance. If the component ascribed the type then it might be a subset of the exports that the instance actually exports.Additionally, can you add commentary for why only instances are handled here? Other types can also be ascribed, such as types/functions/resources.
:speech_balloon: alexcrichton created PR review comment:
This is pretty generically named/implemented for what's a pretty small slice of functionality -- could this
panic!on invalid inputs and/or be renamed to reflect how it's only dealing with instance types?
:memo: jrandolf submitted PR review.
:speech_balloon: jrandolf created PR review comment:
Done
:memo: jrandolf submitted PR review.
:speech_balloon: jrandolf created PR review comment:
Done
jrandolf updated PR #14865.
jrandolf requested alexcrichton for a review on PR #14865.
:thumbs_up: alexcrichton submitted PR review.
alexcrichton added PR #14865 Respect type ascriptions on component exports to the merge queue.
:check: alexcrichton merged PR #14865.
alexcrichton removed PR #14865 Respect type ascriptions on component exports from the merge queue.
Last updated: Oct 31 2026 at 23:03 UTC