Build more profiling ways by default (#682)
[ghc.git] / src / Settings / Default.hs
1 module Settings.Default (
2 -- * Packages that are build by default and for the testsuite
3 defaultPackages, testsuitePackages,
4
5 -- * Default build ways
6 defaultLibraryWays, defaultRtsWays,
7
8 -- * Default command line arguments for various builders
9 SourceArgs (..), sourceArgs, defaultBuilderArgs, defaultPackageArgs,
10 defaultArgs,
11
12 -- * Default build flavour
13 defaultFlavour, defaultSplitObjects
14 ) where
15
16 import qualified Hadrian.Builder.Ar
17 import qualified Hadrian.Builder.Sphinx
18 import qualified Hadrian.Builder.Tar
19 import Hadrian.Haskell.Cabal.PackageData as PD
20
21 import CommandLine
22 import Expression
23 import Flavour
24 import Oracles.Flag
25 import Oracles.Setting
26 import Packages
27 import Settings
28 import Settings.Builders.Alex
29 import Settings.Builders.DeriveConstants
30 import Settings.Builders.Cabal
31 import Settings.Builders.Cc
32 import Settings.Builders.Configure
33 import Settings.Builders.GenPrimopCode
34 import Settings.Builders.Ghc
35 import Settings.Builders.GhcPkg
36 import Settings.Builders.Haddock
37 import Settings.Builders.Happy
38 import Settings.Builders.Hsc2Hs
39 import Settings.Builders.HsCpp
40 import Settings.Builders.Ld
41 import Settings.Builders.Make
42 import Settings.Builders.RunTest
43 import Settings.Builders.Xelatex
44 import Settings.Packages
45 import Settings.Warnings
46
47 -- | Packages that are built by default. You can change this in "UserSettings".
48 defaultPackages :: Stage -> Action [Package]
49 defaultPackages Stage0 = stage0Packages
50 defaultPackages Stage1 = stage1Packages
51 defaultPackages Stage2 = stage2Packages
52 defaultPackages Stage3 = return []
53
54 -- | Packages built in 'Stage0' by default. You can change this in "UserSettings".
55 stage0Packages :: Action [Package]
56 stage0Packages = do
57 win <- windowsHost
58 cross <- flag CrossCompiling
59 return $ [ binary
60 , cabal
61 , compareSizes
62 , compiler
63 , deriveConstants
64 , genapply
65 , genprimopcode
66 , ghc
67 , ghcBoot
68 , ghcBootTh
69 , ghcHeap
70 , ghci
71 , ghcPkg
72 , hsc2hs
73 , hpc
74 , mtl
75 , parsec
76 , templateHaskell
77 , text
78 , transformers
79 , unlit ]
80 ++ [ terminfo | not win, not cross ]
81 ++ [ touchy | win ]
82
83 -- | Packages built in 'Stage1' by default. You can change this in "UserSettings".
84 stage1Packages :: Action [Package]
85 stage1Packages = do
86 win <- windowsHost
87 intLib <- integerLibrary =<< flavour
88 libraries0 <- filter isLibrary <$> stage0Packages
89 cross <- flag CrossCompiling
90 return $ libraries0 -- Build all Stage0 libraries in Stage1
91 ++ [ array
92 , base
93 , bytestring
94 , containers
95 , deepseq
96 , directory
97 , filepath
98 , ghc
99 , ghcCompact
100 , ghcPkg
101 , ghcPrim
102 , haskeline
103 , hsc2hs
104 , intLib
105 , pretty
106 , process
107 , rts
108 , stm
109 , time
110 , unlit
111 , xhtml ]
112 ++ [ hpcBin | not cross ]
113 ++ [ iserv | not win, not cross ]
114 ++ [ libiserv | not win, not cross ]
115 ++ [ runGhc | not cross ]
116 ++ [ touchy | win ]
117 ++ [ unix | not win ]
118 ++ [ win32 | win ]
119
120 -- | Packages built in 'Stage2' by default. You can change this in "UserSettings".
121 stage2Packages :: Action [Package]
122 stage2Packages = do
123 cross <- flag CrossCompiling
124 return $ [ ghcTags ]
125 ++ [ haddock | not cross ]
126
127 -- | Packages that are built only for the testsuite.
128 testsuitePackages :: Action [Package]
129 testsuitePackages = do
130 win <- windowsHost
131 return $ [ checkApiAnnotations
132 , checkPpr
133 , ghci
134 , ghcCompact
135 , ghcPkg
136 , hp2ps
137 , hsc2hs
138 , iserv
139 , parallel
140 , runGhc ] ++
141 [ timeout | win ]
142
143 -- | Default build ways for library packages:
144 -- * We always build 'vanilla' way.
145 -- * We build 'profiling' way when stage > Stage0.
146 -- * We build 'dynamic' way when stage > Stage0 and the platform supports it.
147 defaultLibraryWays :: Ways
148 defaultLibraryWays = mconcat
149 [ pure [vanilla]
150 , notStage0 ? pure [profiling]
151 -- , notStage0 ? platformSupportsSharedLibs ? pure [dynamic]
152 ]
153
154 -- | Default build ways for the RTS.
155 defaultRtsWays :: Ways
156 defaultRtsWays = do
157 ways <- getLibraryWays
158 mconcat
159 [ pure [ logging, debug, threaded, threadedDebug, threadedLogging ]
160 , (profiling `elem` ways) ?
161 pure [ profiling, threadedProfiling, debugProfiling
162 , threadedDebugProfiling ]
163 -- we don't add the 'logging' variants of those for now, but we might
164 -- in the future?
165
166 {- , (dynamic `elem` ways) ?
167 pure [ dynamic, debugDynamic, threadedDynamic, threadedDebugDynamic
168 , loggingDynamic, threadedLoggingDynamic ] -}
169 ]
170
171 -- TODO: Move C source arguments here
172 -- | Default and package-specific source arguments.
173 data SourceArgs = SourceArgs
174 { hsDefault :: Args
175 , hsLibrary :: Args
176 , hsCompiler :: Args
177 , hsGhc :: Args }
178
179 -- | Concatenate source arguments in appropriate order.
180 sourceArgs :: SourceArgs -> Args
181 sourceArgs SourceArgs {..} = builder Ghc ? mconcat
182 [ hsDefault
183 , getPackageData PD.hcOpts
184 , libraryPackage ? hsLibrary
185 , package compiler ? hsCompiler
186 , package ghc ? hsGhc ]
187
188 -- | All default command line arguments.
189 defaultArgs :: Args
190 defaultArgs = mconcat
191 [ defaultBuilderArgs
192 , sourceArgs defaultSourceArgs
193 , defaultPackageArgs ]
194
195 -- | Default source arguments, e.g. optimisation settings.
196 defaultSourceArgs :: SourceArgs
197 defaultSourceArgs = SourceArgs
198 { hsDefault = mconcat [ stage0 ? arg "-O"
199 , notStage0 ? arg "-O2"
200 , arg "-H32m" ]
201 , hsLibrary = mempty
202 , hsCompiler = mempty
203 , hsGhc = mempty }
204
205 -- Please update doc/flavours.md when changing the default build flavour.
206 -- | Default build flavour. Other build flavours are defined in modules
207 -- @Settings.Flavours.*@. Users can add new build flavours in "UserSettings".
208 defaultFlavour :: Flavour
209 defaultFlavour = Flavour
210 { name = "default"
211 , args = defaultArgs
212 , packages = defaultPackages
213 , integerLibrary = (\x -> if x then integerSimple else integerGmp) <$> cmdIntegerSimple
214 , libraryWays = defaultLibraryWays
215 , rtsWays = defaultRtsWays
216 , splitObjects = defaultSplitObjects
217 , dynamicGhcPrograms = False
218 , ghciWithDebugger = False
219 , ghcProfiled = False
220 , ghcDebugged = False }
221
222 -- | Default condition for building split objects.
223 defaultSplitObjects :: Predicate
224 defaultSplitObjects = do
225 goodStage <- notStage0 -- We don't split bootstrap (stage 0) packages
226 pkg <- getPackage
227 supported <- expr supportsSplitObjects
228 split <- expr cmdSplitObjects
229 let goodPackage = isLibrary pkg && pkg /= compiler && pkg /= rts
230 return $ split && goodStage && goodPackage && supported
231
232 -- | All 'Builder'-dependent command line arguments.
233 defaultBuilderArgs :: Args
234 defaultBuilderArgs = mconcat
235 -- GHC-specific builders:
236 [ alexBuilderArgs
237 , cabalBuilderArgs
238 , ccBuilderArgs
239 , configureBuilderArgs
240 , deriveConstantsBuilderArgs
241 , genPrimopCodeBuilderArgs
242 , ghcBuilderArgs
243 , ghcPkgBuilderArgs
244 , haddockBuilderArgs
245 , happyBuilderArgs
246 , hsc2hsBuilderArgs
247 , hsCppBuilderArgs
248 , ldBuilderArgs
249 , makeBuilderArgs
250 , runTestBuilderArgs
251 , validateBuilderArgs
252 , xelatexBuilderArgs
253 -- Generic builders from the Hadrian library:
254 , builder (Ar Pack ) ? Hadrian.Builder.Ar.args Pack
255 , builder (Ar Unpack ) ? Hadrian.Builder.Ar.args Unpack
256 , builder (Sphinx Html ) ? Hadrian.Builder.Sphinx.args Html
257 , builder (Sphinx Latex) ? Hadrian.Builder.Sphinx.args Latex
258 , builder (Sphinx Man ) ? Hadrian.Builder.Sphinx.args Man
259 , builder (Tar Create ) ? Hadrian.Builder.Tar.args Create
260 , builder (Tar Extract ) ? Hadrian.Builder.Tar.args Extract ]
261
262 -- | All 'Package'-dependent command line arguments.
263 defaultPackageArgs :: Args
264 defaultPackageArgs = mconcat [ packageArgs, warningArgs ]