]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Check for _Unwind_Backtrace() support
authorMichał Kępień <michal@isc.org>
Fri, 30 Oct 2020 08:12:50 +0000 (09:12 +0100)
committerMichał Kępień <michal@isc.org>
Fri, 30 Oct 2020 08:12:50 +0000 (09:12 +0100)
Some operating systems (e.g. Linux, FreeBSD) provide the
_Unwind_Backtrace() function in libgcc_s.so, which is automatically
linked into any binary using the functions provided by that library.  On
OpenBSD, though, _Unwind_Backtrace() is provided by libc++abi.so, which
is not automatically linked into binaries produced by the stock system C
compiler.

Meanwhile, lib/isc/backtrace.c assumes that any GNU-compatible toolchain
allows _Unwind_Backtrace() to be used without any extra provisions in
the build system.  This causes build failures on OpenBSD (and possibly
other systems).

Instead of making assumptions, actually check for _Unwind_Backtrace()
support in the toolchain if the backtrace() function is unavailable.

config.h.in
configure
configure.ac
lib/isc/backtrace.c

index e789acda6709b170d3b1a8852a31ab1f72b69673..ae5604c81b0c852ba3925e3296744e6105fd47df 100644 (file)
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
+/* define if the compiler supports _Unwind_Backtrace() */
+#undef HAVE_UNWIND_BACKTRACE
+
 /* Define to 1 if you have the `usleep' function. */
 #undef HAVE_USLEEP
 
index a408f0dcf6159f49da853e9e6841030eebb70daa..401a6e70a596d1e2bf22429614fa077805f14757 100755 (executable)
--- a/configure
+++ b/configure
@@ -19170,6 +19170,27 @@ if ac_fn_c_try_link "$LINENO"; then :
 
 $as_echo "#define HAVE_LIBCTRACE 1" >>confdefs.h
 
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stddef.h>
+int
+main ()
+{
+return _Unwind_Backtrace(NULL, NULL);
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+$as_echo "#define HAVE_UNWIND_BACKTRACE 1" >>confdefs.h
+
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
 
 fi
 rm -f core conftest.err conftest.$ac_objext \
index 1201b5e2a799ca235757b949a045122347288e2d..4a7c6f967e12f7f995a76a279c834757c482ae02 100644 (file)
@@ -1547,7 +1547,14 @@ AS_IF([test "$enable_backtrace" = "yes"],
            [[#include <execinfo.h>]],
            [[return (backtrace((void **)0, 0));]]
          )],
-        [AC_DEFINE([HAVE_LIBCTRACE], [1], [define if system have backtrace function])]
+        [AC_DEFINE([HAVE_LIBCTRACE], [1], [define if system have backtrace function])],
+        [AC_LINK_IFELSE(
+           [AC_LANG_PROGRAM(
+              [[#include <stddef.h>]],
+              [[return _Unwind_Backtrace(NULL, NULL);]]
+            )],
+           [AC_DEFINE([HAVE_UNWIND_BACKTRACE], [1], [define if the compiler supports _Unwind_Backtrace()])]
+         )]
        )])
 
 # [pairwise: --enable-symtable, --disable-symtable]
index 080f32c036a9ce438b85074a58c443c789a6ac44..cf46e6374302440c3a41cc671afc026b254d914d 100644 (file)
@@ -40,7 +40,7 @@
  */
 #ifdef HAVE_LIBCTRACE
 #define BACKTRACE_LIBC
-#elif defined(__GNUC__) && (defined(__x86_64__) || defined(__ia64__))
+#elif defined(HAVE_UNWIND_BACKTRACE)
 #define BACKTRACE_GCC
 #elif defined(WIN32)
 #define BACKTRACE_WIN32