Commit ce9e2a1a authored by Ben Gamari's avatar Ben Gamari 🐢 Committed by Marge Bot

configure: Add --with-libdw-{includes,libraries} flags

Fixing #17255.
parent 3ce18700
Pipeline #12295 passed with stages
in 488 minutes and 46 seconds
......@@ -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)
......
......@@ -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.
......
......@@ -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:
#=======================
......
......@@ -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"
......
......@@ -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 ]
......
......@@ -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" ]
......
......@@ -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))
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
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