diff options
author | Louis Dionne <ldionne.2@gmail.com> | 2022-03-04 22:34:46 +0300 |
---|---|---|
committer | Louis Dionne <ldionne.2@gmail.com> | 2022-03-30 18:23:36 +0300 |
commit | f29002a4b71b7734dfc4bd0e62eec2d341edb3fd (patch) | |
tree | ea8a79387946a72ba46be65ed28c4f2b851d1652 /libcxxabi | |
parent | 436b875e49ec05f24f7d7660a82fc5c5780221a0 (diff) |
[libunwind] Add a _LIBUNWIND_VERSION macro
This allows us to detect whether we're being compiled with LLVM's libunwind
more easily, without CMake having to set explicit variables.
As discussed in https://llvm.org/D119538.
Differential Revision: https://reviews.llvm.org/D121015
Diffstat (limited to 'libcxxabi')
-rw-r--r-- | libcxxabi/CMakeLists.txt | 5 | ||||
-rw-r--r-- | libcxxabi/src/cxa_personality.cpp | 13 |
2 files changed, 11 insertions, 7 deletions
diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt index bf9f112d1623..a7d6d1902158 100644 --- a/libcxxabi/CMakeLists.txt +++ b/libcxxabi/CMakeLists.txt @@ -485,11 +485,6 @@ if (MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS) endif() -# Define LIBCXXABI_USE_LLVM_UNWINDER for conditional compilation. -if (LIBCXXABI_USE_LLVM_UNWINDER) - add_definitions(-DLIBCXXABI_USE_LLVM_UNWINDER) -endif() - if (LIBCXXABI_SILENT_TERMINATE) add_definitions(-DLIBCXXABI_SILENT_TERMINATE) endif() diff --git a/libcxxabi/src/cxa_personality.cpp b/libcxxabi/src/cxa_personality.cpp index f6e135f137c0..b7ff4c217e16 100644 --- a/libcxxabi/src/cxa_personality.cpp +++ b/libcxxabi/src/cxa_personality.cpp @@ -22,6 +22,15 @@ #include "private_typeinfo.h" #include "unwind.h" +// TODO: This is a temporary workaround for libc++abi to recognize that it's being +// built against LLVM's libunwind. LLVM's libunwind started reporting _LIBUNWIND_VERSION +// in LLVM 15 -- we can remove this workaround after shipping LLVM 17. Once we remove +// this workaround, it won't be possible to build libc++abi against libunwind headers +// from LLVM 14 and before anymore. +#if defined(____LIBUNWIND_CONFIG_H__) && !defined(_LIBUNWIND_VERSION) +# define _LIBUNWIND_VERSION +#endif + #if defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__) #include <windows.h> #include <winnt.h> @@ -1015,7 +1024,7 @@ static _Unwind_Reason_Code continue_unwind(_Unwind_Exception* unwind_exception, } // ARM register names -#if !defined(LIBCXXABI_USE_LLVM_UNWINDER) +#if !defined(_LIBUNWIND_VERSION) static const uint32_t REG_UCB = 12; // Register to save _Unwind_Control_Block #endif static const uint32_t REG_SP = 13; @@ -1050,7 +1059,7 @@ __gxx_personality_v0(_Unwind_State state, bool native_exception = __isOurExceptionClass(unwind_exception); -#if !defined(LIBCXXABI_USE_LLVM_UNWINDER) +#if !defined(_LIBUNWIND_VERSION) // Copy the address of _Unwind_Control_Block to r12 so that // _Unwind_GetLanguageSpecificData() and _Unwind_GetRegionStart() can // return correct address. |