Stebalien requested alexcrichton for a review on PR #10455.
Stebalien requested wasmtime-core-reviewers for a review on PR #10455.
Stebalien opened PR #10455 from Stebalien:steb/wasm-config to bytecodealliance:main:
This patch keeps config options for disabling default-enabled wasmtime features, even when those features are disabled via crate feature flags. That way, these wasm features can be disabled by libraries even if the crate-level features are later enabled by some other crate in the build-tree.
Specifically, the following methods are available on the
wasmtime::Configtype, regardless of the enabled crate features:
Config::wasm_threads.Config::wasm_reference_types.Config::wasm_component_model.Config::parallel_compilation.Of these, enabling any of the first three while the corresponding crate feature is disabled will lead to a runtime error when constructing the
wasmtime::Engine. Enabling the last one, parallel compilation, will simply do nothing.fixes #10454
Stebalien commented on PR #10455:
I've tried to keep this change as minimal as possible and stuck to default-enabled features. I'm also happy to extend it to (any of the) features that are currently default-disabled:
Config::async_supportConfig::wasm_function_referencesConfig::wasm_gcConfig::component_model_asyncConfig::coredump_on_trapConfig::wmemcheckConfig::debug_adapter_modulesAlso note: I didn't bother with cranelift/winch options. As I understand it, those will only matter if you actually use cranelift/winch so they shouldn't affect any creates that aren't using the cranelift/winch features.
Stebalien submitted PR review.
Stebalien created PR review comment:
Judging by the test failures, this feature flag shouldn't be here in the first place and this feature is enabled by-default regardless, right?
alexcrichton submitted PR review.
alexcrichton created PR review comment:
Oh this is a bit subtle, and this also changed historically with Wasmtime. In essence though
REFERENCE_TYPESshould always be enabled regardless of what the crate features are, it's theGC_TYPESfeature which is actually gated based onfeature = "gc". There's nowasm_gc_types(...)configuration method, though.I think this can be fixed by updating the validator to allow reference-types being enabled with
feature = "gc"being turned off. It'sfeature = "gc"being turned off plusGC_TYPESbeing turned on that should be an error.
alexcrichton commented on PR #10455:
I think it might make sense to un-gate
wasm_*configuration while you're here, but for the others I think it's ok to leave them as-is and deal with them as they come up later. Although if you'd like to handle them here that's also ok.
Stebalien submitted PR review.
Stebalien created PR review comment:
- What happens if I turn off
wasm_reference_typesbut enable the GC feature?- Should
wasm_gctoggleGC_TYPES?
Stebalien updated PR #10455.
Stebalien submitted PR review.
Stebalien created PR review comment:
Also, does this apply to function references? That is, can I enable function references _without_ the GC feature?
Stebalien updated PR #10455.
Stebalien edited PR #10455:
This patch keeps config options for disabling default-enabled wasmtime features, even when those features are disabled via crate feature flags. That way, these wasm features can be disabled by libraries even if the crate-level features are later enabled by some other crate in the build-tree.
Specifically, the following
wasmtime::Configmethods are now enabled regardless of compile-time features (removed dependency on the GC feature):
Config::wasm_reference_types.Config::wasm_function_references.The following methods are available on the
wasmtime::Configtype, regardless of the enabled crate features but will lead to runtime errors when constructing awasmtime::Engine:
Config::wasm_threads.Config::wasm_gc.Config::wasm_component_model.Config::wasm_component_model_async.Finally,
Config::parallel_compilationis defined regardless of whether or not the parallel compilation feature is enabled. However, without the corresponding crate feature, this config option is a no-op.fixes #10454
Stebalien commented on PR #10455:
I've updated the PR per the new description to:
- Always define the
Config::wasm_*functions.- Allow setting
Config::wasm_reference_typesandConfig::wasm_function_references(I'm not sure if this second one is correct, pending discussion in https://github.com/bytecodealliance/wasmtime/pull/10455#discussion_r2008436743).
Stebalien updated PR #10455.
github-actions[bot] commented on PR #10455:
Label Messager: wasmtime:config
It looks like you are changing Wasmtime's configuration options. Make sure to
complete this check list:
[ ] If you added a new
Configmethod, you wrote extensive documentation for
it.<details>
Our documentation should be of the following form:
```text
Short, simple summary sentence.More details. These details can be multiple paragraphs. There should be
information about not just the method, but its parameters and results as
well.Is this method fallible? If so, when can it return an error?
Can this method panic? If so, when does it panic?
Example
Optional example here.
```</details>
[ ] If you added a new
Configmethod, or modified an existing one, you
ensured that this configuration is exercised by the fuzz targets.<details>
For example, if you expose a new strategy for allocating the next instance
slot inside the pooling allocator, you should ensure that at least one of our
fuzz targets exercises that new strategy.Often, all that is required of you is to ensure that there is a knob for this
configuration option in [wasmtime_fuzzing::Config][fuzzing-config] (or one
of its nestedstructs).Rarely, this may require authoring a new fuzz target to specifically test this
configuration. See [our docs on fuzzing][fuzzing-docs] for more details.</details>
[ ] If you are enabling a configuration option by default, make sure that it
has been fuzzed for at least two weeks before turning it on by default.[fuzzing-config]: https://github.com/bytecodealliance/wasmtime/blob/ca0e8d0a1d8cefc0496dba2f77a670571d8fdcab/crates/fuzzing/src/generators.rs#L182-L194
[fuzzing-docs]: https://docs.wasmtime.dev/contributing-fuzzing.html
<details>
To modify this label's message, edit the <code>.github/label-messager/wasmtime-config.md</code> file.
To add new label messages or remove existing label messages, edit the
<code>.github/label-messager.json</code> configuration file.</details>
alexcrichton submitted PR review.
alexcrichton created PR review comment:
If reference-types is turned off but GC is enabled, then that means GC-using modules will fail to load/compile because the feature is turned off, and the active feature at compile time is basically bloat/inert code and doesn't get used.
For now the hope is we can internalize GC_TYPES to exclusively the
feature = "gc"toggle, sowasm_gcshould not turn onGC_TYPES. Ifwasm_gcis turned on though andGC_TYPESis off then you can still load modules, but only those that don't use types that require a GC.For function-references we don't require a GC for typed function references so you should be able to use such a module without the GC feature.
The end goal is to have
wasm_gcon-by-default in the future, and in such a world we still want GC-disabled builds of Wasmtime to still load modules, so that's whatGC_TYPESis doing, basically disallowing loading modules at runtime which use features disabled at compile time.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
For this we should be able to remove this check entirely. I commented a bit above but on this specifically it's where
gcis safe to enable and it's just GC-using-things that aren't safe to enable. This is mostly because the GC proposal was larger than just GC references, it also introduced many other highly-related but still somewhat orthogonal things. The goal is to useGC_TYPESto separate out the runtime requirement but otherwise all the other stuff in the GC proposal is still valid.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
Mind adding a check below to return an error if this is explicitly enabled but disabled at compile time?
Stebalien closed without merge PR #10455.
Stebalien commented on PR #10455:
Status update: I'm no longer working on the project that needed this PR so I'm going to close it for now.
In case anyone else is interested in implementing this, the main remaining part is to resolve https://github.com/bytecodealliance/wasmtime/pull/10455#discussion_r2008491047.
Stebalien edited a comment on PR #10455:
Status update: I'm no longer working on the project that needed this PR so I'm going to close it for now. @alexcrichton thanks for taking the time to review this.
In case anyone else is interested in implementing this, the main remaining part is to resolve https://github.com/bytecodealliance/wasmtime/pull/10455#discussion_r2008491047.
Last updated: Dec 13 2025 at 19:03 UTC