summaryrefslogtreecommitdiff
path: root/hadrian
diff options
context:
space:
mode:
authorJames Foster <ratherforky@gmail.com>2019-10-13 02:21:37 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-10-25 09:01:08 -0400
commit87175e7870949438401213b8e28ee2722b3de6fd (patch)
tree3ca0522dc80536548a70b2a89b379f287859e439 /hadrian
parent243c72eb60fc3481fe6db3fc0ea9cd836a9e7561 (diff)
downloadhaskell-87175e7870949438401213b8e28ee2722b3de6fd.tar.gz
Make Hadrian use -dynamic-too in the basic case
This commit makes Hadrian use the `-dynamic-too` flag when the current Flavour's libraryWays contains both vanilla and dynamic, cutting down the amount of repeated work caused by separate compilation of dynamic and static files. It does this for the basic case where '.o' and '.dyn_o' files are built with one command, but does not generalise to cases like '.prof_o' and '.prof_dyn_o'.
Diffstat (limited to 'hadrian')
-rw-r--r--hadrian/src/Rules/Compile.hs14
-rw-r--r--hadrian/src/Settings/Builders/Ghc.hs6
2 files changed, 19 insertions, 1 deletions
diff --git a/hadrian/src/Rules/Compile.hs b/hadrian/src/Rules/Compile.hs
index 546ce08cb6..ee395d4d75 100644
--- a/hadrian/src/Rules/Compile.hs
+++ b/hadrian/src/Rules/Compile.hs
@@ -6,6 +6,7 @@ import Hadrian.Oracles.TextFile
import Base
import Context as C
import Expression
+import Oracles.Flag (platformSupportsSharedLibs)
import Rules.Generate
import Settings
import Target
@@ -45,7 +46,18 @@ compilePackage rs = do
| wayPat <- wayPats] |%> compileNonHsObject rs Asm
-- All else is haskell.
- -- This comes last as it overlaps with the above rules' file patterns.
+ -- These come last as they overlap with the above rules' file patterns.
+
+ -- When building dynamically we depend on the static rule if shared libs
+ -- are supported, because it will add the -dynamic-too flag when
+ -- compiling to build the dynamic files alongside the static files
+ [ root -/- "**/build/**/*.dyn_o", root -/- "**/build/**/*.dyn_hi" ]
+ &%> \ [dyn_o, _dyn_hi] -> do
+ p <- platformSupportsSharedLibs
+ if p
+ then need [dyn_o -<.> "o", dyn_o -<.> "hi"]
+ else compileHsObjectAndHi rs dyn_o
+
forM_ ((,) <$> hsExts <*> wayPats) $ \ ((oExt, hiExt), wayPat) ->
[ root -/- "**/build/**/*." ++ wayPat ++ oExt
, root -/- "**/build/**/*." ++ wayPat ++ hiExt ]
diff --git a/hadrian/src/Settings/Builders/Ghc.hs b/hadrian/src/Settings/Builders/Ghc.hs
index 54315484c1..60fd8fa726 100644
--- a/hadrian/src/Settings/Builders/Ghc.hs
+++ b/hadrian/src/Settings/Builders/Ghc.hs
@@ -30,7 +30,13 @@ toolArgs = do
compileAndLinkHs :: Args
compileAndLinkHs = (builder (Ghc CompileHs) ||^ builder (Ghc LinkHs)) ? do
+ ways <- getLibraryWays
+ let hasVanilla = elem vanilla ways
+ hasDynamic = elem dynamic ways
mconcat [ arg "-Wall"
+ , (hasVanilla && hasDynamic) ? builder (Ghc CompileHs) ?
+ platformSupportsSharedLibs ? way vanilla ?
+ arg "-dynamic-too"
, commonGhcArgs
, ghcLinkArgs
, defaultGhcWarningsArgs