From e062c54f436e58ee102d2d37901cdaa052af249a Mon Sep 17 00:00:00 2001 From: ZL Date: Tue, 22 Jul 2025 14:06:54 +0800 Subject: [PATCH] Add bazel feature for wasm-exceptions (#1575) This PR add bazel feature for `-fwasm-exceptions` Part of #1400 --- bazel/emscripten_toolchain/toolchain.bzl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bazel/emscripten_toolchain/toolchain.bzl b/bazel/emscripten_toolchain/toolchain.bzl index ae2939f..070e3e0 100644 --- a/bazel/emscripten_toolchain/toolchain.bzl +++ b/bazel/emscripten_toolchain/toolchain.bzl @@ -363,6 +363,9 @@ def _impl(ctx): # Set if enabling exceptions. feature(name = "exceptions"), + # Set if enabling wasm_exceptions. + feature(name = "wasm_exceptions"), + # This feature overrides the default optimization to prefer execution speed # over binary size (like clang -O3). feature( @@ -515,7 +518,7 @@ def _impl(ctx): flags = [ "-fno-exceptions", ], - not_features = ["exceptions"], + not_features = ["exceptions", "wasm_exceptions"], ), flag_set( actions = all_cpp_compile_actions, @@ -524,6 +527,14 @@ def _impl(ctx): ], features = ["exceptions"], ), + flag_set( + actions = all_cpp_compile_actions + + all_link_actions, + flags = [ + "-fwasm-exceptions", + ], + features = ["wasm_exceptions"], + ), # All compiles (and implicitly link) flag_set( actions = all_compile_actions +