Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Expose exceptions proposal configuration on C API (#11861)

MUsoftwareca4a236eb0b9
diff --git a/crates/c-api/include/wasmtime/config.h b/crates/c-api/include/wasmtime/config.h
index 482f3c1b7c..ab104e95f7 100644
--- a/crates/c-api/include/wasmtime/config.h
+++ b/crates/c-api/include/wasmtime/config.h
@@ -248,6 +248,13 @@ WASMTIME_CONFIG_PROP(void, wasm_memory64, bool)
*/
WASMTIME_CONFIG_PROP(void, wasm_wide_arithmetic, bool)
+/**
+ * \brief Configures whether the WebAssembly exceptions proposal is enabled.
+ *
+ * This setting is `false` by default.
+ */
+WASMTIME_CONFIG_PROP(void, wasm_exceptions, bool)
+
#ifdef WASMTIME_FEATURE_COMPILER
/**
diff --git a/crates/c-api/include/wasmtime/config.hh b/crates/c-api/include/wasmtime/config.hh
index cf789c5a45..6c72942610 100644
--- a/crates/c-api/include/wasmtime/config.hh
+++ b/crates/c-api/include/wasmtime/config.hh
@@ -390,6 +390,14 @@ public:
wasmtime_config_wasm_wide_arithmetic_set(ptr.get(), enable);
}
+ /// \brief Configures whether the WebAssembly exceptions proposal will be
+ /// enabled
+ ///
+ /// https://docs.wasmtime.dev/api/wasmtime/struct.Config.html#method.wasm_exceptions
+ void wasm_exceptions(bool enable) {
+ wasmtime_config_wasm_exceptions_set(ptr.get(), enable);
+ }
+
#ifdef WASMTIME_FEATURE_COMPONENT_MODEL
/// \brief Configures whether the WebAssembly component model proposal will be
/// enabled
diff --git a/crates/c-api/src/config.rs b/crates/c-api/src/config.rs
index 3113ab1627..0f215cc9c2 100644
--- a/crates/c-api/src/config.rs
+++ b/crates/c-api/src/config.rs
@@ -460,6 +460,11 @@ pub extern "C" fn wasmtime_config_wasm_wide_arithmetic_set(c: &mut wasm_config_t
c.config.wasm_wide_arithmetic(enable);
}
+#[unsafe(no_mangle)]
+pub extern "C" fn wasmtime_config_wasm_exceptions_set(c: &mut wasm_config_t, enable: bool) {
+ c.config.wasm_exceptions(enable);
+}
+
#[repr(C)]
#[derive(Clone)]
#[cfg(feature = "pooling-allocator")]
diff --git a/crates/c-api/tests/config.cc b/crates/c-api/tests/config.cc
index 03dc05885f..5bd53489de 100644
--- a/crates/c-api/tests/config.cc
+++ b/crates/c-api/tests/config.cc
@@ -51,6 +51,7 @@ TEST(Config, Smoke) {
config.wasm_memory64(false);
config.wasm_wide_arithmetic(false);
config.wasm_component_model(false);
+ config.wasm_exceptions(false);
config.strategy(Strategy::Auto);
config.cranelift_debug_verifier(false);
config.cranelift_opt_level(OptLevel::Speed);