llvm / llvm/llvm-project

[WebAssembly][clang][lld] None Legacy EH does not look working correctly

Open
#223,209 2 comments 0 reactions 0 assignees View on GitHub
clang lld
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

we need to do soething like this
```
-fwasm-exceptions -Wl,-mllvm,-wasm-enable-eh -Wl,-mllvm,-wasm-use-legacy-eh=false
```
still no guarantee to work.

also if we just use -Wl-mllvm,-wasm-enable-eh without -fwasm-exceptions. Compiler will crash.

```
[otgnhon doublefreetest]$ clang++ -o fr_neweh2.wasm fr.cc -O3 --target=wasm32-wasip1 --sysroot=$HOME/toolchains/llvm/wasm32-wasip1/wasm32-wasip1 -fwasm-exceptions -Wl,-mllvm,-wasm-enable-eh -Wl,-mllvm,-wasm-use-legacy-eh=false -lc++abi -lunwind -s
wasm-ld: error: symbol type mismatch: __cpp_exception
>>> defined as WASM_SYMBOL_TYPE_TAG in /tmp/fr-a80426.o
>>> defined as WASM_SYMBOL_TYPE_FUNCTION in /home//toolchains/llvm/wasm32-wasip1/wasm32-wasip1/lib/wasm32-wasip1/libunwind.a(Unwind-wasm.c.obj)
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
[otgnhon doublefreetest]$ clang++ -o fr_neweh2.wasm fr.cc -O3 --target=wasm32-wasip1 --sysroot=$HOME/toolchains/llvm/wasm32-wasip1/wasm32-wasip1 -fwasm-exceptions -Wl,-mllvm,-wasm-enable-eh -Wl,-mllvm,-wasm-use-legacy-eh=false -lc++abi -lunwind -flto=thin -s
`````
but lto works which is ridiculous

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the two clang++ commands using fr.cc, the wasm32-wasip1 target, and the shown exception and linker flags. Compare the non-LTO and ThinLTO results, then trace the clang/lld handling of legacy versus new WebAssembly EH and the __cpp_exception symbol. Done means the reported mismatch and crash are understood and the affected configuration behaves consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, wasm
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.