Index: cmake/config-ix.cmake =================================================================== --- cmake/config-ix.cmake +++ cmake/config-ix.cmake @@ -147,6 +147,9 @@ # function checks check_symbol_exists(arc4random "stdlib.h" HAVE_DECL_ARC4RANDOM) +if(CMAKE_SYSTEM MATCHES "FreeBSD") + list(APPEND CMAKE_REQUIRED_LIBRARIES "execinfo") +endif() check_symbol_exists(backtrace "execinfo.h" HAVE_BACKTRACE) check_symbol_exists(_Unwind_Backtrace "unwind.h" HAVE__UNWIND_BACKTRACE) check_symbol_exists(getpagesize unistd.h HAVE_GETPAGESIZE) Index: lib/Support/CMakeLists.txt =================================================================== --- lib/Support/CMakeLists.txt +++ lib/Support/CMakeLists.txt @@ -24,6 +24,9 @@ if( UNIX AND NOT (BEOS OR HAIKU) ) set(system_libs ${system_libs} m) endif() + if (HAVE_BACKTRACE AND CMAKE_SYSTEM MATCHES "FreeBSD") + set(system_libs ${system_libs} execinfo) + endif() endif( MSVC OR MINGW ) add_llvm_library(LLVMSupport Index: lib/Support/Unix/Signals.inc =================================================================== --- lib/Support/Unix/Signals.inc +++ lib/Support/Unix/Signals.inc @@ -45,11 +45,15 @@ #endif #ifdef HAVE__UNWIND_BACKTRACE // FIXME: We should be able to use for any target that has an -// _Unwind_Backtrace function, but on FreeBSD the configure test passes -// despite the function not existing, and on Android, conflicts +// _Unwind_Backtrace function, but on Android, conflicts // with . #if defined(__GLIBC__) || defined(__APPLE__) #include +#elif defined(__FreeBSD__) +// On FreeBSD we are including unwind.h from libcxxrt which requires +// _GNU_SOURCE to make _Unwind_Backtrace visible +#define _GNU_SOURCE +#include #else #undef HAVE__UNWIND_BACKTRACE #endif