From 3cefdef5554583727868b7ec8318a3cad2600db6 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Fri, 6 Apr 2018 14:08:49 -0600 Subject: [PATCH] build: new FLB_BACKTRACE option (default=on) Signed-off-by: Eduardo Silva --- CMakeLists.txt | 16 ++++++++++++++++ src/CMakeLists.txt | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f78a6f3193..a249eb83a41 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,7 @@ option(FLB_POSIX_TLS "Force POSIX thread storage" No) option(FLB_WITHOUT_INOTIFY "Disable inotify support" No) option(FLB_SQLDB "Enable SQL embedded DB" No) option(FLB_HTTP_SERVER "Enable HTTP Server" No) +option(FLB_BACKTRACE "Enable stacktrace support" Yes) # Metrics: Experimental Feature, disabled by default on 0.12 series # but enabled in the upcoming 0.13 release. Note that development @@ -385,6 +386,21 @@ else() FLB_OPTION(FLB_JEMALLOC OFF) endif() +# LibBacktrace (friendly stacktrace support) +# ========================================= +if(FLB_BACKTRACE) + FLB_DEFINITION(FLB_HAVE_LIBBACKTRACE) + ExternalProject_Add(backtrace + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/libbacktrace-177940370/ + CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/lib/libbacktrace-177940370/configure ${AUTOCONF_HOST_OPT} --prefix= --enable-shared=no --enable-static=yes + BUILD_COMMAND ${MAKE} + ) + add_library(libbacktrace STATIC IMPORTED GLOBAL) + set_target_properties(libbacktrace PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/backtrace-prefix/lib/libbacktrace.a") + add_dependencies(libbacktrace backtrace) + include_directories("${CMAKE_CURRENT_BINARY_DIR}/backtrace-prefix/include/") +endif() + # Onigmo (Regex Engine) # ===================== if(FLB_REGEX) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6f93e9f5bae..d4ce75157e9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -228,6 +228,10 @@ if(NOT FLB_WITHOUT_BIN) target_link_libraries(fluent-bit-bin libjemalloc) endif() + if(FLB_BACKTRACE) + target_link_libraries(fluent-bit-bin libbacktrace) + endif() + target_link_libraries(fluent-bit-bin fluent-bit-static ${CMAKE_THREAD_LIBS_INIT}) set_target_properties(fluent-bit-bin