diff --git a/crates/c-api/include/wasmtime/config.h b/crates/c-api/include/wasmtime/config.h index 92d7c2ea1e65..dcef84fa6a67 100644 --- a/crates/c-api/include/wasmtime/config.h +++ b/crates/c-api/include/wasmtime/config.h @@ -213,6 +213,19 @@ WASMTIME_CONFIG_PROP(wasmtime_error_t*, strategy, wasmtime_strategy_t) */ WASMTIME_CONFIG_PROP(void, cranelift_debug_verifier, bool) +/** + * \brief Configures whether Cranelift should perform a NaN-canonicalization pass. + * + * When Cranelift is used as a code generation backend this will configure + * it to replace NaNs with a single canonical value. This is useful for users + * requiring entirely deterministic WebAssembly computation. + * + * This is not required by the WebAssembly spec, so it is not enabled by default. + * + * The default value for this is `false` + */ +WASMTIME_CONFIG_PROP(void, cranelift_nan_canonicalization, bool) + /** * \brief Configures Cranelift's optimization level for JIT code. * diff --git a/crates/c-api/src/config.rs b/crates/c-api/src/config.rs index c62f3f477947..f928ff39fb36 100644 --- a/crates/c-api/src/config.rs +++ b/crates/c-api/src/config.rs @@ -120,6 +120,14 @@ pub extern "C" fn wasmtime_config_cranelift_debug_verifier_set( c.config.cranelift_debug_verifier(enable); } +#[no_mangle] +pub extern "C" fn wasmtime_config_cranelift_nan_canonicalization_set( + c: &mut wasm_config_t, + enable: bool, +) { + c.config.cranelift_nan_canonicalization(enable); +} + #[no_mangle] pub extern "C" fn wasmtime_config_cranelift_opt_level_set( c: &mut wasm_config_t,