Sven Tennie pushed to branch wip/supersven/hadrian-cross-stage3 at Glasgow Haskell Compiler / GHC

Commits:

2 changed files:

Changes:

  • hadrian/src/BindistConfig.hs
    1 1
     module BindistConfig where
    
    2 2
     
    
    3
    -import Stage
    
    4
    -import Oracles.Flag
    
    5 3
     import Expression
    
    4
    +import Oracles.Flag
    
    6 5
     
    
    7
    -data BindistConfig = BindistConfig { library_stage :: Stage -- ^ The stage compiler which builds the libraries
    
    8
    -                                   , executable_stage :: Stage -- ^ The stage compiler which builds the executables
    
    9
    -                                   }
    
    6
    +data BindistConfig = BindistConfig
    
    7
    +  { -- | The stage compiler which builds the libraries
    
    8
    +    library_stage :: Stage,
    
    9
    +    -- | The stage compiler which builds the executables
    
    10
    +    executable_stage :: Stage,
    
    11
    +    -- | Which ghc-pkg to use (`targetBindist`'s
    
    12
    +    -- ghc-pkg cannot run on the build platform)
    
    13
    +    use_inplace_ghcPkg :: Bool
    
    14
    +  }
    
    10 15
     
    
    11 16
     -- | A bindist for when the host = target, non cross-compilation setting.
    
    12 17
     -- Both the libraries and final executables are built with stage1 compiler.
    
    13 18
     normalBindist :: BindistConfig
    
    14
    -normalBindist = BindistConfig { library_stage = Stage1, executable_stage = Stage1 }
    
    19
    +normalBindist = BindistConfig {library_stage = Stage1, executable_stage = Stage1, use_inplace_ghcPkg = True}
    
    15 20
     
    
    16 21
     -- | A bindist which contains a cross compiler (when host /= target)
    
    17 22
     -- The cross compiler is produced by the stage1 compiler, but then we must compile
    
    18 23
     -- all the boot libraries with the cross compiler (hence stage2 for libraries)
    
    19 24
     crossBindist :: BindistConfig
    
    20
    -crossBindist = BindistConfig { library_stage = Stage2, executable_stage = Stage1 }
    
    25
    +crossBindist = BindistConfig {library_stage = Stage2, executable_stage = Stage1, use_inplace_ghcPkg = True}
    
    21 26
     
    
    22 27
     -- | A bindist which contains executables for the target, which produce code for the
    
    23 28
     -- target. These are produced as "Stage3" build products, produced by a stage2 cross compiler.
    
    24
    -targetBindist ::  BindistConfig
    
    25
    -targetBindist = BindistConfig { library_stage = Stage2, executable_stage = Stage2 }
    
    26
    -
    
    29
    +targetBindist :: BindistConfig
    
    30
    +targetBindist = BindistConfig {library_stage = Stage2, executable_stage = Stage2, use_inplace_ghcPkg = False}
    
    27 31
     
    
    28 32
     -- | The implicit bindist config, if we don't know any better.
    
    29 33
     implicitBindistConfig :: Action BindistConfig
    
    ... ... @@ -35,7 +39,7 @@ implicitBindistConfig = do
    35 39
       return $ if cross then crossBindist else normalBindist
    
    36 40
     
    
    37 41
     -- | Are we building things in this stage for the final target?
    
    38
    -buildingForTarget ::  Stage -> Action Bool
    
    42
    +buildingForTarget :: Stage -> Action Bool
    
    39 43
     buildingForTarget st = do
    
    40 44
       cfg <- implicitBindistConfig
    
    41 45
       return $ st >= (library_stage cfg)

  • hadrian/src/Rules/BinaryDist.hs
    ... ... @@ -222,9 +222,16 @@ buildBinDistDir dirPrefix root conf@BindistConfig{..} = do
    222 222
         --
    
    223 223
         -- N.B. the ghc-pkg executable may be prefixed with a target triple
    
    224 224
         -- (c.f. #20267).
    
    225
    -
    
    226
    -    ghcPkgName <- programName (vanillaContext executable_stage ghcPkg)
    
    227
    -    cmd_ (bindistFilesDir -/- "bin" -/- ghcPkgName) ["recache", "--package-db", bindistFilesDir -/- "lib" -/- "package.conf.d" ]
    
    225
    +    --
    
    226
    +    -- For Stage3 cross-compilers (those that are supposed to run on the target
    
    227
    +    -- platform), we have to resort to a prior stage's ghc-pkg as the final
    
    228
    +    -- stage can naturally not be executed on our current build host.
    
    229
    +    if use_inplace_ghcPkg then do
    
    230
    +      ghcPkgName <- programName (vanillaContext executable_stage ghcPkg)
    
    231
    +      cmd_ (bindistFilesDir -/- "bin" -/- ghcPkgName) ["recache", "--package-db", bindistFilesDir -/- "lib" -/- "package.conf.d" ]
    
    232
    +    else do
    
    233
    +      ghcPkgPath <- builderPath $ GhcPkg Recache library_stage
    
    234
    +      cmd_ ghcPkgPath ["recache", "--package-db", bindistFilesDir -/- "lib" -/- "package.conf.d" ]
    
    228 235
     
    
    229 236
     
    
    230 237
         need ["docs"]