Commit 0676e68c authored by Erik de Castro Lopo's avatar Erik de Castro Lopo
Browse files

Fix detection and use of `USE_LIBDW`

Test Plan: Configure/build with and without --enable-libdw

Reviewers: trofi, hvr, austin, simonmar, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2276
parent 930e74f8
......@@ -1092,14 +1092,22 @@ AC_DEFINE_UNQUOTED([RTS_LINKER_USE_MMAP], [$RtsLinkerUseMmap],
dnl ** Have libdw?
dnl --------------------------------------------------------------
AC_ARG_ENABLE(libdw,
UseLibdw=NO
USE_LIBDW=0
AC_ARG_ENABLE(dwarf-unwind,
[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_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
......
......@@ -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
......
......@@ -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),@HaveLibdw@,NO))
GhcRtsWithLibdw=$(strip $(if $(filter $(TargetArch_CPP),i386 x86_64),@UseLibdw@,NO))
################################################################################
#
......
......@@ -10,7 +10,7 @@
#include "RtsUtils.h"
#include "Libdw.h"
#ifdef USE_LIBDW
#if USE_LIBDW
#include <elfutils/libdwfl.h>
#include <dwarf.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);
......
......@@ -10,7 +10,7 @@
#include "RtsUtils.h"
#include "LibdwPool.h"
#ifdef USE_LIBDW
#if USE_LIBDW
#include <unistd.h>
......
......@@ -14,7 +14,7 @@
#include "Rts.h"
#include "Libdw.h"
#ifdef USE_LIBDW
#if USE_LIBDW
/* Initialize the pool */
void libdwPoolInit(void);
......
......@@ -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
......
......@@ -61,7 +61,7 @@ unresolved symbols. */
,"mingwex"
# endif
#endif
#ifdef USE_LIBDW
#if USE_LIBDW
, "elf"
, "dw" /* for backtraces */
#endif
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment