Stream: git-wasmtime

Topic: wasmtime / PR #11918 `CodeBuilder` APIs for defining comp...


view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2025 at 20:15):

fitzgen requested alexcrichton for a review on PR #11918.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2025 at 20:15):

fitzgen requested wasmtime-core-reviewers for a review on PR #11918.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2025 at 20:15):

fitzgen requested wasmtime-default-reviewers for a review on PR #11918.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2025 at 20:15):

fitzgen opened PR #11918 from fitzgen:compose-compile-time-builtins to bytecodealliance:main:

Compile-time builtins, as described in the RFC, are effectively the sum of three parts:

  1. Function inlining
  2. Unsafe intrinsics
  3. Component composition

The first two have already been implemented in Wasmtime. This commit implements the final part, leveraging wasm-compose to link host-defined compile-time builtin components with guest-defined main components. It exposes Wasmtime's unsafe intrinsics only to the host-defined compile-time builtins, not the guest-defined main Wasm component.

Why wasm-compose and not wac? Because it is in the same repo as the rest of the wasm-tools crates, and therefore it is easy to depend on without bringing in duplicate copies of that family of crates into our workspace and builds. Also its programmatic API is somewhat easier to use, and is not spread across multiple crates.

<!--
Please make sure you include the following information:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2025 at 20:15):

fitzgen edited PR #11918:

Compile-time builtins, as described in the RFC, are effectively the sum of three parts:

  1. Function inlining
  2. Unsafe intrinsics
  3. Component composition

The first two have already been implemented in Wasmtime. This commit implements the final part, leveraging wasm-compose to link host-defined compile-time builtin components with guest-defined main components. It exposes Wasmtime's unsafe intrinsics only to the host-defined compile-time builtins, not the guest-defined main Wasm component.

Why wasm-compose and not wac? Because it is in the same repo as the rest of the wasm-tools crates, and therefore it is easy to depend on without bringing in duplicate copies of that family of crates into our workspace and builds. Also its programmatic API is somewhat easier to use, and is not spread across multiple crates.

<!--
Please make sure you include the following information:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2025 at 20:22):

fitzgen updated PR #11918.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2025 at 21:21):

fitzgen updated PR #11918.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2025 at 22:03):

fitzgen updated PR #11918.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2025 at 23:18):

alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2025 at 23:18):

alexcrichton created PR review comment:

Given the weight of wasm-compose/tempfile would you be ok leaving this feature off-by-default?

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2025 at 23:18):

alexcrichton created PR review comment:

https://github.com/mozilla/cargo-vet/issues/663

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2025 at 23:18):

alexcrichton created PR review comment:

Could this delegate to compile_time_builtins_binary_or_text to avoid duplicating internals? Also, wat::parse_file might be useful here

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2025 at 23:18):

alexcrichton created PR review comment:

Personally I'd say that the builder should just go ahead and read all of the files. It's an API quirk of wasm-compose that it requires files on the filesystem, but otherwise I'd imagine that the builder does all I/O during configuration and then compilation is less heavy on the I/O

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2025 at 23:18):

alexcrichton created PR review comment:

To help out with #[cfg] in lots of places, how about crates/wasmtime/src/compile/compile_time_builtins.rs which itself has impl CodeBuilder<'a, 'b>` and all the methods over there?

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2025 at 23:18):

alexcrichton created PR review comment:

Would it make sense to plumb this feature in more locations? For example the preexisting expose_unsafe_intrinsics isn't gated by this feature but arguably may want to be? I'm not sure how beneficial that would be though.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2025 at 23:18):

alexcrichton created PR review comment:

This .clone() I think may not be desired since that clones the owned Cow if it's owned. I think you still want the as_deref from before?

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2025 at 23:18):

alexcrichton created PR review comment:

I'm a bit surprised in that I thought CodeBuilder usage was pretty rare throughout this repo as external helpers are primarily used. What are some of the locations that stop compiling with just one lifetime?

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2025 at 23:18):

alexcrichton created PR review comment:

You could replace these by looking for Payload::Version too and then change the level condition to "level 1 == do the thing, everything else == skip the thing"

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2025 at 23:44):

fitzgen submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2025 at 23:44):

fitzgen created PR review comment:

Ah, good to know, thanks

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2025 at 23:45):

