libdw: More precise version check
authorBen Gamari <bgamari.foss@gmail.com>
Fri, 15 Apr 2016 09:43:41 +0000 (11:43 +0200)
committerBen Gamari <ben@smart-cactus.org>
Fri, 15 Apr 2016 22:21:41 +0000 (00:21 +0200)
Test Plan: Try configure in an environment with older `libdw`

Reviewers: hvr, austin

Subscribers: thomie, erikd

Differential Revision: https://phabricator.haskell.org/D2103

GHC Trac Issues: #11820

configure.ac
distrib/configure.ac.in

index ff717a1..dd3236c 100644 (file)
@@ -1052,7 +1052,14 @@ if test "$use_large_address_space" = "yes" ; then
    AC_DEFINE([USE_LARGE_ADDRESS_SPACE], [1], [Enable single heap address space support])
 fi
 
-AC_CHECK_LIB(dw, dwfl_begin, [HaveLibdw=YES], [HaveLibdw=NO])
+dnl ** Have libdw?
+dnl --------------------------------------------------------------
+AC_ARG_ENABLE(libdw,
+    [AC_HELP_STRING([--enable-dwarf-unwind],
+        [Enable DWARF unwinding support in the runtime system via elfutils' libdw [default=no]])],
+    [AC_CHECK_LIB(dw, dwfl_attach_state, [HaveLibdw=YES], [HaveLibdw=NO])],
+    [HaveLibdw=NO]
+)
 AC_SUBST(HaveLibdw)
 
 if test -n "$SPHINXBUILD"; then
index 1df58d5..c0610c6 100644 (file)
@@ -93,8 +93,14 @@ AC_SUBST([LdCmd])
 
 dnl ** Have libdw?
 dnl --------------------------------------------------------------
-AC_CHECK_LIB(dw, dwfl_begin, [HaveLibdw=YES], [HaveLibdw=NO])
-AC_SUBST(HaveLibdw)
+dnl Check for a usable version of libdw/elfutils
+dnl Currently we need 0.158 or newer.
+BinDistNeedsLibdw=@HaveLibdw@
+if test "x$BinDistNeedsLibdw" = "xyes" ; then
+    AC_CHECK_LIB(dw, dwfl_attach_state, [HaveLibdw=YES],
+        [AC_MSG_ERROR([Binary distribution was built with libdw support but target system doesn't have supported libdw version (needs at least 0.158)])]
+    )];
+fi
 
 FP_GCC_VERSION
 AC_PROG_CPP