From 29e1fcfa0517a7c5770b2a95fe7fbc0bc197c360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Sun, 16 May 2021 20:45:09 +0200 Subject: Use libunwind for printing backtrace --- configure.ac | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index e93afbd9..b6361ead 100644 --- a/configure.ac +++ b/configure.ac @@ -253,6 +253,7 @@ AC_SEARCH_LIBS([clock_gettime], [rt]) AC_CHECK_FUNCS([ \ clock_gettime \ + dladdr \ faccessat \ fstatat \ host_get_clock_service \ @@ -261,9 +262,6 @@ AC_CHECK_FUNCS([ \ readlinkat \ ]) -# Add -lexecinfo if needed -AC_SEARCH_LIBS([backtrace], [execinfo]) - if test "$my_htop_platform" = darwin; then AC_CHECK_FUNCS([mach_timebase_info]) fi @@ -409,6 +407,36 @@ if test "x$enable_affinity" = xyes; then fi +AC_ARG_ENABLE([unwind], + [AS_HELP_STRING([--enable-unwind], + [enable unwind support for printing backtraces; requires libunwind @<:@default=check@:>@])], + [], + [enable_unwind=check]) +case "$enable_unwind" in + check) + enable_unwind=yes + if test "$enable_static" = yes; then + AC_CHECK_LIB([lzma], [lzma_index_buffer_decode]) + fi + AC_CHECK_LIB([unwind], [backtrace], [], [enable_unwind=no]) + AC_CHECK_HEADERS([libunwind.h], [], [enable_unwind=no]) + ;; + no) + ;; + yes) + AC_CHECK_LIB([unwind], [backtrace], [], [AC_MSG_ERROR([can not find required library libunwind])]) + AC_CHECK_HEADERS([libunwind.h], [], [AC_MSG_ERROR([can not find require header file libunwind.h])]) + ;; + *) + AC_MSG_ERROR([bad value '$enable_unwind' for --enable-unwind]) + ;; +esac +if test "x$enable_unwind" = xno; then + # Fall back to backtrace(3) and add -lexecinfo if needed + AC_SEARCH_LIBS([backtrace], [execinfo]) +fi + + AC_ARG_ENABLE([hwloc], [AS_HELP_STRING([--enable-hwloc], [enable hwloc support for CPU affinity; disables affinity support; requires libhwloc @<:@default=no@:>@])], @@ -426,6 +454,7 @@ case "$enable_hwloc" in ;; esac + AC_ARG_WITH([os-release], [AS_HELP_STRING([--with-os-release=FILE], [location of an os-release file @<:@default=/etc/os-release@:>@])], @@ -715,6 +744,7 @@ AC_MSG_RESULT([ (Linux) capabilities: $enable_capabilities unicode: $enable_unicode affinity: $enable_affinity + unwind: $enable_unwind hwloc: $enable_hwloc debug: $enable_debug static: $enable_static -- cgit v1.2.3