diff --git a/lib/runtime-core/Cargo.toml b/lib/runtime-core/Cargo.toml index 967dbe32e..7f6d6a58a 100644 --- a/lib/runtime-core/Cargo.toml +++ b/lib/runtime-core/Cargo.toml @@ -59,3 +59,5 @@ generate-debug-information = ["wasm-debug"] # don't export symbols related to the GDB JIT interafce, LLVM or some other native # code will be providing them generate-debug-information-no-export-symbols = [] +# enable DynamicFunc's for closures with captured environment. +dynamicfunc-fat-closures = [] diff --git a/lib/runtime-core/src/typed_func.rs b/lib/runtime-core/src/typed_func.rs index 0b29d54ea..61def512d 100644 --- a/lib/runtime-core/src/typed_func.rs +++ b/lib/runtime-core/src/typed_func.rs @@ -349,9 +349,8 @@ impl<'a> DynamicFunc<'a> { } } - // Disable "fat" closures for possible future changes. - if mem::size_of::() != 0 { - unimplemented!("DynamicFunc with captured environment is not yet supported"); + if cfg!(not(feature = "dynamicfunc-fat-closures")) && mem::size_of::() != 0 { + unimplemented!("DynamicFunc with captured environment is disabled"); } let mut builder = TrampolineBufferBuilder::new();