| ... |
... |
@@ -25,7 +25,6 @@ import Utilities |
|
25
|
25
|
import GHC.Toolchain as Toolchain hiding (HsCpp(HsCpp))
|
|
26
|
26
|
import GHC.Platform.ArchOS
|
|
27
|
27
|
import Settings.Program (ghcWithInterpreter)
|
|
28
|
|
-import UserSettings (finalStage)
|
|
29
|
28
|
|
|
30
|
29
|
-- | Track this file to rebuild generated files whenever it changes.
|
|
31
|
30
|
trackGenerateHs :: Expr ()
|
| ... |
... |
@@ -252,51 +251,30 @@ generateRules = do |
|
252
|
251
|
(root -/- "ghc-stage2") <~+ ghcWrapper Stage2
|
|
253
|
252
|
(root -/- "ghc-stage3") <~+ ghcWrapper Stage3
|
|
254
|
253
|
|
|
255
|
|
- forM_ allStages $ \buildStage -> do
|
|
256
|
|
- let -- Two stages are in play per rule iteration:
|
|
257
|
|
- --
|
|
258
|
|
- -- * @buildStage@ — loop variable; the settings file is written
|
|
259
|
|
- -- into @_build/<buildStage>/lib/settings@ and
|
|
260
|
|
- -- describes the compiler at @compilerStage@.
|
|
261
|
|
- -- * @compilerStage@ — the stage whose @bin/@ holds the compiler
|
|
262
|
|
- -- the settings file describes; also the
|
|
263
|
|
- -- ambient 'Expr' stage passed to
|
|
264
|
|
- -- 'generateSettings' (via 'semiEmptyTarget'),
|
|
265
|
|
- -- so it is the value of @executableStage@
|
|
266
|
|
- -- inside that function.
|
|
267
|
|
- --
|
|
268
|
|
- -- For a cross-compiler the libs it links against live in the
|
|
269
|
|
- -- /successor/ stage's lib dir; @libraryStage@ (computed in the
|
|
270
|
|
- -- rule body below) is that successor. @compilerStage@ normally
|
|
271
|
|
- -- equals @buildStage@, but at @finalStage@ there is no successor
|
|
272
|
|
- -- to hold its libs, so @compilerStage@ drops to the predecessor
|
|
273
|
|
- -- (the final stage's lib dir merely hosts the predecessor
|
|
274
|
|
- -- cross-compiler's target-arch libs).
|
|
275
|
|
- compilerStage = if buildStage == finalStage
|
|
276
|
|
- then predStage buildStage
|
|
277
|
|
- else buildStage
|
|
278
|
|
- prefix = root -/- stageString buildStage -/- "lib"
|
|
|
254
|
+ forM_ allStages $ \compilerStage -> do
|
|
|
255
|
+ let
|
|
|
256
|
+ prefix = root -/- stageString compilerStage -/- "lib"
|
|
279
|
257
|
go gen file = generate file (semiEmptyTarget compilerStage) gen
|
|
280
|
258
|
(prefix -/- "settings") %> \out -> do
|
|
281
|
259
|
-- Stage0 has no library or package DB of its own (the
|
|
282
|
260
|
-- bootstrapping compiler uses Stage1's); for any other stage the
|
|
283
|
261
|
-- package DB lives where the LibDir redirect points (this stage's
|
|
284
|
|
- -- own lib dir, or the successor's when @buildStage@ is a cross
|
|
|
262
|
+ -- own lib dir, or the successor's when @compilerStage@ is a cross
|
|
285
|
263
|
-- stage).
|
|
286
|
|
- isCross <- crossStage buildStage
|
|
287
|
|
- let libraryStage = case buildStage of
|
|
|
264
|
+ isCross <- crossStage compilerStage
|
|
|
265
|
+ let libraryStage = case compilerStage of
|
|
288
|
266
|
Stage0 {} -> Stage1
|
|
289
|
|
- _ -> if isCross then succStage buildStage else buildStage
|
|
|
267
|
+ _ -> if isCross then succStage compilerStage else compilerStage
|
|
290
|
268
|
pkgDb <- packageDbPath (PackageDbLoc libraryStage Final)
|
|
291
|
269
|
-- addTrailingPathSeparator needed: makeRelativeNoSysLink uses
|
|
292
|
270
|
-- splitPath where "lib" and "lib/" are distinct components.
|
|
293
|
271
|
let libTopDir = addTrailingPathSeparator $
|
|
294
|
|
- if isStage0 buildStage
|
|
|
272
|
+ if isStage0 compilerStage
|
|
295
|
273
|
then prefix
|
|
296
|
274
|
else root -/- stageString libraryStage -/- "lib"
|
|
297
|
275
|
relPkgDb = makeRelativeNoSysLink libTopDir pkgDb
|
|
298
|
276
|
go (generateSettings out True relPkgDb libraryStage) out
|
|
299
|
|
- (prefix -/- "targets" -/- "default.target") %> \out -> go (show <$> expr (targetStage (succStage buildStage))) out
|
|
|
277
|
+ (prefix -/- "targets" -/- "default.target") %> \out -> go (show <$> expr (targetStage (succStage compilerStage))) out
|
|
300
|
278
|
|
|
301
|
279
|
where
|
|
302
|
280
|
file <~+ gen = file %> \out -> generate out emptyTarget gen >> makeExecutable out
|
| ... |
... |
@@ -610,13 +588,10 @@ generateSettings settingsFile includeLibDir rel_pkg_db libraryStage = do |
|
610
|
588
|
, ("Use interpreter", expr $ yesNo <$> ghcWithInterpreter executableStage)
|
|
611
|
589
|
-- Advertise the RTS ways that will actually ship with the compiler
|
|
612
|
590
|
-- described by this settings file, i.e. the ways the @libraryStage@
|
|
613
|
|
- -- RTS is built with. Cabal queries this to decide which library ways
|
|
614
|
|
- -- the compiler supports (see
|
|
615
|
|
- -- 'Distribution.Simple.Compiler.waySupported'); under-advertising
|
|
616
|
|
- -- causes Cabal to silently drop flags like
|
|
617
|
|
- -- @--enable-profiling-shared@.
|
|
|
591
|
+ -- RTS is built with.
|
|
618
|
592
|
-- The settings file is regenerated at install time when installing a bindist.
|
|
619
|
|
- , ("RTS ways", unwords . map show . Set.toList <$> expr (interpretInContext (vanillaContext libraryStage rts) getRtsWays))
|
|
|
593
|
+ , ("RTS ways", unwords . map show . Set.toList <$>
|
|
|
594
|
+ expr (interpretInContext (vanillaContext libraryStage rts) getRtsWays))
|
|
620
|
595
|
, ("Relative Global Package DB", pure rel_pkg_db)
|
|
621
|
596
|
, ("base unit-id", pure base_unit_id)
|
|
622
|
597
|
]
|