[commit: ghc] wip/erikd/rts: Fix detection and use of `USE_LIBDW` (fd0d0fc)
git at git.haskell.org
git at git.haskell.org
Sun May 29 08:01:16 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/erikd/rts
Link : http://ghc.haskell.org/trac/ghc/changeset/fd0d0fc14d5329dab4bcff515941ba3499c4326c/ghc
>---------------------------------------------------------------
commit fd0d0fc14d5329dab4bcff515941ba3499c4326c
Author: Erik de Castro Lopo <erikd at mega-nerd.com>
Date: Sat May 28 21:19:49 2016 +1000
Fix detection and use of `USE_LIBDW`
Test Plan: Configure/build with and without --enable-libdw
Reviewers: bgamari, hvr, trofi, austin, simonmar
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2276
>---------------------------------------------------------------
fd0d0fc14d5329dab4bcff515941ba3499c4326c
configure.ac | 18 +++++++++++++-----
distrib/configure.ac.in | 4 ++--
mk/config.mk.in | 2 +-
rts/Libdw.c | 2 +-
rts/Libdw.h | 2 +-
rts/LibdwPool.c | 2 +-
rts/LibdwPool.h | 2 +-
rts/ghc.mk | 8 --------
rts/package.conf.in | 2 +-
rts/posix/Signals.c | 2 +-
10 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/configure.ac b/configure.ac
index 4adf9c5..e0bc755 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1092,14 +1092,22 @@ AC_DEFINE_UNQUOTED([RTS_LINKER_USE_MMAP], [$RtsLinkerUseMmap],
dnl ** Have libdw?
dnl --------------------------------------------------------------
+UseLibdw=NO
+USE_LIBDW=0
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_HELP_STRING([--enable-libdw],
+ [Enable DWARF debugging support in the runtime system [default=no]])],
+ [AC_CHECK_LIB(dw, dwfl_attach_state, [UseLibdw=YES], [UseLibdw=NO])],
+ [UseLibdw=NO]
)
-AC_SUBST(HaveLibdw)
+AC_SUBST(UseLibdw)
+if test $UseLibdw = "YES" ; then
+ USE_LIBDW=1
+fi
+AC_DEFINE_UNQUOTED([USE_LIBDW], [$USE_LIBDW], [Set to 1 to use libdw])
+dnl ** Documentation
+dnl --------------------------------------------------------------
if test -n "$SPHINXBUILD"; then
BUILD_MAN=YES
BUILD_SPHINX_HTML=YES
diff --git a/distrib/configure.ac.in b/distrib/configure.ac.in
index fdd9fd9..33023a7 100644
--- a/distrib/configure.ac.in
+++ b/distrib/configure.ac.in
@@ -93,9 +93,9 @@ dnl ** Have libdw?
dnl --------------------------------------------------------------
dnl Check for a usable version of libdw/elfutils
dnl Currently we need 0.158 or newer.
-BinDistNeedsLibdw=@HaveLibdw@
+BinDistNeedsLibdw=@UseLibdw@
if test "x$BinDistNeedsLibdw" = "xyes" ; then
- AC_CHECK_LIB(dw, dwfl_attach_state, [HaveLibdw=YES],
+ AC_CHECK_LIB(dw, dwfl_attach_state, [UseLibdw=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
diff --git a/mk/config.mk.in b/mk/config.mk.in
index 5dbde02..47198b9 100644
--- a/mk/config.mk.in
+++ b/mk/config.mk.in
@@ -381,7 +381,7 @@ FFIIncludeDir=@FFIIncludeDir@
# GHC needs arch-specific tweak at least in
# rts/Libdw.c:set_initial_registers()
-GhcRtsWithLibdw=$(strip $(if $(filter $(TargetArch_CPP),i386 x86_64), at HaveLibdw@,NO))
+GhcRtsWithLibdw=$(strip $(if $(filter $(TargetArch_CPP),i386 x86_64), at UseLibdw@,NO))
################################################################################
#
diff --git a/rts/Libdw.c b/rts/Libdw.c
index e796840..a16ea59 100644
--- a/rts/Libdw.c
+++ b/rts/Libdw.c
@@ -10,7 +10,7 @@
#include "RtsUtils.h"
#include "Libdw.h"
-#ifdef USE_LIBDW
+#if USE_LIBDW
#include <elfutils/libdwfl.h>
#include <dwarf.h>
diff --git a/rts/Libdw.h b/rts/Libdw.h
index e5fa054..bb3e71b 100644
--- a/rts/Libdw.h
+++ b/rts/Libdw.h
@@ -16,7 +16,7 @@
#include "BeginPrivate.h"
-#ifdef USE_LIBDW
+#if USE_LIBDW
/* Begin a libdw session. A session is tied to a particular capability */
LibdwSession *libdwInit(void);
diff --git a/rts/LibdwPool.c b/rts/LibdwPool.c
index 2363212..8d065c3 100644
--- a/rts/LibdwPool.c
+++ b/rts/LibdwPool.c
@@ -10,7 +10,7 @@
#include "RtsUtils.h"
#include "LibdwPool.h"
-#ifdef USE_LIBDW
+#if USE_LIBDW
#include <unistd.h>
diff --git a/rts/LibdwPool.h b/rts/LibdwPool.h
index a6b670e..3c4216d 100644
--- a/rts/LibdwPool.h
+++ b/rts/LibdwPool.h
@@ -14,7 +14,7 @@
#include "Rts.h"
#include "Libdw.h"
-#ifdef USE_LIBDW
+#if USE_LIBDW
/* Initialize the pool */
void libdwPoolInit(void);
diff --git a/rts/ghc.mk b/rts/ghc.mk
index 6fdc2cc..2dd1b85 100644
--- a/rts/ghc.mk
+++ b/rts/ghc.mk
@@ -480,14 +480,6 @@ rts_PACKAGE_CPP_OPTS += '-DFFI_LIB="C$(LIBFFI_NAME)"'
endif
-#-----------------------------------------------------------------------------
-# Add support for reading DWARF debugging information, if available
-
-ifeq "$(GhcRtsWithLibdw)" "YES"
-rts_CC_OPTS += -DUSE_LIBDW
-rts_PACKAGE_CPP_OPTS += -DUSE_LIBDW
-endif
-
# -----------------------------------------------------------------------------
# dependencies
diff --git a/rts/package.conf.in b/rts/package.conf.in
index 5c6d240..b52a867 100644
--- a/rts/package.conf.in
+++ b/rts/package.conf.in
@@ -61,7 +61,7 @@ unresolved symbols. */
,"mingwex"
# endif
#endif
-#ifdef USE_LIBDW
+#if USE_LIBDW
, "elf"
, "dw" /* for backtraces */
#endif
diff --git a/rts/posix/Signals.c b/rts/posix/Signals.c
index 496ec7b..d73143b 100644
--- a/rts/posix/Signals.c
+++ b/rts/posix/Signals.c
@@ -536,7 +536,7 @@ shutdown_handler(int sig STG_UNUSED)
static void
backtrace_handler(int sig STG_UNUSED)
{
-#ifdef USE_LIBDW
+#if USE_LIBDW
LibdwSession *session = libdwInit();
Backtrace *bt = libdwGetBacktrace(session);
libdwPrintBacktrace(session, stderr, bt);
More information about the ghc-commits
mailing list