From 4ffa98388f8a28c55b0c8acfbba5f62df954c2a4 Mon Sep 17 00:00:00 2001 From: Sergiu Deitsch Date: Tue, 21 Dec 2021 10:47:24 +0100 Subject: [PATCH] ensure _Unwind_Backtrace to actually be available --- CMakeLists.txt | 4 ++++ bazel/glog.bzl | 2 +- src/config.h.cmake.in | 3 +++ src/{stacktrace_x86_64-inl.h => stacktrace_unwind-inl.h} | 0 src/utilities.h | 4 ++-- 5 files changed, 10 insertions(+), 3 deletions(-) rename src/{stacktrace_x86_64-inl.h => stacktrace_unwind-inl.h} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index f166f7b..8cce87d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,6 +94,10 @@ if (Unwind_FOUND) set (HAVE_LIB_UNWIND 1) else (Unwind_FOUND) check_include_file_cxx (unwind.h HAVE_UNWIND_H) + # Check whether linking actually succeeds. ARM toolchains of LLVM unwind + # implementation do not necessarily provide the _Unwind_Backtrace function + # which causes the previous check to succeed but the linking to fail. + check_cxx_symbol_exists (_Unwind_Backtrace unwind.h HAVE__UNWIND_BACKTRACE) endif (Unwind_FOUND) check_include_file_cxx (dlfcn.h HAVE_DLFCN_H) diff --git a/bazel/glog.bzl b/bazel/glog.bzl index 1392bfb..43a2637 100644 --- a/bazel/glog.bzl +++ b/bazel/glog.bzl @@ -128,9 +128,9 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs): "src/stacktrace_generic-inl.h", "src/stacktrace_libunwind-inl.h", "src/stacktrace_powerpc-inl.h", + "src/stacktrace_unwind-inl.h", "src/stacktrace_windows-inl.h", "src/stacktrace_x86-inl.h", - "src/stacktrace_x86_64-inl.h", "src/symbolize.cc", "src/symbolize.h", "src/utilities.cc", diff --git a/src/config.h.cmake.in b/src/config.h.cmake.in index ca278ad..b225b7e 100644 --- a/src/config.h.cmake.in +++ b/src/config.h.cmake.in @@ -118,6 +118,9 @@ /* Define if you have the header file. */ #cmakedefine HAVE_UNWIND_H +/* Define if you linking to _Unwind_Backtrace is possible. */ +#cmakedefine HAVE__UNWIND_BACKTRACE + /* define if the compiler supports using expression for operator */ #cmakedefine HAVE_USING_OPERATOR diff --git a/src/stacktrace_x86_64-inl.h b/src/stacktrace_unwind-inl.h similarity index 100% rename from src/stacktrace_x86_64-inl.h rename to src/stacktrace_unwind-inl.h diff --git a/src/utilities.h b/src/utilities.h index bd818dc..1f55eff 100644 --- a/src/utilities.h +++ b/src/utilities.h @@ -88,8 +88,8 @@ #if defined(HAVE_LIB_UNWIND) # define STACKTRACE_H "stacktrace_libunwind-inl.h" -#elif defined(HAVE_UNWIND_H) -# define STACKTRACE_H "stacktrace_x86_64-inl.h" +#elif defined(HAVE__UNWIND_BACKTRACE) +# define STACKTRACE_H "stacktrace_unwind-inl.h" #elif !defined(NO_FRAME_POINTER) # if defined(__i386__) && __GNUC__ >= 2 # define STACKTRACE_H "stacktrace_x86-inl.h"