From c3e8c410f897106447fd1364066f808cb8099bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Tue, 2 Jun 2026 16:31:36 +0900 Subject: [PATCH] Revert "Guard unused llvm-libunwind symbols to avoid duplicates on Android" --- src/coreclr/nativeaot/Runtime/CMakeLists.txt | 8 ++------ .../nativeaot/Runtime/unix/UnixNativeCodeManager.cpp | 2 +- src/coreclr/nativeaot/Runtime/unix/UnwindHelpers.cpp | 5 ----- src/coreclr/nativeaot/Runtime/unix/UnwindHelpers.h | 1 - src/native/external/llvm-libunwind-version.txt | 1 - src/native/external/llvm-libunwind/src/Unwind-EHABI.cpp | 8 -------- src/native/external/llvm-libunwind/src/libunwind.cpp | 4 ---- 7 files changed, 3 insertions(+), 26 deletions(-) diff --git a/src/coreclr/nativeaot/Runtime/CMakeLists.txt b/src/coreclr/nativeaot/Runtime/CMakeLists.txt index 7b7eaf49ed1f35..e491f54a562445 100644 --- a/src/coreclr/nativeaot/Runtime/CMakeLists.txt +++ b/src/coreclr/nativeaot/Runtime/CMakeLists.txt @@ -149,12 +149,8 @@ else() include_directories($ENV{EMSCRIPTEN/system/lib/libcxxabi/include}) endif() - # Guard out the public unw_* C API, C++ exception dispatch entry points, - # and the LocalAddressSpace singleton from llvm-libunwind. NativeAOT does - # not use these - it uses the internal C++ classes directly. Omitting them - # avoids exporting symbols that conflict with platform libunwind (e.g. - # Android NDK r29). - add_definitions(-D_LIBUNWIND_NATIVEAOT=1) + # Disable building _Unwind_XXX style APIs of libunwind, since we don't use them. + add_definitions(-D_LIBUNWIND_DISABLE_ZERO_COST_APIS=1) # Compile unwinding only for the current compilation target architecture add_definitions(-D_LIBUNWIND_IS_NATIVE_ONLY) diff --git a/src/coreclr/nativeaot/Runtime/unix/UnixNativeCodeManager.cpp b/src/coreclr/nativeaot/Runtime/unix/UnixNativeCodeManager.cpp index 982c541c7014f6..266b56bd1f6e4e 100644 --- a/src/coreclr/nativeaot/Runtime/unix/UnixNativeCodeManager.cpp +++ b/src/coreclr/nativeaot/Runtime/unix/UnixNativeCodeManager.cpp @@ -56,7 +56,7 @@ UnixNativeCodeManager::UnixNativeCodeManager(TADDR moduleBase, m_pClasslibFunctions(pClasslibFunctions), m_nClasslibFunctions(nClasslibFunctions) { // Cache the location of unwind sections - UnwindHelpers::FindUnwindSections( + libunwind::LocalAddressSpace::sThisAddressSpace.findUnwindSections( (uintptr_t)pvManagedCodeStartRange, m_UnwindInfoSections); } diff --git a/src/coreclr/nativeaot/Runtime/unix/UnwindHelpers.cpp b/src/coreclr/nativeaot/Runtime/unix/UnwindHelpers.cpp index be27ac18f65826..b1e51f8cad6782 100644 --- a/src/coreclr/nativeaot/Runtime/unix/UnwindHelpers.cpp +++ b/src/coreclr/nativeaot/Runtime/unix/UnwindHelpers.cpp @@ -1396,11 +1396,6 @@ bool UnwindHelpers::GetUnwindProcInfo(PCODE pc, UnwindInfoSections &uwInfoSectio return true; } -bool UnwindHelpers::FindUnwindSections(uintptr_t pc, UnwindInfoSections §ions) -{ - return _addressSpace.findUnwindSections(pc, sections); -} - #if defined(TARGET_APPLE) // Apple considers _dyld_find_unwind_sections to be private API that cannot be used // by apps submitted to App Store and TestFlight, both for iOS-like and macOS platforms. diff --git a/src/coreclr/nativeaot/Runtime/unix/UnwindHelpers.h b/src/coreclr/nativeaot/Runtime/unix/UnwindHelpers.h index a185c990648b62..2e9d7a299e0e01 100644 --- a/src/coreclr/nativeaot/Runtime/unix/UnwindHelpers.h +++ b/src/coreclr/nativeaot/Runtime/unix/UnwindHelpers.h @@ -15,5 +15,4 @@ class UnwindHelpers public: static bool StepFrame(REGDISPLAY *regs, unw_word_t start_ip, uint32_t format, unw_word_t unwind_info); static bool GetUnwindProcInfo(PCODE ip, libunwind::UnwindInfoSections &uwInfoSections, unw_proc_info_t *procInfo); - static bool FindUnwindSections(uintptr_t pc, libunwind::UnwindInfoSections §ions); }; diff --git a/src/native/external/llvm-libunwind-version.txt b/src/native/external/llvm-libunwind-version.txt index b2b238ba74ab9b..8d9b9e900e6bcb 100644 --- a/src/native/external/llvm-libunwind-version.txt +++ b/src/native/external/llvm-libunwind-version.txt @@ -3,4 +3,3 @@ 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 diff --git a/src/native/external/llvm-libunwind/src/Unwind-EHABI.cpp b/src/native/external/llvm-libunwind/src/Unwind-EHABI.cpp index 5292bc55d37823..338c853bca780e 100644 --- a/src/native/external/llvm-libunwind/src/Unwind-EHABI.cpp +++ b/src/native/external/llvm-libunwind/src/Unwind-EHABI.cpp @@ -443,12 +443,6 @@ _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. -#if !defined(_LIBUNWIND_NATIVEAOT) - extern "C" _LIBUNWIND_EXPORT _Unwind_Reason_Code __aeabi_unwind_cpp_pr0(_Unwind_State state, _Unwind_Control_Block *ucbp, _Unwind_Context *context) { @@ -1216,6 +1210,4 @@ __gnu_unwind_frame(_Unwind_Exception *exception_object, } } -#endif // !defined(_LIBUNWIND_NATIVEAOT) - #endif // defined(_LIBUNWIND_ARM_EHABI) diff --git a/src/native/external/llvm-libunwind/src/libunwind.cpp b/src/native/external/llvm-libunwind/src/libunwind.cpp index 0dfd6cf49b1134..2f2032c6c28147 100644 --- a/src/native/external/llvm-libunwind/src/libunwind.cpp +++ b/src/native/external/llvm-libunwind/src/libunwind.cpp @@ -26,8 +26,6 @@ #include #endif -#if !defined(_LIBUNWIND_NATIVEAOT) - #if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__wasm__) #include "AddressSpace.hpp" #include "UnwindCursor.hpp" @@ -549,8 +547,6 @@ int __unw_remove_find_dynamic_unwind_sections( #endif // __APPLE__ -#endif // !defined(_LIBUNWIND_NATIVEAOT) - // Add logging hooks in Debug builds only #ifndef NDEBUG #include