[all-commits] [llvm/llvm-project] a947b4: [WebAssembly] Add Wasm SjLj option support for clang

Heejin Ahn via All-commits all-commits at lists.llvm.org
Tue Aug 24 18:13:12 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a947b40cafa8a1d7e241699c1400d80c77e9894c
      https://github.com/llvm/llvm-project/commit/a947b40cafa8a1d7e241699c1400d80c77e9894c
  Author: Heejin Ahn <aheejin at gmail.com>
  Date:   2021-08-24 (Tue, 24 Aug 2021)

  Changed paths:
    M clang/lib/Driver/ToolChains/WebAssembly.cpp
    M clang/test/Driver/wasm-toolchain.c

  Log Message:
  -----------
  [WebAssembly] Add Wasm SjLj option support for clang

This adds support for Wasm SjLj in clang. Also this sets the new
`-mllvm -wasm-enable-eh` option for Wasm EH.

Note there is a little unfortunate inconsistency there: Wasm EH is
enabled by a clang option `-fwasm-exceptions`, which sets
`-mllvm -wasm-enable-eh` in the backend options. It also sets
`-exception-model=wasm` but this is done in the common code.

Wasm SjLj doesn't have a clang-level option like `-fwasm-exceptions`.
`-fwasm-exceptions` was added because each exception model has its
corresponding `-f***-exceptions`, but I'm not sure if adding a new
option like `-fwasm-sjlj` or something is a good idea.

So the current plan is Emscripten sets `-mllvm -wasm-enable-sjlj` if
Wasm SJLj is enabled in its settings.js, as it does for Emscripten
EH/SjLj (it sets `-mllvm -enable-emscripten-cxx-exceptions` for
Emscripten EH and `-mllvm -enable-emscripten-sjlj` for Emscripten SjLj).
And setting this enables the exception handling feature, and also sets
`-exception-model=wasm`, but this time this is not done in the common
code so we do it ourselves.

Also note that other exception models have 1-to-1 correspondance with
their `-f***-exceptions` flag and their `-exception-model=***` flag, but
because we use `-exception-model=wasm` also for Wasm SjLj while
`-fwasm-exceptions` still means Wasm EH, there is also a little
inconsistency there, but I think it is manageable.

Also this adds various error checking and tests.

Reviewed By: dschuff

Differential Revision: https://reviews.llvm.org/D108582




More information about the All-commits mailing list