- Notifications
You must be signed in to change notification settings - Fork 15.2k
[libunwind] Enable wasm target for exceptions #168449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
| @llvm/pr-subscribers-libunwind Author: Yerzhan Zhamashev (yerzham) ChangesMost minimal changes to enable libunwind to build for wasm by excluding Full diff: https://github.com/llvm/llvm-project/pull/168449.diff 2 Files Affected:
diff --git a/libunwind/src/assembly.h b/libunwind/src/assembly.h index 84c9d526f1d75..9c35b6050a2bf 100644 --- a/libunwind/src/assembly.h +++ b/libunwind/src/assembly.h @@ -254,6 +254,8 @@ aliasname: \ #define NO_EXEC_STACK_DIRECTIVE // clang-format on +#elif defined(__wasm__) + #else #error Unsupported target diff --git a/libunwind/src/config.h b/libunwind/src/config.h index f017403fa2234..73162995f9293 100644 --- a/libunwind/src/config.h +++ b/libunwind/src/config.h @@ -75,13 +75,14 @@ #define _LIBUNWIND_EXPORT #define _LIBUNWIND_HIDDEN #else - #if !defined(__ELF__) && !defined(__MACH__) && !defined(_AIX) - #define _LIBUNWIND_EXPORT __declspec(dllexport) - #define _LIBUNWIND_HIDDEN - #else - #define _LIBUNWIND_EXPORT __attribute__((visibility("default"))) - #define _LIBUNWIND_HIDDEN __attribute__((visibility("hidden"))) - #endif +#if !defined(__ELF__) && !defined(__MACH__) && !defined(_AIX) && \ + !defined(__wasm__) +#define _LIBUNWIND_EXPORT __declspec(dllexport) +#define _LIBUNWIND_HIDDEN +#else +#define _LIBUNWIND_EXPORT __attribute__((visibility("default"))) +#define _LIBUNWIND_HIDDEN __attribute__((visibility("hidden"))) +#endif #endif #define STR(a) #a |
4b07878 to 8baec64 Compare | Compared to yamt's gist why do we not have After fixing that I then ran into the following errors when linking Are there further changes needed to fix this? |
| I needed to clarify wasi-sdk had to use latest version of src/llvm-project, at least I tested since v21.1.5. Otherwise, usage of NO_EXEC_STACK_DIRECTIVE in UnwindRegistersRestore.S should be gated out since #92192 (then some modification at #162581). I do not think NO_EXEC_STACK_DIRECTIVE is ever used for wasm target after that, so it would be an unused declaration. As for the consequent errors, probably still related to outdated llvm source? |
Most minimal changes to enable libunwind to build for wasm by excluding
__wasm__from the Windows-style __declspec path in config.h and by recognizing wasm in assembly.h to skip the unsupported-target error. This unblocks building an exceptions-enabled wasi-sdk sysroot (see WebAssembly/wasi-sdk#565) and builds on prior attempts including yamt’s gist, #79667, and #140365.