Index: cmake/config-ix.cmake =================================================================== --- cmake/config-ix.cmake +++ cmake/config-ix.cmake @@ -165,6 +165,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 @@ -46,8 +46,8 @@ #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 -// with . +// despite the function not existing unless _GNU_SOURCE is defined, and +// on Android, conflicts with . #ifdef __GLIBC__ #include #else