configure: Add --with-libdw-{includes,libraries} flags
authorBen Gamari <ben@smart-cactus.org>
Thu, 26 Sep 2019 20:06:28 +0000 (16:06 -0400)
committerMarge Bot <ben+marge-bot@smart-cactus.org>
Wed, 6 Nov 2019 13:05:57 +0000 (08:05 -0500)
Fixing #17255.

configure.ac
distrib/configure.ac.in
hadrian/cfg/system.config.in
hadrian/src/Oracles/Setting.hs
hadrian/src/Settings/Builders/Common.hs
hadrian/src/Settings/Packages.hs
mk/config.mk.in
rts/ghc.mk
rts/package.conf.in
rts/rts.cabal.in

index f86ce4c..68e4466 100644 (file)
@@ -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)
index aa3470a..027df47 100644 (file)
@@ -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.
index 6c78f43..b531bd8 100644 (file)
@@ -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:
 #=======================
 
index d8156f7..569d9a4 100644 (file)
@@ -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"
index 2c41d92..5421972 100644 (file)
@@ -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 ]
index 0f1ae64..4d399ca 100644 (file)
@@ -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" ]
 
index 50b8aef..eff6b36 100644 (file)
@@ -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))
index 5bd830d..f25f2f9 100644 (file)
@@ -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
 
index ce3146b..93b664a 100644 (file)
@@ -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
index 4b5d837..b9a67c7 100644 (file)
@@ -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