1dnl 2dnl Checks for libunwind, which usually does a better job than backtrace() when 3dnl resolving symbols in the stack backtrace. Newer versions have support for 4dnl getting info about the object file the function came from, so we look for 5dnl that too and use it if found. 6dnl 7AC_DEFUN([ZFS_AC_CONFIG_USER_LIBUNWIND], [ 8 AC_ARG_WITH([libunwind], 9 AS_HELP_STRING([--with-libunwind], 10 [use libunwind for backtraces in userspace assertions]), 11 [], 12 [with_libunwind=auto]) 13 14 AS_IF([test "x$with_libunwind" != "xno"], [ 15 ZFS_AC_FIND_SYSTEM_LIBRARY(LIBUNWIND, [libunwind], [libunwind.h], [], [unwind], [], [ 16 dnl unw_get_elf_filename() is sometimes a macro, other 17 dnl times a proper symbol, so we can't just do a link 18 dnl check; we need to include the header properly. 19 AX_SAVE_FLAGS 20 CFLAGS="$CFLAGS $LIBUNWIND_CFLAGS" 21 LIBS="$LIBS $LIBUNWIND_LIBS" 22 AC_MSG_CHECKING([for unw_get_elf_filename in libunwind]) 23 AC_LINK_IFELSE([ 24 AC_LANG_PROGRAM([ 25 #define UNW_LOCAL_ONLY 26 #include <libunwind.h> 27 ], [ 28 unw_get_elf_filename(0, 0, 0, 0); 29 ]) 30 ], [ 31 AC_MSG_RESULT([yes]) 32 AC_DEFINE(HAVE_LIBUNWIND_ELF, 1, 33 [libunwind has unw_get_elf_filename]) 34 ], [ 35 AC_MSG_RESULT([no]) 36 ]) 37 dnl LLVM includes it's own libunwind library, which 38 dnl defines the highest numbered register in a different 39 dnl way, and has an incompatible unw_resname function. 40 AC_MSG_CHECKING([whether libunwind is llvm libunwind]) 41 AC_COMPILE_IFELSE([ 42 AC_LANG_PROGRAM([ 43 #include <libunwind.h> 44 #if !defined(_LIBUNWIND_HIGHEST_DWARF_REGISTER) 45 #error "_LIBUNWIND_HIGHEST_DWARF_REGISTER is not defined" 46 #endif 47 ], [])], [ 48 AC_MSG_RESULT([yes]) 49 AC_DEFINE(IS_LIBUNWIND_LLVM, 1, [libunwind is llvm libunwind]) 50 ], [ 51 AC_MSG_RESULT([no]) 52 ]) 53 AX_RESTORE_FLAGS 54 ], [ 55 AS_IF([test "x$with_libunwind" = "xyes"], [ 56 AC_MSG_FAILURE([--with-libunwind was given, but libunwind is not available, try installing libunwind-devel]) 57 ]) 58 ]) 59 ]) 60]) 61