summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-10-11 17:59:57 -0400
committerBen Gamari <ben@smart-cactus.org>2019-10-11 18:16:11 -0400
commit7a59eb6a25b38433cb363b94a6169296021ca688 (patch)
treeec0be51485d6dc57cc65fe7d49072d0e662c069c
parentd584e3f08cfee6e28b70bf53c573d86e44f326f8 (diff)
downloadhaskell-wip/hadrian-add-helpers.tar.gz
hadrian: Introduce enableDebugInfo flavour transformerwip/hadrian-add-helpers
Also refactor things a bit to eliminate repetition.
-rw-r--r--hadrian/src/Flavour.hs30
1 files changed, 21 insertions, 9 deletions
diff --git a/hadrian/src/Flavour.hs b/hadrian/src/Flavour.hs
index e78aa5b9a1..dba8621952 100644
--- a/hadrian/src/Flavour.hs
+++ b/hadrian/src/Flavour.hs
@@ -1,7 +1,10 @@
module Flavour
( Flavour (..), werror
, DocTargets, DocTarget(..)
+ -- * Flavour transformers
+ , addArgs
, splitSections, splitSectionsIf
+ , enableDebugInfo
) where
import Expression
@@ -34,7 +37,7 @@ data Flavour = Flavour {
ghciWithDebugger :: Bool,
-- | Build profiled GHC.
ghcProfiled :: Bool,
- -- | Build GHC with debug information.
+ -- | Build GHC with debugging assertions.
ghcDebugged :: Bool,
-- | Whether to build docs and which ones
-- (haddocks, user manual, haddock manual)
@@ -61,10 +64,21 @@ type DocTargets = Set DocTarget
data DocTarget = Haddocks | SphinxHTML | SphinxPDFs | SphinxMan | SphinxInfo
deriving (Eq, Ord, Show, Bounded, Enum)
+-- | Add arguments to the 'args' of a 'Flavour'.
+addArgs :: Args -> Flavour -> Flavour
+addArgs args' fl = fl { args = args fl <> args' }
+
-- | Turn on -Werror for packages built with the stage1 compiler.
-- It mimics the CI settings so is useful to turn on when developing.
werror :: Flavour -> Flavour
-werror fl = fl { args = args fl <> (builder Ghc ? notStage0 ? arg "-Werror") }
+werror = addArgs (builder Ghc ? notStage0 ? arg "-Werror")
+
+-- | Build C and Haskell objects with debugging information.
+enableDebugInfo :: Flavour -> Flavour
+enableDebugInfo = addArgs $ mconcat
+ [ builder (Ghc CompileHs) ? notStage0 ? arg "-g3"
+ , builder (Cc CompileC) ? notStage0 ? arg "-g3"
+ ]
-- | Transform the input 'Flavour' so as to build with
-- @-split-sections@ whenever appropriate. You can
@@ -74,13 +88,11 @@ werror fl = fl { args = args fl <> (builder Ghc ? notStage0 ? arg "-Werror") }
-- building it. If the given flavour doesn't build
-- anything in a @dyn@-enabled way, then 'splitSections' is a no-op.
splitSectionsIf :: (Package -> Bool) -> Flavour -> Flavour
-splitSectionsIf pkgPredicate fl = fl { args = args fl <> splitSectionsArg }
-
- where splitSectionsArg = do
- way <- getWay
- pkg <- getPackage
- (Dynamic `wayUnit` way) ? pkgPredicate pkg ?
- builder (Ghc CompileHs) ? arg "-split-sections"
+splitSectionsIf pkgPredicate = addArgs $ do
+ way <- getWay
+ pkg <- getPackage
+ (Dynamic `wayUnit` way) ? pkgPredicate pkg ?
+ builder (Ghc CompileHs) ? arg "-split-sections"
-- | Like 'splitSectionsIf', but with a fixed predicate: use
-- split sections for all packages but the GHC library.