bytecodealliance / bytecodealliance/wasmtime

Provide a mechanism for disabling on-by-default config options regardless of the enabled cargo feature flags

Open
#10,454 6 comments 1 reaction 0 assignees View on GitHub
Dominant language
Rust
Stars
18.6k
Forks
1.8k
Avg merge
1d 19h
Merged PRs (30d)
121

Description

#### Feature

Provide some mechanism for disabling on-by-default config options without having to enable their associated cargo feature flags.

#### Benefit

The wasmtime [Config](https://docs.rs/wasmtime/latest/wasmtime/struct.Config.html) has a bunch of options like [Config::wasm_reference_types](https://docs.rs/wasmtime/latest/wasmtime/struct.Config.html#method.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:

1. Remove the `#[cfg(feature = ...)]` gates on all `Config` methods and their associated fields in the config.
2. Return an error from `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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.