How to Fix: `Config::wasm_bulk_memory(false)` cannot be usefully specified without enabling the `gc` feature.
This bug is a feature-gating mismatch: Config::wasm_bulk_memory(false) looks configurable, but in a wasmtime build that enables runtime without gc, disabling bulk memory is not meaningfully supported because the setting is tied to engine behavior that assumes related compilation capabilities are present.
Understanding the Root Cause
At the center of this issue is the interaction between Wasmtime configuration flags, WebAssembly proposal support, and Cargo feature gating.
In Wasmtime, Config exposes methods such as wasm_bulk_memory(false) so callers can explicitly enable or disable specific WebAssembly features. In theory, that suggests you can turn bulk memory off independently. In practice, when Wasmtime is compiled with runtime but without gc, that configuration path becomes misleading.
The reason is that some internal validation and compilation paths are only useful when the engine has the corresponding feature support compiled in. If the gc feature is not enabled at build time, Wasmtime cannot fully honor certain combinations of runtime configuration flags in a useful way. As a result, calling Config::wasm_bulk_memory(false) may compile, but it does not provide a meaningful standalone configuration in that feature set.
This is why the issue exists: the public API implies a valid runtime toggle, while the actual crate feature matrix makes that toggle ineffective or unsupported unless the proper related features are enabled.
In short:
- Cargo features determine which Wasmtime capabilities exist in the binary at all.
- Config methods only control behavior that the compiled binary can actually support.
- Without gc, disabling bulk memory is not usefully representable in this scenario.
Step-by-Step Solution
The correct fix depends on what you actually want from your Wasmtime embedder.
Option 1: Enable the gc feature if you need this configuration to be meaningful
If your application explicitly needs to control bulk memory support, update your dependency so the relevant Wasmtime feature set is compiled in.
[dependencies]
wasmtime = { version = "<your-version>", features = ["runtime", "gc"] }
Then configure the engine normally:
use wasmtime::Config;
use wasmtime::Engine;
fn main() -> anyhow::Result<()> {
let mut config = Config::new();
config.wasm_bulk_memory(false);
let engine = Engine::new(&config)?;
Ok(())
}
This approach is best when your runtime must precisely control enabled WebAssembly proposals.
Option 2: Remove the call if you do not need to override the default
If your project does not specifically require disabling bulk memory, the simplest and safest fix is to stop setting it.
use wasmtime::Config;
use wasmtime::Engine;
fn main() -> anyhow::Result<()> {
let config = Config::new();
let engine = Engine::new(&config)?;
Ok(())
}
This avoids an API combination that is not useful under the current feature set.
Option 3: Gate your configuration in your own crate
If you maintain a library or support multiple Wasmtime builds, make your configuration conditional so you only call wasm_bulk_memory(false) when the relevant feature set is enabled.
[features]
default = []
wasmtime-gc = ["wasmtime/gc"]
[dependencies]
wasmtime = { version = "<your-version>", features = ["runtime"] }
use wasmtime::Config;
fn build_config() -> Config {
let mut config = Config::new();
#[cfg(feature = "wasmtime-gc")]
{
config.wasm_bulk_memory(false);
}
config
}
This is the most maintainable approach for reusable crates, CI matrices, and workspace builds.
Option 4: Upgrade to a Wasmtime release that clarifies or fixes the API behavior
If this issue was reported against an older version, check the Wasmtime repository and release notes for a patch that either:
- improves validation,
- changes feature requirements, or
- makes the API reject unsupported combinations more clearly.
In some cases, the real fix is upstream: preventing confusing configuration calls when the underlying feature is unavailable.
Recommended decision matrix
- If you must disable bulk memory: enable gc and keep the config call.
- If you do not care about bulk memory explicitly: remove the call.
- If you support multiple builds: add conditional compilation around the setting.
- If behavior seems inconsistent across versions: upgrade Wasmtime and retest.
Common Edge Cases
1. You enabled runtime but assumed all WebAssembly toggles are runtime-only
This is a common misunderstanding. In Wasmtime, many settings look like runtime configuration, but they still depend on what was compiled into the crate through Cargo features.
2. Your workspace enables different Wasmtime features in different crates
Feature unification in Cargo can produce surprising results. One crate may expect gc to be off, while another turns it on indirectly. Always inspect your resolved dependency graph with your usual Cargo tooling and verify the final feature set.
3. CI and local builds behave differently
If one environment enables default features or extra workspace features, you may only see this issue in one place. Pin your dependency declaration carefully and test with the exact same feature flags in all environments.
4. You are disabling bulk memory to validate older Wasm modules
If your real goal is compatibility testing for modules that target a narrower WebAssembly baseline, be aware that not every proposal toggle is equally independent in the current Wasmtime API surface. You may need a different test strategy, such as validating modules separately or using a build that supports the full configuration matrix you need.
5. The code compiles, but behavior still seems wrong
That usually indicates an API semantics problem rather than a syntax problem. The method exists, but under your active crate features, it may not affect engine behavior in the way you expect.
FAQ
Why does wasm_bulk_memory(false) exist if it cannot always be used meaningfully?
Because the API is broader than any single Cargo feature combination. Wasmtime exposes configuration methods for engines built with different capabilities, but some combinations are only valid or useful when specific compile-time features are enabled.
Do I always need the gc feature to use Config::wasm_bulk_memory?
Not necessarily in every version or implementation detail, but for the issue described here, disabling bulk memory without gc is not usefully supported. The practical fix is to enable gc or avoid setting that flag.
Is this a bug in my application code or in Wasmtime?
It is primarily an upstream API/feature-gating issue. Your code is only triggering a configuration combination that the API suggests is valid, but the compiled feature set does not support meaningfully.
If you are maintaining production code, the safest resolution is to align your Cargo features with the Config options you intend to use and avoid assuming that every exposed toggle is independent under every build configuration.