summaryrefslogtreecommitdiff
path: root/hadrian/src/Settings/Builders/SplitSections.hs
blob: 024596e50c1166d5e180ab3a10fd6e5169d07077 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
-- | Settings required when split-sections is enabled.
module Settings.Builders.SplitSections where

import Expression
import Packages
import Settings
import Flavour.Type

import Oracles.Setting

-- | Does it make sense to enable or disable split sections?
splitSectionsArgs :: Args
splitSectionsArgs = do
  pkg <- getPackage
  osx <- expr isOsxTarget
  notSt0 <- notStage0
  flav <- expr flavour
  if ( ghcSplitSections flav
         -- Flavour enables split-sections
    && not osx
         -- OS X doesn't support split sections
    && notSt0
         -- Disable for stage 0 because we aren't going to ship
         -- the resulting binaries and consequently there is no
         -- reason to minimize size.
    && (pkg /= ghc)
         -- Disable section splitting for the GHC library.
         -- It takes too long and there is little benefit.
    ) then
    ( mconcat
        [ builder (Ghc CompileHs) ? arg "-fsplit-sections"
        , builder MergeObjects ? ifM (expr isWinTarget)
            (pure ["-T", "driver/utils/merge_sections_pe.ld"])
            (pure ["-T", "driver/utils/merge_sections.ld"])
        ]
    ) else mempty