Skip to content

Compose compile-time builtins in memory - #15025

Merged
fitzgen merged 1 commit into
bytecodealliance:mainfrom
dyslexicsteak:compose-in-memory
Oct 28, 2026
Merged

fitzgen merged 1 commit into
bytecodealliance:mainfrom
dyslexicsteak:compose-in-memory

Conversation

@dyslexicsteak

Copy link
Copy Markdown
Contributor

Compose the main Wasm and its compile-time builtins directly with wasm_compose::graph::CompositionGraph instead of writing them to a temporary directory and running the file-based ComponentComposer. Only builtins registered on the CodeBuilder can be composed in.

This also skips composition when the main Wasm imports no builtin, and drops the tempfile dependency of the compile-time-builtins feature.

This resolves a security issue and fixes various filesystem path related bugs and also adds tests with more realistic name inputs.

Fixes #15024.

@dyslexicsteak
dyslexicsteak requested a review from a team as a code owner October 27, 2026 09:09
@dyslexicsteak
dyslexicsteak requested review from dicej and removed request for a team October 27, 2026 09:09
@github-actions github-actions Bot added the wasmtime:api Related to the API of the `wasmtime` crate itself label Oct 27, 2026

@fitzgen fitzgen 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.

Thanks! Overall looks good, but a few things we should address before merging below.

@fitzgen
fitzgen removed the request for review from dicej October 27, 2026 18:46
@dyslexicsteak

Copy link
Copy Markdown
Contributor Author

Thanks! Overall looks good, but a few things we should address before merging below.

The feedback has got me thinking, actually, and maybe this requires an issue to discuss and a 2nd PR, but what if builtins resolved transitively? Like, say an embedder splits builtins into layers that build upon each other, with "ns:host/buffers" and "ns:host/strings" building on "ns:host/memory", as it stands right now, if a guest uses the higher-level builtins on their own then the lower level "ns:host/memory" won't get composed in because it's not a direct guest import. If they resolved transitively then it just works for any import anywhere and works fine based on my local testing.

@fitzgen

fitzgen commented Oct 28, 2026

Copy link
Copy Markdown
Member

The feedback has got me thinking, actually, and maybe this requires an issue to discuss and a 2nd PR, but what if builtins resolved transitively? Like, say an embedder splits builtins into layers that build upon each other, with "ns:host/buffers" and "ns:host/strings" building on "ns:host/memory", as it stands right now, if a guest uses the higher-level builtins on their own then the lower level "ns:host/memory" won't get composed in because it's not a direct guest import. If they resolved transitively then it just works for any import anywhere and works fine based on my local testing.

This seems reasonable, but yeah should be a dedicated follow up.

@fitzgen fitzgen 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.

Thanks!

@fitzgen
fitzgen added this pull request to the merge queue Oct 28, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 28, 2026
Build the composition with wasm-compose's `CompositionGraph` instead of
writing the main Wasm and its builtins to a temporary directory for the
file-based `ComponentComposer`. Import names no longer become file
paths, so interface names work, and only the registered builtins can be
composed in.

Also validate with the engine's features, name the builtin in its parse
errors, skip composition when no builtin is imported, and drop the
`tempfile` dependency.
@dyslexicsteak

dyslexicsteak commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor Author

The tempfile change triggered a lint in the merge queue on a misplaced tempfile dependency in component-async-tests that was originally hidden somehow, maybe by Cargo checking the build graph and seeing if it would have been included anyway. I moved it to be a dev dependency as the lint suggested.

@fitzgen
fitzgen enabled auto-merge October 28, 2026 14:44
@fitzgen
fitzgen added this pull request to the merge queue Oct 28, 2026
Merged via the queue into bytecodealliance:main with commit b34fad6 Oct 28, 2026
53 checks passed
@dyslexicsteak
dyslexicsteak deleted the compose-in-memory branch October 28, 2026 15:14
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.

Compile-time builtin composition resolves guest imports from host working directory & has path failures

2 participants