summaryrefslogtreecommitdiff
path: root/hadrian/src
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-02-25 10:00:01 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-04-25 10:18:17 -0400
commitb2721819f391ab49871271283f32df54810c4387 (patch)
tree1c9c6158e83ba72efd670902c735834a70f952c3 /hadrian/src
parent53cc93ae3c9b939fff8407ee588dff89f7f92a12 (diff)
downloadhaskell-b2721819f391ab49871271283f32df54810c4387.tar.gz
hadrian: Clean up handling of libffi dependencies
Diffstat (limited to 'hadrian/src')
-rw-r--r--hadrian/src/Rules/Libffi.hs3
-rw-r--r--hadrian/src/Rules/Rts.hs3
-rw-r--r--hadrian/src/Settings/Packages.hs16
3 files changed, 12 insertions, 10 deletions
diff --git a/hadrian/src/Rules/Libffi.hs b/hadrian/src/Rules/Libffi.hs
index e37faee5dc..8e62461202 100644
--- a/hadrian/src/Rules/Libffi.hs
+++ b/hadrian/src/Rules/Libffi.hs
@@ -103,6 +103,9 @@ libffiLocalName force_dynamic = do
libffiLibrary :: FilePath
libffiLibrary = "inst/lib/libffi.a"
+-- | These are the headers that we must package with GHC since foreign export
+-- adjustor code produced by GHC depends upon them.
+-- See Note [Packaging libffi headers] in GHC.Driver.CodeOutput.
libffiHeaderFiles :: [FilePath]
libffiHeaderFiles = ["ffi.h", "ffitarget.h"]
diff --git a/hadrian/src/Rules/Rts.hs b/hadrian/src/Rules/Rts.hs
index a6cd0f15d2..59a337801f 100644
--- a/hadrian/src/Rules/Rts.hs
+++ b/hadrian/src/Rules/Rts.hs
@@ -28,6 +28,7 @@ rtsRules = priority 3 $ do
let buildPath = root -/- buildDir (rtsContext stage)
-- Header files
+ -- See Note [Packaging libffi headers] in GHC.Driver.CodeOutput.
forM_ libffiHeaderFiles $ \header ->
buildPath -/- "include" -/- header %> copyLibffiHeader stage
@@ -46,6 +47,8 @@ withLibffi stage action = needLibffi stage
-- | Copy a header files wither from the system libffi or from the libffi
-- build dir to the rts build dir.
+--
+-- See Note [Packaging libffi headers] in GHC.Driver.CodeOutput.
copyLibffiHeader :: Stage -> FilePath -> Action ()
copyLibffiHeader stage header = do
useSystemFfi <- flag UseSystemFfi
diff --git a/hadrian/src/Settings/Packages.hs b/hadrian/src/Settings/Packages.hs
index 43141610a7..d4b8810810 100644
--- a/hadrian/src/Settings/Packages.hs
+++ b/hadrian/src/Settings/Packages.hs
@@ -6,7 +6,6 @@ import Oracles.Setting
import Oracles.Flag
import Packages
import Settings
-import Rules.Libffi
-- | Package-specific command-line arguments.
packageArgs :: Args
@@ -26,6 +25,8 @@ packageArgs = do
cursesIncludeDir <- getSetting CursesIncludeDir
cursesLibraryDir <- getSetting CursesLibDir
+ ffiIncludeDir <- getSetting FfiIncludeDir
+ ffiLibraryDir <- getSetting FfiLibDir
debugAssertions <- ghcDebugAssertions <$> expr flavour
mconcat
@@ -139,7 +140,8 @@ packageArgs = do
-- the Stage1 libraries, as we already know that the bootstrap
-- compiler comes with the same versions as the one we are building.
--
- builder (Cabal Flags) ? ifM stage0
+ builder (Cabal Setup) ? cabalExtraDirs ffiIncludeDir ffiLibraryDir
+ , builder (Cabal Flags) ? ifM stage0
(andM [cross, bootCross] `cabalFlag` "internal-interpreter")
(arg "internal-interpreter")
@@ -269,7 +271,6 @@ rtsPackageArgs = package rts ? do
path <- getBuildPath
top <- expr topDirectory
useSystemFfi <- expr $ flag UseSystemFfi
- ffiLibName <- libffiName
ffiIncludeDir <- getSetting FfiIncludeDir
ffiLibraryDir <- getSetting FfiLibDir
libdwIncludeDir <- getSetting LibdwIncludeDir
@@ -296,8 +297,6 @@ rtsPackageArgs = package rts ? do
let cArgs = mconcat
[ rtsWarnings
- , flag UseSystemFfi ? not (null ffiIncludeDir) ? arg ("-I" ++ ffiIncludeDir)
- , flag WithLibdw ? not (null libdwIncludeDir) ? arg ("-I" ++ libdwIncludeDir)
, arg "-fomit-frame-pointer"
-- RTS *must* be compiled with optimisations. The INLINE_HEADER macro
-- requires that functions are inlined to work as expected. Inlining
@@ -386,6 +385,7 @@ rtsPackageArgs = package rts ? do
, builder (Cabal Setup) ? mconcat
[ cabalExtraDirs libdwIncludeDir libdwLibraryDir
, cabalExtraDirs libnumaIncludeDir libnumaLibraryDir
+ , useSystemFfi ? cabalExtraDirs ffiIncludeDir ffiLibraryDir
]
, builder (Cc (FindCDependencies CDep)) ? cArgs
, builder (Cc (FindCDependencies CxxDep)) ? cArgs
@@ -394,11 +394,7 @@ rtsPackageArgs = package rts ? do
, builder Ghc ? ghcArgs
, builder HsCpp ? pure
- [ "-DTOP=" ++ show top
- , "-DFFI_INCLUDE_DIR=" ++ show ffiIncludeDir
- , "-DFFI_LIB_DIR=" ++ show ffiLibraryDir
- , "-DFFI_LIB=" ++ show ffiLibName
- , "-DLIBDW_LIB_DIR=" ++ show libdwLibraryDir ]
+ [ "-DTOP=" ++ show top ]
, builder HsCpp ? flag WithLibdw ? arg "-DUSE_LIBDW"
, builder HsCpp ? flag HaveLibMingwEx ? arg "-DHAVE_LIBMINGWEX" ]