-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a mechanism for disabling on-by-default config options regardless of the enabled cargo feature flags #10454
Comments
Your motivation definitely makes sense, however I think the alternative you describe is probably the best approach here, mainly because
|
Agreed yeah, I think it'd be reasonable to un-gate most of the |
I'm quite happy with either option and I'm happy to take a stab at implementing this. |
Great! Let me know (here or zulip) if you need any pointers or anything like that 👍 |
Would it make sense to have a method which returns a |
I have a PR here (#10455) but I need a small clarification on the default status of reference types with the "gc" feature disabled. |
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::Config` type, regardless of the enabled crate features: 1. `Config::wasm_threads`. 2. `Config::wasm_reference_types`. 3. `Config::wasm_component_model`. 4. `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 bytecodealliance#10454
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::Config` methods are now enabled regardless of compile-time features (removed dependency on the GC feature): 1. `Config::wasm_reference_types`. 2. `Config::wasm_function_references`. The following methods are available on the `wasmtime::Config` type, regardless of the enabled crate features but will lead to runtime errors when constructing a `wasmtime::Engine`: 1. `Config::wasm_threads`. 2. `Config::wasm_gc`. 3. `Config::wasm_component_model`. 4. `Config::wasm_component_model_async`. Finally, `Config::parallel_compilation` is 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 bytecodealliance#10454
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::Config` methods are now enabled regardless of compile-time features (removed dependency on the GC feature): 1. `Config::wasm_reference_types`. 2. `Config::wasm_function_references`. The following methods are available on the `wasmtime::Config` type, regardless of the enabled crate features but will lead to runtime errors when constructing a `wasmtime::Engine`: 1. `Config::wasm_threads`. 2. `Config::wasm_gc`. 3. `Config::wasm_component_model`. 4. `Config::wasm_component_model_async`. Finally, `Config::parallel_compilation` is 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 bytecodealliance#10454
Feature
Provide some mechanism for disabling on-by-default config options without having to enable their associated cargo feature flags.
Benefit
The wasmtime Config has a bunch of options like Config::wasm_reference_types that are enabled by-default if the corresponding cargo feature is enabled. Unfortunately, these config options are gated by the same feature flags making it impossible to turn them off without enabling the underlying cargo feature.
This is fine when building an application, but is a problem for library authors. If a library author wants to configure wasmtime in a specific way, they need to enable features (in cargo) they don't actually want so they can disable them in the config. Unfortunately, there's no way to actually detect if the feature has been enabled.
Implementation
The simplest solution is to provide some form of
Config::minimal()
constructor (or something like that) that turns off all optional features. New versions of wasmtime may make some of these features mandatory, but, IMO, that's fine. I'm mostly looking for predictability.Alternatives
Another option is to let users call all config methods even if the associated capabilities are disabled via cargo features:
#[cfg(feature = ...)]
gates on allConfig
methods and their associated fields in the config.Engine::new
if unsupported features are requested.The main drawback is that we'll lose the compile-time check on whether or not the feature is enabled.
The text was updated successfully, but these errors were encountered: