[libcxx-commits] [PATCH] D158919: [libunwind][WebAssembly] Support Wasm EH
Heejin Ahn via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Aug 30 18:03:33 PDT 2023
aheejin added inline comments.
================
Comment at: libunwind/include/unwind_itanium.h:27
uintptr_t private_[6];
-#else
+#elif !defined(__USING_WASM_EXCEPTIONS__)
uintptr_t private_1; // non-zero means forced unwind
----------------
compnerd wrote:
> This is very confusing. Does WASM use SEH? This path is normally for Windows x86.
I actually don't really remember, because I wrote this more than 3 years ago. And note that it is `!defined` (negative), so I think I simply wanted to exclude them because we were not using them. Not sure what you mean by SEH or Windows x86.
I think I can just delete this. All our tests seem to pass without this change. The data structure can be a little larger but exceptions are rare so it wouldn't be a problem.
================
Comment at: libunwind/src/config.h:101
#endif
+#elif defined(__wasm__)
#else
----------------
compnerd wrote:
> It might be useful to provide warnings should those macros be used on WASM? Right now the use of `_LIBUNWIND_WEAK_ALIAS` will fail with a weird preprocessor error.
We don't use it in `Unwind-wasm.c` so I think I just tried to avoid the error. But we also support compilation of weak alias, so I think there's no reason we need to error out. I added `defined(__wasm__)` with other architectures, like this, and removed this separate `elif`:
```
--- a/system/lib/libunwind/src/config.h
+++ b/system/lib/libunwind/src/config.h
@@ -83,7 +83,7 @@
__asm__(".globl " SYMBOL_NAME(aliasname)); \
__asm__(SYMBOL_NAME(aliasname) " = " SYMBOL_NAME(name)); \
_LIBUNWIND_ALIAS_VISIBILITY(SYMBOL_NAME(aliasname))
-#elif defined(__ELF__) || defined(_AIX)
+#elif defined(__ELF__) || defined(_AIX) || defined(__wasm__)
#define _LIBUNWIND_WEAK_ALIAS(name, aliasname) \
extern "C" _LIBUNWIND_EXPORT __typeof(name) aliasname \
__attribute__((weak, alias(#name)));
@@ -98,7 +98,6 @@
SYMBOL_NAME(name))) \
extern "C" _LIBUNWIND_EXPORT __typeof(name) aliasname;
#endif
-#elif defined(__wasm__)
#else
#error Unsupported target
#endif
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D158919/new/
https://reviews.llvm.org/D158919
More information about the libcxx-commits
mailing list