prefer backtrace() on OSX

It seems to work and _Unwind_Backtrace which is configured otherwise
doesn't.
This commit is contained in:
Aliaksey Kandratsenka 2021-02-28 17:52:17 -08:00
parent a015377a54
commit c2f60400a8
3 changed files with 17 additions and 4 deletions

View File

@ -65,7 +65,7 @@ include(PCFromUContext)
define_target_variables()
# Currently only backtrace works on s390.
if(s390)
if(s390 OR OSX)
set(default_enable_libunwind OFF)
set(default_enable_backtrace ON)
else()
@ -308,6 +308,9 @@ check_c_source_compiles("
#include <unwind.h>
int main()
{
#if __APPLE__
#error OSX _Unwind_Backtrace recurses back to malloc
#endif
&_Unwind_Backtrace;
return 0;
}"

View File

@ -11,4 +11,5 @@ macro(define_target_variables)
check_cxx_source_compiles("int main() { return __FreeBSD__; }" FreeBSD)
check_cxx_source_compiles("int main() { return __MINGW__; }" MINGW)
check_cxx_source_compiles("int main() { return __linux; }" LINUX)
check_cxx_source_compiles("int main() { return __APPLE__; }" OSX)
endmacro()

View File

@ -55,8 +55,13 @@ case "$host" in
*-darwin*) default_enable_heap_checker=no;;
esac
# Currently only backtrace works on s390.
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [return __s390__])],
# Currently only backtrace works on s390 and OSX.
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [
#if !defined(__s390__) && !defined(__APPLE__)
#error not s390 and not osx
#endif
return 1
])],
[default_enable_libunwind=no
default_enable_backtrace=yes],
[default_enable_libunwind=yes
@ -416,7 +421,11 @@ AC_CACHE_CHECK([if target has _Unwind_Backtrace],
[perftools_cv_have_unwind_backtrace],
[AC_LANG_PUSH(C++)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[#include <unwind.h>]],
[[#include <unwind.h>
#if defined(__APPLE__)
#error OSX _Unwind_Backtrace recurses back to malloc
#endif
]],
[[&_Unwind_Backtrace]])],
[perftools_cv_have_unwind_backtrace=yes],
[perftools_cv_have_unwind_backtrace=no])