summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Maste <emaste@freebsd.org>2017-04-12 13:51:00 +0000
committerEd Maste <emaste@freebsd.org>2017-04-12 13:51:00 +0000
commit944d939ce13980e02d603df3038eb7c4b8feac84 (patch)
tree4bcbfe9c66cec36e663e0ed2341d3cddbe1331db
parent0b09474fe1a4c1519e7a299e79c578cbe5b60a91 (diff)
Fix detection of backtrace() availability on FreeBSD
On FreeBSD backtrace is not part of libc and depends on libexecinfo being available. Instead of using manual checks we can use the builtin CMake module FindBacktrace.cmake to detect availability of backtrace() in a portable way. Patch By: Alex Richardson Differential Revision: https://reviews.llvm.org/D27143 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300062 91177308-0d34-0410-b5e6-96231b3b80d8
-rwxr-xr-xcmake/config-ix.cmake5
-rw-r--r--include/llvm/Config/config.h.cmake2
-rw-r--r--lib/Support/CMakeLists.txt5
-rw-r--r--lib/Support/Unix/Signals.inc4
4 files changed, 11 insertions, 5 deletions
diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake
index e5050018046a..0331d0fa10ab 100755
--- a/cmake/config-ix.cmake
+++ b/cmake/config-ix.cmake
@@ -46,7 +46,6 @@ endfunction()
check_include_file(dirent.h HAVE_DIRENT_H)
check_include_file(dlfcn.h HAVE_DLFCN_H)
check_include_file(errno.h HAVE_ERRNO_H)
-check_include_file(execinfo.h HAVE_EXECINFO_H)
check_include_file(fcntl.h HAVE_FCNTL_H)
check_include_file(inttypes.h HAVE_INTTYPES_H)
check_include_file(link.h HAVE_LINK_H)
@@ -165,7 +164,9 @@ endif()
# function checks
check_symbol_exists(arc4random "stdlib.h" HAVE_DECL_ARC4RANDOM)
-check_symbol_exists(backtrace "execinfo.h" HAVE_BACKTRACE)
+find_package(Backtrace)
+set(HAVE_BACKTRACE ${Backtrace_FOUND})
+set(BACKTRACE_HEADER ${Backtrace_HEADER})
check_symbol_exists(_Unwind_Backtrace "unwind.h" HAVE__UNWIND_BACKTRACE)
check_symbol_exists(getpagesize unistd.h HAVE_GETPAGESIZE)
check_symbol_exists(sysconf unistd.h HAVE_SYSCONF)
diff --git a/include/llvm/Config/config.h.cmake b/include/llvm/Config/config.h.cmake
index 3ee48a0d1ba8..a3c919d39804 100644
--- a/include/llvm/Config/config.h.cmake
+++ b/include/llvm/Config/config.h.cmake
@@ -16,6 +16,8 @@
/* Define to 1 if you have the `backtrace' function. */
#cmakedefine HAVE_BACKTRACE ${HAVE_BACKTRACE}
+#define BACKTRACE_HEADER <${BACKTRACE_HEADER}>
+
/* Define to 1 if you have the <CrashReporterClient.h> header file. */
#cmakedefine HAVE_CRASHREPORTERCLIENT_H
diff --git a/lib/Support/CMakeLists.txt b/lib/Support/CMakeLists.txt
index a46167e8714e..491614b4bf63 100644
--- a/lib/Support/CMakeLists.txt
+++ b/lib/Support/CMakeLists.txt
@@ -9,6 +9,9 @@ elseif( CMAKE_HOST_UNIX )
if( HAVE_LIBDL )
set(system_libs ${system_libs} ${CMAKE_DL_LIBS})
endif()
+ if( HAVE_BACKTRACE )
+ set(system_libs ${system_libs} ${Backtrace_LIBRARIES})
+ endif()
if(LLVM_ENABLE_TERMINFO)
if(HAVE_TERMINFO)
set(system_libs ${system_libs} ${TERMINFO_LIBS})
@@ -140,7 +143,7 @@ add_llvm_library(LLVMSupport
Windows
${LLVM_MAIN_INCLUDE_DIR}/llvm/ADT
${LLVM_MAIN_INCLUDE_DIR}/llvm/Support
-
+ ${Backtrace_INCLUDE_DIRS}
LINK_LIBS ${system_libs}
)
diff --git a/lib/Support/Unix/Signals.inc b/lib/Support/Unix/Signals.inc
index 756d0f5a95e8..88ad21e9806e 100644
--- a/lib/Support/Unix/Signals.inc
+++ b/lib/Support/Unix/Signals.inc
@@ -25,8 +25,8 @@
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <string>
-#if HAVE_EXECINFO_H
-# include <execinfo.h> // For backtrace().
+#ifdef HAVE_BACKTRACE
+# include BACKTRACE_HEADER // For backtrace().
#endif
#if HAVE_SIGNAL_H
#include <signal.h>