Skip to content
Draft
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
1 change: 1 addition & 0 deletions src/native/external/llvm-libunwind-version.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ https://github.com/llvm/llvm-project/releases/tag/llvmorg-22.1.1
Apply https://github.com/dotnet/runtime/commit/35b7d59fa1075ab0fefb921393409806a821d8ed
Apply https://github.com/dotnet/runtime/commit/be5f98fb6702704afbaf705dce0b54d55479c6f1
Apply https://github.com/dotnet/runtime/commit/fde4a5bd965b128318e17a3b8ba1dc0fcf8df4a0
Apply https://github.com/dotnet/runtime/commit/5697904ea1bce4dea47d2d12c89a2c82dd0d18b5
13 changes: 9 additions & 4 deletions src/native/external/llvm-libunwind/src/Unwind-EHABI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,10 +443,11 @@ _Unwind_VRS_Interpret(_Unwind_Context *context, const uint32_t *data,
return _URC_CONTINUE_UNWIND;
}

// The C++ exception dispatch functions below depend on __unw_step and other
// public API functions from libunwind.cpp which are guarded out when
// _LIBUNWIND_NATIVEAOT is defined. NativeAOT does not use these - it only
// uses _Unwind_VRS_Interpret above.
// The C++ exception dispatch functions in the two #if !defined(_LIBUNWIND_NATIVEAOT)
// blocks below depend on __unw_step and other public API functions from libunwind.cpp
// which are guarded out when _LIBUNWIND_NATIVEAOT is defined. NativeAOT does not use
// these - it only uses _Unwind_VRS_Interpret above, which depends on
// _Unwind_VRS_Get/Set/Pop defined between the two guard blocks.
#if !defined(_LIBUNWIND_NATIVEAOT)

extern "C" _LIBUNWIND_EXPORT _Unwind_Reason_Code
Expand Down Expand Up @@ -891,6 +892,8 @@ _Unwind_GetLanguageSpecificData(struct _Unwind_Context *context) {
return result;
}

#endif // !defined(_LIBUNWIND_NATIVEAOT)

// Only used in _LIBUNWIND_TRACE_API, which is a no-op when assertions are
// disabled.
[[gnu::unused]] static uint64_t
Expand Down Expand Up @@ -1154,6 +1157,8 @@ _Unwind_VRS_Pop(_Unwind_Context *context, _Unwind_VRS_RegClass regclass,
_LIBUNWIND_ABORT("unsupported register class");
}

#if !defined(_LIBUNWIND_NATIVEAOT)

/// Not used by C++.
/// Unwinds stack, calling "stop" function at each frame.
/// Could be used to implement longjmp().
Expand Down
20 changes: 18 additions & 2 deletions src/native/external/llvm-libunwind/src/libunwind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,19 @@
#include <sanitizer/asan_interface.h>
#endif

#if !defined(_LIBUNWIND_NATIVEAOT)

#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__wasm__)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Perhaps we can omit these just for android to make both linux-arm and android-arm happy:

Suggested change
#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__wasm__)
#if defined(_LIBUNWIND_NATIVEAOT) && !defined(__ANDROID__)
#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__wasm__)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could work, but that seems a little fragile to me (I now think the ifdef approach was fragile to begin with), so trying another idea in #128927.

#include "AddressSpace.hpp"
#include "UnwindCursor.hpp"

using namespace libunwind;

// The singleton, cursor initialization, and most __unw_* functions are
// excluded from NativeAOT. The register accessors (__unw_get/set_reg,
// __unw_get/set_fpreg, __unw_save_vfp_as_X) are kept unconditional because
// they are called by _Unwind_VRS_Get/Set/Pop (Unwind-EHABI.cpp) which in
// turn are called by _Unwind_VRS_Interpret on ARM32 NativeAOT managed frames.
#if !defined(_LIBUNWIND_NATIVEAOT)

/// internal object to represent this processes address space
LocalAddressSpace LocalAddressSpace::sThisAddressSpace;

Expand Down Expand Up @@ -96,6 +101,8 @@ _LIBUNWIND_HIDDEN int __unw_init_local(unw_cursor_t *cursor,
}
_LIBUNWIND_WEAK_ALIAS(__unw_init_local, unw_init_local)

#endif // !defined(_LIBUNWIND_NATIVEAOT)

/// Get value of specified register at cursor position in stack frame.
_LIBUNWIND_HIDDEN int __unw_get_reg(unw_cursor_t *cursor, unw_regnum_t regNum,
unw_word_t *value) {
Expand Down Expand Up @@ -223,6 +230,8 @@ _LIBUNWIND_HIDDEN int __unw_set_fpreg(unw_cursor_t *cursor, unw_regnum_t regNum,
}
_LIBUNWIND_WEAK_ALIAS(__unw_set_fpreg, unw_set_fpreg)

#if !defined(_LIBUNWIND_NATIVEAOT)

/// Get location of specified register at cursor position in stack frame.
_LIBUNWIND_HIDDEN int __unw_get_save_loc(unw_cursor_t *cursor, int regNum,
unw_save_loc_t* location)
Expand Down Expand Up @@ -353,6 +362,8 @@ _LIBUNWIND_EXPORT uintptr_t __unw_get_data_rel_base(unw_cursor_t *cursor) {
_LIBUNWIND_WEAK_ALIAS(__unw_get_data_rel_base, unw_get_data_rel_base)
#endif

#endif // !defined(_LIBUNWIND_NATIVEAOT)

#ifdef __arm__
// Save VFP registers d0-d15 using FSTMIADX instead of FSTMIADD
_LIBUNWIND_HIDDEN void __unw_save_vfp_as_X(unw_cursor_t *cursor) {
Expand All @@ -364,6 +375,7 @@ _LIBUNWIND_HIDDEN void __unw_save_vfp_as_X(unw_cursor_t *cursor) {
_LIBUNWIND_WEAK_ALIAS(__unw_save_vfp_as_X, unw_save_vfp_as_X)
#endif

#if !defined(_LIBUNWIND_NATIVEAOT)

#if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
/// SPI: walks cached DWARF entries
Expand Down Expand Up @@ -465,8 +477,12 @@ _LIBUNWIND_HIDDEN const char *__unw_strerror(int error_code) {
}
_LIBUNWIND_WEAK_ALIAS(__unw_strerror, unw_strerror)

#endif // !defined(_LIBUNWIND_NATIVEAOT)

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

#if !defined(_LIBUNWIND_NATIVEAOT)

#ifdef __APPLE__

namespace libunwind {
Expand Down
Loading