Build a sysroot that supports C++ exceptions by default#606
Merged
alexcrichton merged 3 commits intoWebAssembly:mainfrom Apr 8, 2026
Merged
Build a sysroot that supports C++ exceptions by default#606alexcrichton merged 3 commits intoWebAssembly:mainfrom
alexcrichton merged 3 commits intoWebAssembly:mainfrom
Conversation
This was referenced Mar 11, 2026
This commit collects together some LLVM PRs, some changes in the build configuration here, and some thoughts from WebAssembly#565 and related issues. Specifically the changes here are: * The patch for llvm/llvm-project#168449 is updated to its upstream (unlanded) form. * Patches for the (landed) llvm/llvm-project#185770 and llvm/llvm-project#185775 are added. * The `WASI_SDK_EXCEPTIONS` configuration is now either `ON`, `OFF`, or `DUAL`. The default depends on the version of Clang in use, where 23.0.0+ (which isn't released officially yet) will be `DUAL` and otherwise it's `OFF`. CI for our custom-built patched toolchain defaults to `DUAL`. * In `DUAL` mode libcxx is built twice into two different directories, once with exceptions and once without. This is supported by LLVM patches and means that Clang will select the right set of libraries based on compiler flags. The end result here is that the produced toolchain from this repository, by default, supports C++ exceptions. Additionally if exceptions-related flags are not passed then the final binary will not use C++ exceptions nor require the wasm exception-handling proposal. There's still follow-up work from WebAssembly#565, such as: * Subjectively it feels wordy to pass `-fwasm-exceptions` vs `-fexceptions`. * Personally I think `-mllvm -wasm-use-legacy-eh=false` should become the default upstream. * Subjectively I don't think that `-lunwind` should be necessary and it should be injected automatically with `-fwasm-exceptions` (or `-fexceptions`). * Shared libraries for exceptions remain disabled due to build errors I do not personally know how to resolve. I'll file follow-up issues for these once this has landed since they're more minor compared to the main body of "anything works". Closes WebAssembly#334 Closes WebAssembly#565
b96bbc9 to
2f7a86e
Compare
ricochet
approved these changes
Mar 31, 2026
Co-authored-by: Joel Dice <joel.dice@akamai.com>
lewing
added a commit
to lewing/wasi-sdk
that referenced
this pull request
Apr 13, 2026
Enable C++ exceptions in the libc++/libc++abi/libunwind sysroot build. This is required for the CoreCLR WASM interpreter on WASI, which uses C++ exceptions for managed exception handling dispatch. Changes: - LIBCXX_ENABLE_EXCEPTIONS: OFF -> ON - LIBCXXABI_ENABLE_EXCEPTIONS: OFF -> ON - Add libunwind to LLVM_ENABLE_RUNTIMES - Add LIBCXXABI_USE_LLVM_UNWINDER, LIBUNWIND_ENABLE_SHARED, LIBUNWIND_USE_COMPILER_RT settings - Add -fwasm-exceptions to CMAKE_C_FLAGS and CMAKE_CXX_FLAGS This aligns with upstream wasi-sdk 33 (WebAssembly#606) which now builds exception-enabled sysroots by default. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit collects together some LLVM PRs, some changes in the build configuration here, and some thoughts from #565 and related issues. Specifically the changes here are:
WASI_SDK_EXCEPTIONSconfiguration is now eitherON,OFF, orDUAL. The default depends on the version of Clang in use, where 23.0.0+ (which isn't released officially yet) will beDUALand otherwise it'sOFF. CI for our custom-built patched toolchain defaults toDUAL.DUALmode libcxx is built twice into two different directories, once with exceptions and once without. This is supported by LLVM patches and means that Clang will select the right set of libraries based on compiler flags.The end result here is that the produced toolchain from this repository, by default, supports C++ exceptions. Additionally if exceptions-related flags are not passed then the final binary will not use C++ exceptions nor require the wasm exception-handling proposal.
There's still follow-up work from #565, such as:
-fwasm-exceptionsvs-fexceptions.-mllvm -wasm-use-legacy-eh=falseshould become the default upstream.-lunwindshould be necessary and it should be injected automatically with-fwasm-exceptions(or-fexceptions).I'll file follow-up issues for these once this has landed since they're more minor compared to the main body of "anything works".
Closes #334
Closes #565