summaryrefslogtreecommitdiff
path: root/hadrian/src/Flavour.hs
diff options
context:
space:
mode:
authorAlp Mestanogullari <alpmestan@gmail.com>2019-03-15 21:35:59 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-03-27 07:20:05 -0400
commitfb12f53c2779f15ee24786e8c3beae3133506a01 (patch)
tree954591064a368662821b289a606a8a6706ca7d91 /hadrian/src/Flavour.hs
parent646f2e79c5d6e79341693b1b9660da974102cec2 (diff)
downloadhaskell-fb12f53c2779f15ee24786e8c3beae3133506a01.tar.gz
Hadrian: introduce an easy way for users to build with -split-sections
Any user can now trivially build any number of Haskell packages with `-split-sections` by using `splitSections`/`splitSectionsIf` on any existing or new flavour: -- build all packages but the ghc library with -split-sections splitSections :: Flavour -> Flavour -- build all packages that satisfy the given predicate -- with --split-sections splitSectionsIf :: (Package -> Bool) -> Flavour -> Flavour See the new section in `doc/user-settings.md`.
Diffstat (limited to 'hadrian/src/Flavour.hs')
-rw-r--r--hadrian/src/Flavour.hs25
1 files changed, 25 insertions, 0 deletions
diff --git a/hadrian/src/Flavour.hs b/hadrian/src/Flavour.hs
index 06407e7022..230272ec62 100644
--- a/hadrian/src/Flavour.hs
+++ b/hadrian/src/Flavour.hs
@@ -1,10 +1,12 @@
module Flavour
( Flavour (..), werror
, DocTargets, DocTarget(..)
+ , splitSections, splitSectionsIf
) where
import Expression
import Data.Set (Set)
+import Packages
-- Please update doc/{flavours.md, user-settings.md} when changing this file.
-- | 'Flavour' is a collection of build settings that fully define a GHC build.
@@ -63,3 +65,26 @@ data DocTarget = Haddocks | SphinxHTML | SphinxPDFs | SphinxMan
-- 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") }
+
+-- | Transform the input 'Flavour' so as to build with
+-- @-split-sections@ whenever appropriate. You can
+-- select which package gets built with split sections
+-- by passing a suitable predicate. If the predicate holds
+-- for a given package, then @split-sections@ is used when
+-- 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"
+
+-- | Like 'splitSectionsIf', but with a fixed predicate: use
+-- split sections for all packages but the GHC library.
+splitSections :: Flavour -> Flavour
+splitSections = splitSectionsIf (/=ghc)
+-- Disable section splitting for the GHC library. It takes too long and
+-- there is little benefit.