diff --git a/CMakeLists.txt b/CMakeLists.txt index d05a6468..07563217 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -460,6 +460,15 @@ if(USE_JEMALLOC) list(APPEND INCLUDE_DIRS ${Jemalloc_INCLUDE_DIRS}) endif() +set(DWARFS_USE_EXCEPTION_TRACER OFF) +if(NOT CMAKE_BUILD_TYPE STREQUAL Release) + if(NOT STATIC_BUILD_DO_NOT_USE) + if(TARGET folly_exception_tracer) + set(DWARFS_USE_EXCEPTION_TRACER ON) + endif() + endif() +endif() + add_library( thrift_light ${CMAKE_CURRENT_SOURCE_DIR}/fbthrift/thrift/lib/cpp2/FieldRef.cpp @@ -510,6 +519,10 @@ foreach(tgt dwarfs ${BINARY_TARGETS}) $<$:DWARFS_HAVE_LIBLZMA> $<$:DWARFS_HAVE_PYTHON>) + if(DWARFS_USE_EXCEPTION_TRACER) + target_compile_definitions(${tgt} PRIVATE DWARFS_USE_EXCEPTION_TRACER) + endif() + target_compile_options(${tgt} PRIVATE -Wall -Wextra -pedantic) set_property(TARGET ${tgt} PROPERTY CXX_STANDARD 17) @@ -597,7 +610,7 @@ foreach(tgt ${BINARY_TARGETS}) if(USE_JEMALLOC) target_link_libraries(${tgt} ${Jemalloc_LIBRARIES}) endif() - if(TARGET folly_exception_tracer) + if(DWARFS_USE_EXCEPTION_TRACER) target_link_libraries( ${tgt} -Wl,--whole-archive folly_exception_tracer_base folly_exception_tracer -Wl,--no-whole-archive) diff --git a/src/dwarfs/error.cpp b/src/dwarfs/error.cpp index 72c98eb8..26769cc4 100644 --- a/src/dwarfs/error.cpp +++ b/src/dwarfs/error.cpp @@ -24,9 +24,12 @@ #include #include -#include #include +#ifdef DWARFS_USE_EXCEPTION_TRACER +#include +#endif + #include "dwarfs/error.h" namespace dwarfs { @@ -51,7 +54,7 @@ system_error::system_error(int err, char const* file, int line) noexcept , line_(line) {} void dump_exceptions() { -#if !DWARFS_STATIC_BUILD && FOLLY_HAVE_ELF && FOLLY_HAVE_DWARF +#ifdef DWARFS_USE_EXCEPTION_TRACER auto exceptions = ::folly::exception_tracer::getCurrentExceptions(); for (auto& exc : exceptions) { std::cerr << exc << std::endl;