summaryrefslogtreecommitdiff
path: root/hadrian/src/Flavour.hs
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2022-12-07 11:04:59 +0000
committerMatthew Pickering <matthewtpickering@gmail.com>2023-01-06 15:32:32 +0000
commit123adfba81c8c9febf531b8783b7a0a3166e4604 (patch)
tree75aa0676aa00d5749010fd5469f9a1349d0e25df /hadrian/src/Flavour.hs
parentc45ce0f169fe995107fd5f66a961c826e8247d99 (diff)
downloadhaskell-123adfba81c8c9febf531b8783b7a0a3166e4604.tar.gz
hadrian: Add no_split_sections tranformer
This transformer reverts the effect of `split_sections`, which we intend to use for platforms which don't support split sections. In order to achieve this we have to modify the implemntation of the split_sections transformer to store whether we are enabling split_sections directly in the `Flavour` definition. This is because otherwise there's no convenient way to turn off split_sections due to having to pass additional linker scripts when merging objects. (cherry picked from commit fec6638e2468c78f136f2363d8b3239a9bfd4f91)
Diffstat (limited to 'hadrian/src/Flavour.hs')
-rw-r--r--hadrian/src/Flavour.hs32
1 files changed, 7 insertions, 25 deletions
diff --git a/hadrian/src/Flavour.hs b/hadrian/src/Flavour.hs
index f1e4aba881..9f8bd1d955 100644
--- a/hadrian/src/Flavour.hs
+++ b/hadrian/src/Flavour.hs
@@ -5,7 +5,7 @@ module Flavour
-- * Flavour transformers
, flavourTransformers
, addArgs
- , splitSections, splitSectionsIf
+ , splitSections
, enableThreadSanitizer
, enableDebugInfo, enableTickyGhc
, viaLlvmBackend
@@ -37,7 +37,6 @@ import Text.Parsec.Char as P
import Control.Monad.Except
import UserSettings
import Oracles.Flag
-import Oracles.Setting
flavourTransformers :: Map String (Flavour -> Flavour)
@@ -46,6 +45,7 @@ flavourTransformers = M.fromList
, "debug_info" =: enableDebugInfo
, "ticky_ghc" =: enableTickyGhc
, "split_sections" =: splitSections
+ , "no_split_sections" =: noSplitSections
, "thread_sanitizer" =: enableThreadSanitizer
, "llvm" =: viaLlvmBackend
, "profiled_ghc" =: enableProfiledGhc
@@ -181,31 +181,13 @@ enableHaddock =
]
-- | 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. Note that this transformer doesn't do anything
+-- @-split-sections@ whenever appropriate.
+-- Note that this transformer doesn't do anything
-- on darwin because on darwin platforms we always enable subsections
-- via symbols.
-splitSectionsIf :: (Package -> Bool) -> Flavour -> Flavour
-splitSectionsIf pkgPredicate = addArgs $ do
- pkg <- getPackage
- osx <- expr isOsxTarget
- not osx ? -- osx doesn't support split sections
- pkgPredicate pkg ? mconcat -- Only apply to these packages
- [ builder (Ghc CompileHs) ? arg "-split-sections"
- , builder MergeObjects ? ifM (expr isWinTarget)
- (pure ["-t", "driver/utils/merge_sections_pe.ld"])
- (pure ["-t", "driver/utils/merge_sections.ld"])
- ]
-
--- | 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.
+splitSections, noSplitSections :: Flavour -> Flavour
+splitSections f = f { ghcSplitSections = True }
+noSplitSections f = f { ghcSplitSections = False }
-- | Build GHC and libraries with ThreadSanitizer support. You likely want to
-- configure with @--disable-large-address-space@ when using this.