Skip to content

[libunwind][WebAssembly] Make libunwind compilable #92192

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

Merged
merged 5 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions libunwind/include/__libunwind_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@
#endif
#define _LIBUNWIND_HIGHEST_DWARF_REGISTER \
_LIBUNWIND_HIGHEST_DWARF_REGISTER_LOONGARCH
#elif defined(__wasm__)
// Unused
#define _LIBUNWIND_CONTEXT_SIZE 0
#define _LIBUNWIND_CURSOR_SIZE 0
# else
# error "Unsupported architecture."
# endif
Expand Down
3 changes: 2 additions & 1 deletion libunwind/src/UnwindLevel1.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
#include "libunwind_ext.h"
#include "unwind.h"

#if !defined(_LIBUNWIND_ARM_EHABI) && !defined(__USING_SJLJ_EXCEPTIONS__)
#if !defined(_LIBUNWIND_ARM_EHABI) && !defined(__USING_SJLJ_EXCEPTIONS__) && \
!defined(__wasm__)

#ifndef _LIBUNWIND_SUPPORT_SEH_UNWIND

Expand Down
4 changes: 2 additions & 2 deletions libunwind/src/UnwindRegistersRestore.S
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
.text
#endif

#if !defined(__USING_SJLJ_EXCEPTIONS__)
#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__wasm__)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are defining __USING_WASM_EXCEPTIONS__. Why you are not using it here and everywhere else?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__wasm__ is defined whenever we compile the code to wasm, and __USING_WASM_EXCEPTIONS__ is defined when we compile the code to wasm and use Wasm exceptions (-fwasm-exeptions). And this code should be excluded whenever it is compiled to wasm, even if -fwasm-exceptions is not used.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Then does the clang change really belong here? LIBUNWIND_USES_WASM_EXCEPTIONS also seems to be unused.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the clang change and LIBUNWIND_USES_WASM_EXCEPTIONS.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I land this? Thank you for your review!


#if defined(__i386__)
DEFINE_LIBUNWIND_FUNCTION(__libunwind_Registers_x86_jumpto)
Expand Down Expand Up @@ -1232,7 +1232,7 @@ DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind19Registers_loongarch6jumptoEv)

#endif

#endif /* !defined(__USING_SJLJ_EXCEPTIONS__) */
#endif /* !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__wasm__) */

NO_EXEC_STACK_DIRECTIVE

4 changes: 2 additions & 2 deletions libunwind/src/UnwindRegistersSave.S
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
.text
#endif

#if !defined(__USING_SJLJ_EXCEPTIONS__)
#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__wasm__)

#if defined(__i386__)

Expand Down Expand Up @@ -1177,6 +1177,6 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)

WEAK_ALIAS(__unw_getcontext, unw_getcontext)

#endif /* !defined(__USING_SJLJ_EXCEPTIONS__) */
#endif /* !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__wasm__) */

NO_EXEC_STACK_DIRECTIVE
4 changes: 2 additions & 2 deletions libunwind/src/libunwind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <sanitizer/asan_interface.h>
#endif

#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__USING_WASM_EXCEPTIONS__)
#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__wasm__)
#include "AddressSpace.hpp"
#include "UnwindCursor.hpp"

Expand Down Expand Up @@ -348,7 +348,7 @@ void __unw_remove_dynamic_eh_frame_section(unw_word_t eh_frame_start) {

#endif // defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
#endif // !defined(__USING_SJLJ_EXCEPTIONS__) &&
// !defined(__USING_WASM_EXCEPTIONS__)
// !defined(__wasm__)

#ifdef __APPLE__

Expand Down
Loading