Skip to content

Build a sysroot that supports C++ exceptions by default#606

Open
alexcrichton wants to merge 2 commits intoWebAssembly:mainfrom
alexcrichton:exceptions
Open

Build a sysroot that supports C++ exceptions by default#606
alexcrichton wants to merge 2 commits intoWebAssembly:mainfrom
alexcrichton:exceptions

Conversation

@alexcrichton
Copy link
Collaborator

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:

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:

  • 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 #334
Closes #565

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for C++ exceptions Add Support for WASM Exceptions

1 participant