fitzgen submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2025 at 23:45):

fitzgen created PR review comment:

The intrinsics themselves aren't worth gating, in my opinion. There isn't that much code there.

In contrast, pulling in wasm-compose is worth feature-gating, IMO.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2025 at 23:52):

fitzgen submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2025 at 23:52):

fitzgen created PR review comment:

FWIW, they won't be in our CLI release artifacts because there is not any way to define compile-time builtins via the CLI at the moment.

But all else being equal I'd rather have them enabled by default just because that seems like it is on the path for making things production ready, and I feel that this feature is fairly production ready already. If we disabled everything by default, and required opt-in for all features, disabling it would make sense to me, but we have a bunch of other stuff on by default that isn't as baked as this already is yet (stack switching, guest debugging, core dumps) so disabling this now doesn't really make sense to me.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2025 at 23:53):

fitzgen submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2025 at 23:53):

fitzgen created PR review comment:

Basically all my unsafe intrinsics tests and the unsafe intrinsics / compile-time builtins example as well. Wouldn't be the end of the world to fix them all, just annoying, and I figured it might be annoying for existing embedders as well.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2025 at 23:55):

fitzgen submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2025 at 23:55):

fitzgen created PR review comment:

Ah this might have been accidental fallout from my hunt for understanding the borrow checking errors I was seeing from putting the 'a lifetime into a type with a Drop implementation, and might not be necessary.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2025 at 23:56):

fitzgen updated PR #11918.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 23 2025 at 00:18):

fitzgen updated PR #11918.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 23 2025 at 00:18):

fitzgen submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 23 2025 at 00:18):

fitzgen created PR review comment:

Fixed in https://github.com/bytecodealliance/wasmtime/pull/11918/commits/5180f8207e1f6f983ddbed81f8020a9f56796434

view this post on Zulip Wasmtime GitHub notifications bot (Oct 23 2025 at 00:30):

fitzgen updated PR #11918.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 23 2025 at 00:31):

fitzgen submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 23 2025 at 00:31):

fitzgen created PR review comment:

https://github.com/bytecodealliance/wasmtime/pull/11918/commits/b5a78a464b9c9660b07b0ea2b96e1bf4521efb58

view this post on Zulip Wasmtime GitHub notifications bot (Oct 23 2025 at 00:31):

fitzgen submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 23 2025 at 00:31):

fitzgen created PR review comment:

https://github.com/bytecodealliance/wasmtime/pull/11918/commits/b5a78a464b9c9660b07b0ea2b96e1bf4521efb58

view this post on Zulip Wasmtime GitHub notifications bot (Oct 23 2025 at 00:33):

fitzgen updated PR #11918.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 23 2025 at 00:33):

fitzgen submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 23 2025 at 00:33):

fitzgen created PR review comment:

https://github.com/bytecodealliance/wasmtime/pull/11918/commits/e3dc4ff48f015e6fc0acb0d0ef1972f79a647cac

view this post on Zulip Wasmtime GitHub notifications bot (Oct 23 2025 at 00:36):

fitzgen updated PR #11918.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 23 2025 at 00:36):

fitzgen submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 23 2025 at 00:36):

fitzgen created PR review comment:

https://github.com/bytecodealliance/wasmtime/pull/11918/commits/8489dab945e1d8ecb3031a46f6340eb24bb19740

view this post on Zulip Wasmtime GitHub notifications bot (Oct 23 2025 at 00:46):

fitzgen updated PR #11918.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 23 2025 at 00:46):

fitzgen submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 23 2025 at 00:46):

fitzgen created PR review comment:

https://github.com/bytecodealliance/wasmtime/pull/11918/commits/c6b1860aa479f233f57fed88298d6337de28605a

view this post on Zulip Wasmtime GitHub notifications bot (Oct 23 2025 at 00:50):

fitzgen updated PR #11918.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 23 2025 at 00:50):

alexcrichton has enabled auto merge for PR #11918.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 23 2025 at 18:33):

fitzgen updated PR #11918.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 23 2025 at 18:33):

fitzgen has enabled auto merge for PR #11918.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 23 2025 at 19:23):

fitzgen merged PR #11918.


Last updated: Dec 06 2025 at 06:05 UTC