diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f3a6c6..681ddaa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -258,6 +258,7 @@ if(gperftools_enable_libunwind) if(have_libunwind) set(unwind_libs ${libunwind_location}) set(will_use_libunwind ON) + set(USE_LIBUNWIND 1) endif() endif() endif() diff --git a/cmake/config.h.in b/cmake/config.h.in index 3748271..f29d811 100644 --- a/cmake/config.h.in +++ b/cmake/config.h.in @@ -98,6 +98,8 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_LIBUNWIND_H +#cmakedefine USE_LIBUNWIND + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_LINUX_PTRACE_H diff --git a/configure.ac b/configure.ac index 698f2c7..766856d 100644 --- a/configure.ac +++ b/configure.ac @@ -272,8 +272,10 @@ AM_CONDITIONAL(ENABLE_STATIC, test "$enable_static" = yes) UNWIND_LIBS= if test "$enable_libunwind" = yes; then AC_CHECK_HEADERS([libunwind.h], - [AC_CHECK_LIB(unwind, backtrace, UNWIND_LIBS=-lunwind) - will_use_libunwind=yes]) + [AC_CHECK_LIB(unwind, backtrace, + [UNWIND_LIBS=-lunwind + AC_DEFINE([USE_LIBUNWIND], [1], [libunwind.h was found and is working]) + will_use_libunwind=yes])]) fi AC_SUBST(UNWIND_LIBS) diff --git a/src/stacktrace.cc b/src/stacktrace.cc index 32b16fa..4d85856 100644 --- a/src/stacktrace.cc +++ b/src/stacktrace.cc @@ -102,14 +102,14 @@ struct GetStackImplementation { // libunwind uses __thread so we check for both libunwind.h and // __thread support -#if defined(HAVE_LIBUNWIND_H) && defined(HAVE_TLS) +#if defined(USE_LIBUNWIND) && defined(HAVE_TLS) #define STACKTRACE_INL_HEADER "stacktrace_libunwind-inl.h" #define GST_SUFFIX libunwind #include "stacktrace_impl_setup-inl.h" #undef GST_SUFFIX #undef STACKTRACE_INL_HEADER #define HAVE_GST_libunwind -#endif // HAVE_LIBUNWIND_H +#endif // USE_LIBUNWIND #if defined(__i386__) || defined(__x86_64__) #define STACKTRACE_INL_HEADER "stacktrace_x86-inl.h"