| Issue |
175717
|
| Summary |
wasm-exceptions in clang 21 vs clang 20
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
anutosh491
|
Hey @sbc100 @aheejin
I would like some help from your end. I maintain clang-repl and the clang-repl in the browser through wasm usecase (which allows writing C++ in the browser in a repl format)
Can be tried out here : https://compiler-research.org/xeus-cpp/lab/index.html
The above link is already using `-fwasm-exceptions` & `-mllvm -wasm-enable-sjlj` with the CompilerBuilder as can be seen through the clang cc1 command. This is clang 20.1.8 based.
`
"" -cc1 -triple wasm32-unknown-emscripten ....... -target-feature +exception-handling -target-feature +multivalue -target-feature +reference-types -exception-model=wasm -mllvm -wasm-enable-eh ....... -fcxx-exceptions -fexceptions -exception-model=wasm -iwithsysroot/include/compat -fincremental-extensions -mllvm -wasm-enable-sjlj -o "<<< inputs >>>.o" -x c++ "<<< inputs >>>"
`
And hence you can do exception handling using the same
<img width="1073" height="316" alt="Image" src="" />
**But what we notice is as we're migrating to clang 21.1.8, wasm-exceptions doesn't work the same.**
Let me take this out of Jupyter and demonstrate it through a toy project. A standard clang-repl in the browser workflow looks like this
code in cell x -> PTU (partial translation unit as code in a repl can be incomplete -> LLVM IR -> incr_module_x.o where x is cell number -> incr_module_x.wasm which is built as a standlone side module and loaded on top of a main module (from where we can parse and execute code)
So it's one of these steps, where things can go wrong. In our case I suspect the LLVM IR being built is wrong and hence the wasm generated is also wrong.
Taking the minimalistic example of
```
try { throw 1; } catch (...) { 0; }
```
note that we're using only `-fwasm-exceptions`. our compiler builder args look something like
```
CB.SetCompilerArgs({
"-v",
"-xc++",
"-std=c++23",
"-Xclang", "-iwithsysroot/include/compat",
"-fwasm-exceptions"
});
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs