summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hadrian/src/Context.hs4
-rw-r--r--hadrian/src/Rules/Library.hs9
-rw-r--r--hadrian/src/Settings/Builders/Cabal.hs17
-rw-r--r--hadrian/src/Utilities.hs4
4 files changed, 22 insertions, 12 deletions
diff --git a/hadrian/src/Context.hs b/hadrian/src/Context.hs
index 745901159d..672b3a6004 100644
--- a/hadrian/src/Context.hs
+++ b/hadrian/src/Context.hs
@@ -96,7 +96,9 @@ pkgLibraryFile context@Context {..} = do
-- | Path to the GHCi library file of a given 'Context', e.g.:
-- @_build/stage1/libraries/array/build/HSarray-0.5.1.0.o@.
pkgGhciLibraryFile :: Context -> Action FilePath
-pkgGhciLibraryFile context = pkgFile context "HS" ".o"
+pkgGhciLibraryFile context@Context {..} = do
+ let extension = "" <.> osuf way
+ pkgFile context "HS" extension
-- | Path to the configuration file of a given 'Context'.
pkgConfFile :: Context -> Action FilePath
diff --git a/hadrian/src/Rules/Library.hs b/hadrian/src/Rules/Library.hs
index 24a94241c6..122004084a 100644
--- a/hadrian/src/Rules/Library.hs
+++ b/hadrian/src/Rules/Library.hs
@@ -25,7 +25,9 @@ libraryRules = do
root -/- "//libHS*-*.dylib" %> buildDynamicLibUnix root "dylib"
root -/- "//libHS*-*.so" %> buildDynamicLibUnix root "so"
root -/- "//*.a" %> buildStaticLib root
- priority 2 $ root -/- "//HS*-*.o" %> buildGhciLibO root
+ priority 2 $ do
+ root -/- "//HS*-*.o" %> buildGhciLibO root
+ root -/- "//HS*-*.p_o" %> buildGhciLibO root
-- * 'Action's for building libraries
@@ -193,8 +195,9 @@ parseLibGhciFilename :: Parsec.Parsec String () LibGhci
parseLibGhciFilename = do
_ <- Parsec.string "HS"
(pkgname, pkgver) <- parsePkgId
- way <- parseWaySuffix vanilla
- _ <- Parsec.string ".o"
+ _ <- Parsec.string "."
+ way <- parseWayPrefix vanilla
+ _ <- Parsec.string "o"
return (LibGhci pkgname pkgver way)
-- | Parse the filename of a dynamic library to be built into a 'LibDyn' value.
diff --git a/hadrian/src/Settings/Builders/Cabal.hs b/hadrian/src/Settings/Builders/Cabal.hs
index f33e9b458c..80b9b67a71 100644
--- a/hadrian/src/Settings/Builders/Cabal.hs
+++ b/hadrian/src/Settings/Builders/Cabal.hs
@@ -57,19 +57,24 @@ libraryArgs :: Args
libraryArgs = do
flavourWays <- getLibraryWays
contextWay <- getWay
+ package <- getPackage
withGhci <- expr ghcWithInterpreter
dynPrograms <- expr (flavour >>= dynamicGhcPrograms)
let ways = flavourWays ++ [contextWay]
- pure [ if vanilla `elem` ways
+ hasVanilla = vanilla `elem` ways
+ hasProfiling = any (wayUnit Profiling) ways
+ hasDynamic = any (wayUnit Dynamic) ways
+ pure [ if hasVanilla
then "--enable-library-vanilla"
else "--disable-library-vanilla"
- , if vanilla `elem` ways && withGhci && not dynPrograms
- then "--enable-library-for-ghci"
- else "--disable-library-for-ghci"
- , if or [Profiling `wayUnit` way | way <- ways]
+ , if hasProfiling
then "--enable-library-profiling"
else "--disable-library-profiling"
- , if or [Dynamic `wayUnit` way | way <- ways]
+ , if (hasVanilla || hasProfiling) &&
+ package /= rts && withGhci && not dynPrograms
+ then "--enable-library-for-ghci"
+ else "--disable-library-for-ghci"
+ , if hasDynamic
then "--enable-shared"
else "--disable-shared" ]
diff --git a/hadrian/src/Utilities.hs b/hadrian/src/Utilities.hs
index 7fe6a89dae..d31f6cc2d0 100644
--- a/hadrian/src/Utilities.hs
+++ b/hadrian/src/Utilities.hs
@@ -61,10 +61,10 @@ stage1Dependencies =
-- | Given a library 'Package' this action computes all of its targets. See
-- 'packageTargets' for the explanation of the @includeGhciLib@ parameter.
libraryTargets :: Bool -> Context -> Action [FilePath]
-libraryTargets includeGhciLib context = do
+libraryTargets includeGhciLib context@Context {..} = do
libFile <- pkgLibraryFile context
ghciLib <- pkgGhciLibraryFile context
- ghci <- if includeGhciLib
+ ghci <- if includeGhciLib && not (wayUnit Dynamic way)
then interpretInContext context $ getContextData buildGhciLib
else return False
return $ [ libFile ] ++ [ ghciLib | ghci ]