summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-03-16 19:45:56 -0400
committerBen Gamari <ben@smart-cactus.org>2022-04-06 15:18:37 -0400
commit109cee198886974ab5348c9a2ae5dd0275046b5e (patch)
treed640962d0ac23cef7146f1c75831178eae57ac7f
parentf7b0f63c5f605c005b90d2c06d9e29893dba2dd1 (diff)
downloadhaskell-109cee198886974ab5348c9a2ae5dd0275046b5e.tar.gz
hadrian: Disable ghci libraries when object merging is not available
-rw-r--r--hadrian/src/Oracles/Flag.hs13
-rw-r--r--hadrian/src/Rules/Register.hs7
-rw-r--r--hadrian/src/Settings/Builders/Cabal.hs4
3 files changed, 19 insertions, 5 deletions
diff --git a/hadrian/src/Oracles/Flag.hs b/hadrian/src/Oracles/Flag.hs
index 40ae3e8f9b..7c05be5a68 100644
--- a/hadrian/src/Oracles/Flag.hs
+++ b/hadrian/src/Oracles/Flag.hs
@@ -1,8 +1,11 @@
{-# LANGUAGE MultiWayIf #-}
module Oracles.Flag (
- Flag (..), flag, getFlag, platformSupportsSharedLibs,
- targetSupportsSMP, useLibffiForAdjustors
+ Flag (..), flag, getFlag,
+ platformSupportsSharedLibs,
+ platformSupportsGhciObjects,
+ targetSupportsSMP,
+ useLibffiForAdjustors
) where
import Hadrian.Oracles.TextFile
@@ -60,6 +63,12 @@ flag f = do
getFlag :: Flag -> Expr c b Bool
getFlag = expr . flag
+-- | Does the platform support object merging (and therefore we can build GHCi objects
+-- when appropriate).
+platformSupportsGhciObjects :: Action Bool
+platformSupportsGhciObjects =
+ not . null <$> settingsFileSetting SettingsFileSetting_MergeObjectsCommand
+
platformSupportsSharedLibs :: Action Bool
platformSupportsSharedLibs = do
windows <- isWinTarget
diff --git a/hadrian/src/Rules/Register.hs b/hadrian/src/Rules/Register.hs
index cefdf04cb7..c510e96c02 100644
--- a/hadrian/src/Rules/Register.hs
+++ b/hadrian/src/Rules/Register.hs
@@ -9,6 +9,7 @@ import Expression ( getContextData )
import Hadrian.BuildPath
import Hadrian.Expression
import Hadrian.Haskell.Cabal
+import Oracles.Flag (platformSupportsGhciObjects)
import Packages
import Rules.Rts
import {-# SOURCE #-} Rules.Library (needLibrary)
@@ -206,12 +207,14 @@ extraTargets context
-- | Given a library 'Package' this action computes all of its targets. Needing
-- all the targets should build the library such that it is ready to be
-- registered into the package database.
--- See 'packageTargets' for the explanation of the @includeGhciLib@ parameter.
+-- See 'Rules.packageTargets' for the explanation of the @includeGhciLib@
+-- parameter.
libraryTargets :: Bool -> Context -> Action [FilePath]
libraryTargets includeGhciLib context@Context {..} = do
libFile <- pkgLibraryFile context
ghciLib <- pkgGhciLibraryFile context
- ghci <- if includeGhciLib && not (wayUnit Dynamic way)
+ ghciObjsSupported <- platformSupportsGhciObjects
+ ghci <- if ghciObjsSupported && includeGhciLib && not (wayUnit Dynamic way)
then interpretInContext context $ getContextData buildGhciLib
else return False
extra <- extraTargets context
diff --git a/hadrian/src/Settings/Builders/Cabal.hs b/hadrian/src/Settings/Builders/Cabal.hs
index 1ef20147ae..c6a83ce12b 100644
--- a/hadrian/src/Settings/Builders/Cabal.hs
+++ b/hadrian/src/Settings/Builders/Cabal.hs
@@ -139,6 +139,7 @@ libraryArgs = do
package <- getPackage
withGhci <- expr ghcWithInterpreter
dynPrograms <- expr (flavour >>= dynamicGhcPrograms)
+ ghciObjsSupported <- expr platformSupportsGhciObjects
let ways = flavourWays ++ [contextWay]
hasVanilla = vanilla `elem` ways
hasProfiling = any (wayUnit Profiling) ways
@@ -149,7 +150,8 @@ libraryArgs = do
, if hasProfiling
then "--enable-library-profiling"
else "--disable-library-profiling"
- , if (hasVanilla || hasProfiling) &&
+ , if ghciObjsSupported &&
+ (hasVanilla || hasProfiling) &&
package /= rts && withGhci && not dynPrograms
then "--enable-library-for-ghci"
else "--disable-library-for-ghci"