Auto config improvements (#20)
This commit is contained in:
parent
3ab0c7f738
commit
9d52dc24e2
@ -104,10 +104,11 @@ function(check_support var source includes libraries definitions)
|
|||||||
set(${var} ${${var}} PARENT_SCOPE)
|
set(${var} ${${var}} PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
if(NOT MSVC) # No need to bother checking in msvc, but do check in minngw
|
if(MINGW OR NOT WIN32) # No need to bother checking in msvc, but do check in minngw
|
||||||
check_support(HAS_UNWIND has_unwind.cpp "" "" "")
|
check_support(HAS_UNWIND has_unwind.cpp "" "" "")
|
||||||
check_support(HAS_EXECINFO has_execinfo.cpp "" "" "")
|
check_support(HAS_EXECINFO has_execinfo.cpp "" "" "")
|
||||||
check_support(HAS_BACKTRACE has_backtrace.cpp "" "backtrace" "${CPPTRACE_BACKTRACE_PATH_DEFINITION}")
|
check_support(HAS_BACKTRACE has_backtrace.cpp "" "backtrace" "${CPPTRACE_BACKTRACE_PATH_DEFINITION}")
|
||||||
|
check_support(HAS_DL has_dl.cpp "" "dl" "")
|
||||||
check_support(HAS_CXXABI has_cxxabi.cpp "" "" "")
|
check_support(HAS_CXXABI has_cxxabi.cpp "" "" "")
|
||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
set(STACKTRACE_LINK_LIB "stdc++_libbacktrace")
|
set(STACKTRACE_LINK_LIB "stdc++_libbacktrace")
|
||||||
@ -115,6 +116,16 @@ if(NOT MSVC) # No need to bother checking in msvc, but do check in minngw
|
|||||||
set(STACKTRACE_LINK_LIB "")
|
set(STACKTRACE_LINK_LIB "")
|
||||||
endif()
|
endif()
|
||||||
check_support(HAS_STACKTRACE has_stacktrace.cpp "" "${STACKTRACE_LINK_LIB}" "")
|
check_support(HAS_STACKTRACE has_stacktrace.cpp "" "${STACKTRACE_LINK_LIB}" "")
|
||||||
|
if(APPLE)
|
||||||
|
find_program(ADDR2LINE_PATH atos PATHS ENV PATH)
|
||||||
|
else()
|
||||||
|
find_program(ADDR2LINE_PATH addr2line PATHS ENV PATH)
|
||||||
|
endif()
|
||||||
|
if("${ADDR2LINE_PATH}" STREQUAL "ADDR2LINE_PATH-NOTFOUND")
|
||||||
|
set(HAS_ADDR2LINE FALSE)
|
||||||
|
else()
|
||||||
|
set(HAS_ADDR2LINE TRUE)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# =============================================== Autoconfig full dump ===============================================
|
# =============================================== Autoconfig full dump ===============================================
|
||||||
@ -135,7 +146,8 @@ if(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
# Attempt to auto-config
|
# Attempt to auto-config
|
||||||
if(HAS_STACKTRACE AND NOT WIN32) # Our trace is better than msvc's <stacktrace>
|
if(MINGW OR NOT WIN32) # Our trace is better than msvc's <stacktrace>
|
||||||
|
if(HAS_STACKTRACE)
|
||||||
set(CPPTRACE_FULL_TRACE_WITH_LIBBACKTRACE On)
|
set(CPPTRACE_FULL_TRACE_WITH_LIBBACKTRACE On)
|
||||||
message(STATUS "Cpptrace auto config: Using C++23 <stacktrace> for the full trace")
|
message(STATUS "Cpptrace auto config: Using C++23 <stacktrace> for the full trace")
|
||||||
elseif(HAS_BACKTRACE AND NOT WIN32) # Mingw libbacktrace doesn't seem to be working
|
elseif(HAS_BACKTRACE AND NOT WIN32) # Mingw libbacktrace doesn't seem to be working
|
||||||
@ -143,6 +155,7 @@ if(
|
|||||||
message(STATUS "Cpptrace auto config: Using libbacktrace for the full trace")
|
message(STATUS "Cpptrace auto config: Using libbacktrace for the full trace")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
# =============================================== Autoconfig unwinding ===============================================
|
# =============================================== Autoconfig unwinding ===============================================
|
||||||
# Unwind back-ends (If not doing CPPTRACE_FULL_TRACE_WITH_LIBBACKTRACE)
|
# Unwind back-ends (If not doing CPPTRACE_FULL_TRACE_WITH_LIBBACKTRACE)
|
||||||
@ -168,7 +181,7 @@ if(
|
|||||||
set(CPPTRACE_UNWIND_WITH_NOTHING On)
|
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.")
|
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()
|
endif()
|
||||||
elseif(WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # mingw
|
elseif(MINGW)
|
||||||
if(HAS_UNWIND)
|
if(HAS_UNWIND)
|
||||||
set(CPPTRACE_UNWIND_WITH_UNWIND On)
|
set(CPPTRACE_UNWIND_WITH_UNWIND On)
|
||||||
message(STATUS "Cpptrace auto config: Using libgcc unwind for unwinding")
|
message(STATUS "Cpptrace auto config: Using libgcc unwind for unwinding")
|
||||||
@ -201,18 +214,19 @@ if(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
# Attempt to auto-config
|
# Attempt to auto-config
|
||||||
if(APPLE)
|
if(UNIX OR MINGW)
|
||||||
set(CPPTRACE_GET_SYMBOLS_WITH_LIBDL ON)
|
if(HAS_BACKTRACE AND NOT MINGW) # not working on mingw at the moment
|
||||||
elseif(UNIX)
|
|
||||||
if(HAS_BACKTRACE)
|
|
||||||
set(CPPTRACE_GET_SYMBOLS_WITH_LIBBACKTRACE On)
|
set(CPPTRACE_GET_SYMBOLS_WITH_LIBBACKTRACE On)
|
||||||
message(STATUS "Cpptrace auto config: Using libbacktrace for symbols")
|
message(STATUS "Cpptrace auto config: Using libbacktrace for symbols")
|
||||||
|
elseif(HAS_ADDR2LINE)
|
||||||
|
set(CPPTRACE_GET_SYMBOLS_WITH_ADDR2LINE On)
|
||||||
|
message(STATUS "Cpptrace auto config: Using addr2line for symbols")
|
||||||
|
elseif(HAS_DL)
|
||||||
|
set(CPPTRACE_GET_SYMBOLS_WITH_LIBDL On)
|
||||||
|
message(STATUS "Cpptrace auto config: Using libdl for symbols")
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "Cpptrace auto config: No symbol back-end could be automatically configured. To compile anyway set CPPTRACE_GET_SYMBOLS_WITH_NOTHING.")
|
message(FATAL_ERROR "Cpptrace auto config: No symbol back-end could be automatically configured. To compile anyway set CPPTRACE_GET_SYMBOLS_WITH_NOTHING.")
|
||||||
endif()
|
endif()
|
||||||
elseif(WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # mingw
|
|
||||||
set(CPPTRACE_GET_SYMBOLS_WITH_ADDR2LINE On)
|
|
||||||
message(STATUS "Cpptrace auto config: Using addr2line for symbols")
|
|
||||||
elseif(WIN32)
|
elseif(WIN32)
|
||||||
set(CPPTRACE_GET_SYMBOLS_WITH_DBGHELP On)
|
set(CPPTRACE_GET_SYMBOLS_WITH_DBGHELP On)
|
||||||
message(STATUS "Cpptrace auto config: Using dbghelp for symbols")
|
message(STATUS "Cpptrace auto config: Using dbghelp for symbols")
|
||||||
|
|||||||
6
cmake/has_dl.cpp
Normal file
6
cmake/has_dl.cpp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include <dlfcn.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
Dl_info info;
|
||||||
|
dladdr(nullptr, &info);
|
||||||
|
}
|
||||||
@ -1,25 +0,0 @@
|
|||||||
test.cpp||19||trace()
|
|
||||||
test.cpp||35||foo(int)
|
|
||||||
test.cpp||39||foo(int)
|
|
||||||
test.cpp||39||foo(int)
|
|
||||||
test.cpp||39||foo(int)
|
|
||||||
test.cpp||39||foo(int)
|
|
||||||
test.cpp||39||foo(int)
|
|
||||||
test.cpp||39||foo(int)
|
|
||||||
test.cpp||39||foo(int)
|
|
||||||
test.cpp||39||foo(int)
|
|
||||||
test.cpp||39||foo(int)
|
|
||||||
test.cpp||39||foo(int)
|
|
||||||
test.cpp||47||void foo<int>(int, int)
|
|
||||||
test.cpp||47||void foo<int, int>(int, int, int)
|
|
||||||
test.cpp||47||void foo<int, int, int>(int, int, int, int)
|
|
||||||
test.cpp||47||void foo<int, int, int, int>(int, int, int, int, int)
|
|
||||||
test.cpp||47||void foo<int, int, int, int, int>(int, int, int, int, int, int)
|
|
||||||
test.cpp||47||void foo<int, int, int, int, int, int>(int, int, int, int, int, int, int)
|
|
||||||
test.cpp||47||void foo<int, int, int, int, int, int, int>(int, int, int, int, int, int, int, int)
|
|
||||||
test.cpp||47||void foo<int, int, int, int, int, int, int, int>(int, int, int, int, int, int, int, int, int)
|
|
||||||
test.cpp||47||void foo<int, int, int, int, int, int, int, int, int>(int, int, int, int, int, int, int, int, int, int)
|
|
||||||
test.cpp||53||function_two(int, float)
|
|
||||||
test.cpp||59||function_one(int)
|
|
||||||
test.cpp||65||main
|
|
||||||
||0||
|
|
||||||
25
test/expected/macos.libdl.txt
Normal file
25
test/expected/macos.libdl.txt
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
build/test||0||trace()
|
||||||
|
build/test||0||foo(int)
|
||||||
|
build/test||0||foo(int)
|
||||||
|
build/test||0||foo(int)
|
||||||
|
build/test||0||foo(int)
|
||||||
|
build/test||0||foo(int)
|
||||||
|
build/test||0||foo(int)
|
||||||
|
build/test||0||foo(int)
|
||||||
|
build/test||0||foo(int)
|
||||||
|
build/test||0||foo(int)
|
||||||
|
build/test||0||foo(int)
|
||||||
|
build/test||0||foo(int)
|
||||||
|
build/test||0||void foo<int>(int, int)
|
||||||
|
build/test||0||void foo<int, int>(int, int, int)
|
||||||
|
build/test||0||void foo<int, int, int>(int, int, int, int)
|
||||||
|
build/test||0||void foo<int, int, int, int>(int, int, int, int, int)
|
||||||
|
build/test||0||void foo<int, int, int, int, int>(int, int, int, int, int, int)
|
||||||
|
build/test||0||void foo<int, int, int, int, int, int>(int, int, int, int, int, int, int)
|
||||||
|
build/test||0||void foo<int, int, int, int, int, int, int>(int, int, int, int, int, int, int, int)
|
||||||
|
build/test||0||void foo<int, int, int, int, int, int, int, int>(int, int, int, int, int, int, int, int, int)
|
||||||
|
build/test||0||void foo<int, int, int, int, int, int, int, int, int>(int, int, int, int, int, int, int, int, int, int)
|
||||||
|
build/test||0||function_two(int, float)
|
||||||
|
build/test||0||function_one(int)
|
||||||
|
build/test||0||main
|
||||||
|
/usr/lib/dyld||0||start
|
||||||
@ -1,25 +1,25 @@
|
|||||||
build/test||0||trace()
|
test.cpp||19||trace()
|
||||||
build/test||0||foo(int)
|
test.cpp||35||foo(int)
|
||||||
build/test||0||foo(int)
|
test.cpp||39||foo(int)
|
||||||
build/test||0||foo(int)
|
test.cpp||39||foo(int)
|
||||||
build/test||0||foo(int)
|
test.cpp||39||foo(int)
|
||||||
build/test||0||foo(int)
|
test.cpp||39||foo(int)
|
||||||
build/test||0||foo(int)
|
test.cpp||39||foo(int)
|
||||||
build/test||0||foo(int)
|
test.cpp||39||foo(int)
|
||||||
build/test||0||foo(int)
|
test.cpp||39||foo(int)
|
||||||
build/test||0||foo(int)
|
test.cpp||39||foo(int)
|
||||||
build/test||0||foo(int)
|
test.cpp||39||foo(int)
|
||||||
build/test||0||foo(int)
|
test.cpp||39||foo(int)
|
||||||
build/test||0||void foo<int>(int, int)
|
test.cpp||47||void foo<int>(int, int)
|
||||||
build/test||0||void foo<int, int>(int, int, int)
|
test.cpp||47||void foo<int, int>(int, int, int)
|
||||||
build/test||0||void foo<int, int, int>(int, int, int, int)
|
test.cpp||47||void foo<int, int, int>(int, int, int, int)
|
||||||
build/test||0||void foo<int, int, int, int>(int, int, int, int, int)
|
test.cpp||47||void foo<int, int, int, int>(int, int, int, int, int)
|
||||||
build/test||0||void foo<int, int, int, int, int>(int, int, int, int, int, int)
|
test.cpp||47||void foo<int, int, int, int, int>(int, int, int, int, int, int)
|
||||||
build/test||0||void foo<int, int, int, int, int, int>(int, int, int, int, int, int, int)
|
test.cpp||47||void foo<int, int, int, int, int, int>(int, int, int, int, int, int, int)
|
||||||
build/test||0||void foo<int, int, int, int, int, int, int>(int, int, int, int, int, int, int, int)
|
test.cpp||47||void foo<int, int, int, int, int, int, int>(int, int, int, int, int, int, int, int)
|
||||||
build/test||0||void foo<int, int, int, int, int, int, int, int>(int, int, int, int, int, int, int, int, int)
|
test.cpp||47||void foo<int, int, int, int, int, int, int, int>(int, int, int, int, int, int, int, int, int)
|
||||||
build/test||0||void foo<int, int, int, int, int, int, int, int, int>(int, int, int, int, int, int, int, int, int, int)
|
test.cpp||47||void foo<int, int, int, int, int, int, int, int, int>(int, int, int, int, int, int, int, int, int, int)
|
||||||
build/test||0||function_two(int, float)
|
test.cpp||53||function_two(int, float)
|
||||||
build/test||0||function_one(int)
|
test.cpp||59||function_one(int)
|
||||||
build/test||0||main
|
test.cpp||65||main
|
||||||
/usr/lib/dyld||0||start
|
||0||
|
||||||
Loading…
Reference in New Issue
Block a user