From 2bcabac74fc6855c9a09e79eae2c7e12fe70808c Mon Sep 17 00:00:00 2001 From: Colin LeMahieu Date: Sun, 27 Oct 2024 11:28:48 +0000 Subject: [PATCH] Link boost stacktrace appropriately for line information. --- CMakeLists.txt | 23 +++++++++++------------ ci/build-ci.sh | 11 ----------- ci/build.sh | 9 --------- ci/prepare/linux/prepare-clang.sh | 4 ---- nano/lib/CMakeLists.txt | 4 ---- 5 files changed, 11 insertions(+), 40 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b93fac654..021d620896 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,18 +120,6 @@ set(NANO_ROCKSDB_TOOLS OFF CACHE BOOL "") -option(NANO_STACKTRACE_BACKTRACE - "Use BOOST_STACKTRACE_USE_BACKTRACE in stacktraces, for POSIX" OFF) - -if(NANO_STACKTRACE_BACKTRACE) - add_definitions(-DNANO_STACKTRACE_BACKTRACE) - add_definitions(-DBOOST_STACKTRACE_USE_BACKTRACE) - if(NANO_BACKTRACE_INCLUDE) - add_definitions( - -DBOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE=${NANO_BACKTRACE_INCLUDE}) - endif() -endif() - # Enable NANO_TRACING by default in Debug builds if(CMAKE_BUILD_TYPE STREQUAL "Debug") option(NANO_TRACING "Enable trace logging" ON) @@ -497,6 +485,17 @@ include_directories(${BOOST_LIBRARY_INCLUDES}) add_library(Boost::stacktrace ALIAS boost_stacktrace_basic) add_definitions(-DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED) +if(WIN32) + # Windows-specific configuration + target_link_libraries(boost_stacktrace_basic PRIVATE dbghelp) +else() + # Unix-like systems (Linux, macOS) + target_link_libraries(boost_stacktrace_basic PRIVATE dl) + + # Add -rdynamic linker flag for better symbol resolution + target_link_options(boost_stacktrace_basic PRIVATE -rdynamic) +endif() + # Workaround for missing reference errata in the boost property_tree module target_link_libraries(boost_property_tree INTERFACE Boost::any) target_link_libraries(boost_property_tree INTERFACE Boost::format) diff --git a/ci/build-ci.sh b/ci/build-ci.sh index 31a65eed7f..906be43f30 100755 --- a/ci/build-ci.sh +++ b/ci/build-ci.sh @@ -28,17 +28,6 @@ fi ulimit -S -n 8192 -if [[ "$OS" == 'Linux' ]]; then - if clang --version && [ ${LCOV:-0} == 0 ]; then - BACKTRACE="-DNANO_STACKTRACE_BACKTRACE=ON \ - -DNANO_BACKTRACE_INCLUDE=" - else - BACKTRACE="-DNANO_STACKTRACE_BACKTRACE=ON" - fi -else - BACKTRACE="" -fi - cmake \ -G'Unix Makefiles' \ -DACTIVE_NETWORK=nano_dev_network \ diff --git a/ci/build.sh b/ci/build.sh index 090aecbe86..c913344136 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -10,15 +10,6 @@ fi SRC=${SRC:-${PWD}} OS=$(uname) -CMAKE_BACKTRACE="" -if [[ ${OS} == 'Linux' ]]; then - CMAKE_BACKTRACE="-DNANO_STACKTRACE_BACKTRACE=ON" - - if [[ ${COMPILER:-} == 'clang' ]]; then - CMAKE_BACKTRACE="${CMAKE_BACKTRACE} -DNANO_BACKTRACE_INCLUDE=" - fi -fi - CMAKE_QT_DIR="" if [[ ${QT_DIR:-} ]]; then CMAKE_QT_DIR="-DQt5_DIR=${QT_DIR}" diff --git a/ci/prepare/linux/prepare-clang.sh b/ci/prepare/linux/prepare-clang.sh index ce35402e2e..5820a51f79 100755 --- a/ci/prepare/linux/prepare-clang.sh +++ b/ci/prepare/linux/prepare-clang.sh @@ -12,7 +12,3 @@ curl -O https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh $CLANG_VER update-alternatives --install /usr/bin/cc cc /usr/bin/clang-$CLANG_VERSION 100 update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-$CLANG_VERSION 100 update-alternatives --install /usr/bin/lldb lldb /usr/bin/lldb-$CLANG_VERSION 100 - -# Workaround to get a path that can be easily passed into cmake for BOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE -# See https://www.boost.org/doc/libs/1_70_0/doc/html/stacktrace/configuration_and_build.html#stacktrace.configuration_and_build.f3 -backtrace_file=$(find /usr/lib/gcc/ -name 'backtrace.h' | head -n 1) && test -f $backtrace_file && ln -s $backtrace_file /tmp/backtrace.h diff --git a/nano/lib/CMakeLists.txt b/nano/lib/CMakeLists.txt index 702cb84fa3..a353a8eea9 100644 --- a/nano/lib/CMakeLists.txt +++ b/nano/lib/CMakeLists.txt @@ -135,10 +135,6 @@ target_link_libraries( Boost::property_tree Boost::stacktrace) -if(NANO_STACKTRACE_BACKTRACE) - target_link_libraries(nano_lib backtrace) -endif() - target_compile_definitions( nano_lib PRIVATE -DMAJOR_VERSION_STRING=${CPACK_PACKAGE_VERSION_MAJOR}