summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-09-26 16:06:28 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-11-06 08:05:57 -0500
commitce9e2a1a9307bf43ead278dd1fc8db4325d82340 (patch)
treebd134ac511b2d20755290d9b63505cffeb2a9518
parent3ce18700f80a12c48a029b49c6201ad2410071bb (diff)
downloadhaskell-ce9e2a1a9307bf43ead278dd1fc8db4325d82340.tar.gz
configure: Add --with-libdw-{includes,libraries} flags
Fixing #17255.
-rw-r--r--configure.ac33
-rw-r--r--distrib/configure.ac.in4
-rw-r--r--hadrian/cfg/system.config.in3
-rw-r--r--hadrian/src/Oracles/Setting.hs4
-rw-r--r--hadrian/src/Settings/Builders/Common.hs2
-rw-r--r--hadrian/src/Settings/Packages.hs6
-rw-r--r--mk/config.mk.in3
-rw-r--r--rts/ghc.mk6
-rw-r--r--rts/package.conf.in4
-rw-r--r--rts/rts.cabal.in1
10 files changed, 62 insertions, 4 deletions
diff --git a/configure.ac b/configure.ac
index f86ce4c8a3..68e44661ef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1221,15 +1221,46 @@ AC_DEFINE_UNQUOTED([RTS_LINKER_USE_MMAP], [$RtsLinkerUseMmap],
dnl ** Have libdw?
dnl --------------------------------------------------------------
+AC_ARG_WITH([libdw-libraries],
+ [AC_HELP_STRING([--with-libdw-libraries=ARG],
+ [Find libraries for libdw in ARG [default=system default]])
+ ],
+ [
+ LibdwLibDir="$withval"
+ LIBDW_LDFLAGS="-L$withval"
+ ])
+
+AC_SUBST(LibdwLibDir)
+
+AC_ARG_WITH([libdw-includes],
+ [AC_HELP_STRING([--with-libdw-includes=ARG],
+ [Find includes for libdw in ARG [default=system default]])
+ ],
+ [
+ LibdwIncludeDir="$withval"
+ LIBDW_CFLAGS="-I$withval"
+ ])
+
+AC_SUBST(LibdwIncludeDir)
+
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]])])
if test "$enable_dwarf_unwind" = "yes" ; then
+ CFLAGS2="$CFLAGS"
+ CFLAGS="$LIBDW_CFLAGS $CFLAGS"
+ LDFLAGS2="$LDFLAGS"
+ LDFLAGS="$LIBDW_LDFLAGS $LDFLAGS"
+
AC_CHECK_LIB(dw, dwfl_attach_state,
- [UseLibdw=YES],
+ [AC_CHECK_HEADERS([elfutils/libdw.h], [break], [])
+ UseLibdw=YES],
[AC_MSG_ERROR([Cannot find system libdw (required by --enable-dwarf-unwind)])])
+
+ CFLAGS="$CFLAGS2"
+ LDFLAGS="$LDFLAGS2"
fi
AC_SUBST(UseLibdw)
diff --git a/distrib/configure.ac.in b/distrib/configure.ac.in
index aa3470a9b1..027df47db8 100644
--- a/distrib/configure.ac.in
+++ b/distrib/configure.ac.in
@@ -26,6 +26,10 @@ FFILibDir=@FFILibDir@
AC_SUBST(FFILibDir)
AC_SUBST(FFIIncludeDir)
+LibdwIncludeDir=@LibdwIncludeDir@
+LibdwLibDir=@LibdwLibDir@
+AC_SUBST(LibdwLibDir)
+AC_SUBST(LibdwIncludeDir)
# We have to run these unconditionally as FPTOOLS_SET_PLATFORM_VARS wants the
# values it computes.
diff --git a/hadrian/cfg/system.config.in b/hadrian/cfg/system.config.in
index 6c78f43ccb..b531bd8c31 100644
--- a/hadrian/cfg/system.config.in
+++ b/hadrian/cfg/system.config.in
@@ -169,6 +169,9 @@ use-system-ffi = @UseSystemLibFFI@
ffi-include-dir = @FFIIncludeDir@
ffi-lib-dir = @FFILibDir@
+libdw-include-dir = @LibdwIncludeDir@
+libdw-lib-dir = @LibdwLibDir@
+
# Optional Dependencies:
#=======================
diff --git a/hadrian/src/Oracles/Setting.hs b/hadrian/src/Oracles/Setting.hs
index d8156f778f..569d9a4ed4 100644
--- a/hadrian/src/Oracles/Setting.hs
+++ b/hadrian/src/Oracles/Setting.hs
@@ -54,6 +54,8 @@ data Setting = BuildArch
| HostOsHaskell
| IconvIncludeDir
| IconvLibDir
+ | LibdwIncludeDir
+ | LibdwLibDir
| LlvmTarget
| ProjectGitCommitId
| ProjectName
@@ -141,6 +143,8 @@ setting key = lookupValueOrError configFile $ case key of
HostOsHaskell -> "host-os-haskell"
IconvIncludeDir -> "iconv-include-dir"
IconvLibDir -> "iconv-lib-dir"
+ LibdwIncludeDir -> "libdw-include-dir"
+ LibdwLibDir -> "libdw-lib-dir"
LlvmTarget -> "llvm-target"
ProjectGitCommitId -> "project-git-commit-id"
ProjectName -> "project-name"
diff --git a/hadrian/src/Settings/Builders/Common.hs b/hadrian/src/Settings/Builders/Common.hs
index 2c41d92493..5421972659 100644
--- a/hadrian/src/Settings/Builders/Common.hs
+++ b/hadrian/src/Settings/Builders/Common.hs
@@ -29,12 +29,14 @@ cIncludeArgs = do
iconvIncludeDir <- getSetting IconvIncludeDir
gmpIncludeDir <- getSetting GmpIncludeDir
ffiIncludeDir <- getSetting FfiIncludeDir
+ libdwIncludeDir <- getSetting FfiIncludeDir
libPath <- expr $ stageLibPath stage
mconcat [ notStage0 ||^ package compiler ? arg "-Iincludes"
, arg $ "-I" ++ libPath
, arg $ "-I" ++ path
, pure . map ("-I"++) . filter (/= "") $ [iconvIncludeDir, gmpIncludeDir]
, flag UseSystemFfi ? arg ("-I" ++ ffiIncludeDir)
+ , flag WithLibdw ? if not (null libdwIncludeDir) then arg ("-I" ++ libdwIncludeDir) else mempty
-- Add @incDirs@ in the build directory, since some files generated
-- with @autoconf@ may end up in the build directory.
, pure [ "-I" ++ path -/- dir | dir <- incDirs ]
diff --git a/hadrian/src/Settings/Packages.hs b/hadrian/src/Settings/Packages.hs
index 0f1ae6426a..4d399ca9f0 100644
--- a/hadrian/src/Settings/Packages.hs
+++ b/hadrian/src/Settings/Packages.hs
@@ -199,11 +199,14 @@ rtsPackageArgs = package rts ? do
libffiName <- expr libffiLibraryName
ffiIncludeDir <- getSetting FfiIncludeDir
ffiLibraryDir <- getSetting FfiLibDir
+ libdwIncludeDir <- getSetting LibdwIncludeDir
+ libdwLibraryDir <- getSetting LibdwLibDir
-- Arguments passed to GHC when compiling C and .cmm sources.
let ghcArgs = mconcat
[ arg "-Irts"
, arg $ "-I" ++ path
+ , flag WithLibdw ? if not (null libdwIncludeDir) then arg ("-I" ++ libdwIncludeDir) else mempty
, arg $ "-DRtsWay=\"rts_" ++ show way ++ "\""
-- Set the namespace for the rts fs functions
, arg $ "-DFS_NAMESPACE=rts"
@@ -320,7 +323,8 @@ rtsPackageArgs = package rts ? do
[ "-DTOP=" ++ show top
, "-DFFI_INCLUDE_DIR=" ++ show ffiIncludeDir
, "-DFFI_LIB_DIR=" ++ show ffiLibraryDir
- , "-DFFI_LIB=" ++ show libffiName ]
+ , "-DFFI_LIB=" ++ show libffiName
+ , "-DLIBDW_LIB_DIR=" ++ show libdwLibraryDir ]
, builder HsCpp ? flag HaveLibMingwEx ? arg "-DHAVE_LIBMINGWEX" ]
diff --git a/mk/config.mk.in b/mk/config.mk.in
index 50b8aef610..eff6b366e9 100644
--- a/mk/config.mk.in
+++ b/mk/config.mk.in
@@ -363,6 +363,9 @@ UseSystemLibFFI=@UseSystemLibFFI@
FFILibDir=@FFILibDir@
FFIIncludeDir=@FFIIncludeDir@
+LibdwLibDir=@LibdwLibDir@
+LibdwIncludeDir=@LibdwIncludeDir@
+
# GHC needs arch-specific tweak at least in
# rts/Libdw.c:set_initial_registers()
GhcRtsWithLibdw=$(strip $(if $(filter $(TargetArch_CPP),i386 x86_64 s390x),@UseLibdw@,NO))
diff --git a/rts/ghc.mk b/rts/ghc.mk
index 5bd830da6f..f25f2f9b75 100644
--- a/rts/ghc.mk
+++ b/rts/ghc.mk
@@ -543,6 +543,12 @@ rts_PACKAGE_CPP_OPTS += '-DFFI_LIB="C$(LIBFFI_NAME)"'
endif
+ifeq "$(UseLibdw)" "YES"
+rts_PACKAGE_CPP_OPTS += -DLIBDW_LIB_DIR=$(LibdwLibDir)
+else
+rts_PACKAGE_CPP_OPTS += -DLIBDW_LIB_DIR=
+endif
+
# -----------------------------------------------------------------------------
# dependencies
diff --git a/rts/package.conf.in b/rts/package.conf.in
index ce3146b4c5..93b664ae61 100644
--- a/rts/package.conf.in
+++ b/rts/package.conf.in
@@ -18,9 +18,9 @@ hidden-modules:
import-dirs:
#if defined(INSTALLING)
-library-dirs: LIB_DIR"/rts" FFI_LIB_DIR
+library-dirs: LIB_DIR"/rts" FFI_LIB_DIR LIBDW_LIB_DIR
#else /* !INSTALLING */
-library-dirs: TOP"/rts/dist/build" FFI_LIB_DIR
+library-dirs: TOP"/rts/dist/build" FFI_LIB_DIR LIBDW_LIB_DIR
#endif
hs-libraries: "HSrts" FFI_LIB
diff --git a/rts/rts.cabal.in b/rts/rts.cabal.in
index 4b5d837c3a..b9a67c7ca1 100644
--- a/rts/rts.cabal.in
+++ b/rts/rts.cabal.in
@@ -115,6 +115,7 @@ library
include-dirs: build ../includes includes
includes/dist-derivedconstants/header @FFIIncludeDir@
+ @LibdwIncludeDir@
includes: Stg.h
install-includes: Cmm.h HsFFI.h MachDeps.h Rts.h RtsAPI.h Stg.h
ghcautoconf.h ghcconfig.h ghcplatform.h ghcversion.h