llvm.org GIT mirror llvm / 944d939
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 Ed Maste 3 years ago
4 changed file(s) with 11 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
4545 check_include_file(dirent.h HAVE_DIRENT_H)
4646 check_include_file(dlfcn.h HAVE_DLFCN_H)
4747 check_include_file(errno.h HAVE_ERRNO_H)
48 check_include_file(execinfo.h HAVE_EXECINFO_H)
4948 check_include_file(fcntl.h HAVE_FCNTL_H)
5049 check_include_file(inttypes.h HAVE_INTTYPES_H)
5150 check_include_file(link.h HAVE_LINK_H)
164163
165164 # function checks
166165 check_symbol_exists(arc4random "stdlib.h" HAVE_DECL_ARC4RANDOM)
167 check_symbol_exists(backtrace "execinfo.h" HAVE_BACKTRACE)
166 find_package(Backtrace)
167 set(HAVE_BACKTRACE ${Backtrace_FOUND})
168 set(BACKTRACE_HEADER ${Backtrace_HEADER})
168169 check_symbol_exists(_Unwind_Backtrace "unwind.h" HAVE__UNWIND_BACKTRACE)
169170 check_symbol_exists(getpagesize unistd.h HAVE_GETPAGESIZE)
170171 check_symbol_exists(sysconf unistd.h HAVE_SYSCONF)
1414
1515 /* Define to 1 if you have the `backtrace' function. */
1616 #cmakedefine HAVE_BACKTRACE ${HAVE_BACKTRACE}
17
18 #define BACKTRACE_HEADER <${BACKTRACE_HEADER}>
1719
1820 /* Define to 1 if you have the header file. */
1921 #cmakedefine HAVE_CRASHREPORTERCLIENT_H
77 endif()
88 if( HAVE_LIBDL )
99 set(system_libs ${system_libs} ${CMAKE_DL_LIBS})
10 endif()
11 if( HAVE_BACKTRACE )
12 set(system_libs ${system_libs} ${Backtrace_LIBRARIES})
1013 endif()
1114 if(LLVM_ENABLE_TERMINFO)
1215 if(HAVE_TERMINFO)
139142 Windows
140143 ${LLVM_MAIN_INCLUDE_DIR}/llvm/ADT
141144 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Support
142
145 ${Backtrace_INCLUDE_DIRS}
143146 LINK_LIBS ${system_libs}
144147 )
145148
2424 #include "llvm/Support/raw_ostream.h"
2525 #include
2626 #include
27 #if HAVE_EXECINFO_H
28 # include // For backtrace().
27 #ifdef HAVE_BACKTRACE
28 # include BACKTRACE_HEADER // For backtrace().
2929 #endif
3030 #if HAVE_SIGNAL_H
3131 #include