From d09378c8e852eed250902744db8353de4b78304d Mon Sep 17 00:00:00 2001 From: Jeremy Rifkin <51220084+jeremy-rifkin@users.noreply.github.com> Date: Thu, 12 Sep 2024 23:56:09 -0500 Subject: [PATCH] Use execinfo.h by default for clang/apple clang on macos, #161 --- CMakeLists.txt | 10 +++++++++- README.md | 12 ++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ae26087..52a546b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -116,7 +116,15 @@ if( ) ) # Attempt to auto-config - if(UNIX) + if(APPLE AND ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")) + if(HAS_EXECINFO) + set(CPPTRACE_UNWIND_WITH_EXECINFO On) + message(STATUS "Cpptrace auto config: Using execinfo.h for unwinding") + else() + set(CPPTRACE_UNWIND_WITH_NOTHING On) + message(FATAL_ERROR "Cpptrace auto config: No unwinding back-end seems to be supported, stack tracing will not work. To compile anyway set CPPTRACE_UNWIND_WITH_NOTHING.") + endif() + elseif(UNIX) if(HAS_UNWIND) set(CPPTRACE_UNWIND_WITH_UNWIND On) message(STATUS "Cpptrace auto config: Using libgcc unwind for unwinding") diff --git a/README.md b/README.md index b7311df..614495d 100644 --- a/README.md +++ b/README.md @@ -1051,12 +1051,12 @@ Unwinding, symbol resolution, and demangling. The library's CMake automatically configures itself for what your system supports. The ideal configuration is as follows: -| Platform | Unwinding | Symbols | Demangling | -| -------- | ------------- | ------------------ | -------------------- | -| Linux | `_Unwind` | libdwarf | cxxabi.h | -| MacOS | `_Unwind` | libdwarf | cxxabi.h | -| Windows | `StackWalk64` | dbghelp | No demangling needed | -| MinGW | `StackWalk64` | libdwarf + dbghelp | cxxabi.h | +| Platform | Unwinding | Symbols | Demangling | +| -------- | ------------------------------------------------------- | ------------------ | -------------------- | +| Linux | `_Unwind` | libdwarf | cxxabi.h | +| MacOS | `_Unwind` for gcc, execinfo.h for clang and apple clang | libdwarf | cxxabi.h | +| Windows | `StackWalk64` | dbghelp | No demangling needed | +| MinGW | `StackWalk64` | libdwarf + dbghelp | cxxabi.h | Support for these back-ends is the main development focus and they should work well. If you want to use a different back-end such as addr2line, for example, you can configure the library to do so.