Skip to content

Commit

Permalink
Link boost stacktrace appropriately for line information.
Browse files Browse the repository at this point in the history
  • Loading branch information
clemahieu committed Oct 27, 2024
1 parent 09b635f commit 2bcabac
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 40 deletions.
23 changes: 11 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 0 additions & 11 deletions ci/build-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=</tmp/backtrace.h>"
else
BACKTRACE="-DNANO_STACKTRACE_BACKTRACE=ON"
fi
else
BACKTRACE=""
fi

cmake \
-G'Unix Makefiles' \
-DACTIVE_NETWORK=nano_dev_network \
Expand Down
9 changes: 0 additions & 9 deletions ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=</tmp/backtrace.h>"
fi
fi

CMAKE_QT_DIR=""
if [[ ${QT_DIR:-} ]]; then
CMAKE_QT_DIR="-DQt5_DIR=${QT_DIR}"
Expand Down
4 changes: 0 additions & 4 deletions ci/prepare/linux/prepare-clang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 0 additions & 4 deletions nano/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 2bcabac

Please sign in to comment.