Sven Tennie pushed to branch wip/romes/hadrian-cross-stage2-rebase_SVEN_FINAL at Glasgow Haskell Compiler / GHC

Commits:

8 changed files:

Changes:

  • hadrian/src/Hadrian/Oracles/TextFile.hs
    ... ... @@ -124,8 +124,8 @@ getBuildTarget :: Action Toolchain.Target
    124 124
     getBuildTarget = getTargetConfig buildTargetFile
    
    125 125
     
    
    126 126
     -- | Get the host target configuration through 'getTargetConfig'
    
    127
    -getHostTarget :: Action Toolchain.Target
    
    128
    -getHostTarget = do
    
    127
    +getHostTarget :: Stage -> Action Toolchain.Target
    
    128
    +getHostTarget stage | stage >= Stage1 = do
    
    129 129
       -- MP: If we are not cross compiling then we should use the target file in order to
    
    130 130
       -- build things for the host, in particular we want to use the configured values for the
    
    131 131
       -- target for building the RTS (ie are we using Libffi for adjustors, and the wordsize)
    
    ... ... @@ -135,8 +135,7 @@ getHostTarget = do
    135 135
       if (Toolchain.targetPlatformTriple ht) == (Toolchain.targetPlatformTriple tt)
    
    136 136
         then return tt
    
    137 137
         else return ht
    
    138
    -  -- where
    
    139
    -  --   msg = "The host's target configuration file " ++ quote hostTargetFile ++ " does not exist! ghc-toolchain might have failed to generate it."
    
    138
    +getHostTarget _stage {- stage0 -} = getTargetConfig hostTargetFile
    
    140 139
     
    
    141 140
     -- | Get the target target configuration through 'getTargetConfig'
    
    142 141
     getTargetTarget :: Action Toolchain.Target
    
    ... ... @@ -145,9 +144,8 @@ getTargetTarget = getTargetConfig targetTargetFile
    145 144
     queryBuildTarget :: (Toolchain.Target -> a) -> Action a
    
    146 145
     queryBuildTarget f = f <$> getBuildTarget
    
    147 146
     
    
    148
    -queryHostTarget :: (Toolchain.Target -> a) -> Action a
    
    149
    -queryHostTarget f = f <$> getHostTarget
    
    150
    -
    
    147
    +queryHostTarget :: Stage -> (Toolchain.Target -> a) -> Action a
    
    148
    +queryHostTarget stage f = f <$> getHostTarget stage
    
    151 149
     
    
    152 150
     newtype KeyValue = KeyValue (FilePath, String)
    
    153 151
         deriving (Binary, Eq, Hashable, NFData, Show)
    

  • hadrian/src/Oracles/Setting.hs
    ... ... @@ -137,7 +137,7 @@ getSetting = expr . setting
    137 137
     bashPath :: Action FilePath
    
    138 138
     bashPath = setting BourneShell
    
    139 139
     
    
    140
    -isWinHost :: Action Bool
    
    140
    +isWinHost :: Stage -> Action Bool
    
    141 141
     isWinHost = anyHostOs [OSMinGW32]
    
    142 142
     
    
    143 143
     isWinTarget :: Stage -> Action Bool
    
    ... ... @@ -153,8 +153,8 @@ isArmTarget :: Stage -> Action Bool
    153 153
     isArmTarget stage = queryTargetTarget stage (isARM . archOS_arch . tgtArchOs)
    
    154 154
     
    
    155 155
     -- | Check whether the host OS setting matches one of the given strings.
    
    156
    -anyHostOs :: [OS] -> Action Bool
    
    157
    -anyHostOs oss = (`elem` oss) <$> queryHostTarget (archOS_OS . tgtArchOs)
    
    156
    +anyHostOs :: [OS] -> Stage ->  Action Bool
    
    157
    +anyHostOs oss  stage = (`elem` oss) <$> queryHostTarget stage (archOS_OS . tgtArchOs)
    
    158 158
     
    
    159 159
     -- | Check whether the target architecture setting matches one of the given
    
    160 160
     -- strings.
    
    ... ... @@ -233,7 +233,7 @@ libsuf st way
    233 233
     -- For example, we want to build RTS with stage1 for the host target as we
    
    234 234
     -- produce a host executable with stage1 (which cross-compiles to stage2).
    
    235 235
     targetStage :: Stage -> Action Target
    
    236
    -targetStage stage | isHostStage stage = getHostTarget
    
    236
    +targetStage stage | isHostStage stage = getHostTarget stage
    
    237 237
     targetStage _ = getTargetTarget
    
    238 238
     
    
    239 239
     isHostStage :: Stage -> Bool
    

  • hadrian/src/Rules/BinaryDist.hs
    ... ... @@ -326,7 +326,7 @@ bindistRules = do
    326 326
         -- phony "binary-dist-dir-stage3" $ buildBinDistDir root targetBindist
    
    327 327
     
    
    328 328
         let buildBinDist compressor = do
    
    329
    -          win_host <- isWinHost
    
    329
    +          win_host <- isWinHost Stage1
    
    330 330
               win_target <- isWinTarget Stage2
    
    331 331
               when (win_target && win_host) (error "normal binary-dist does not work for windows targets, use `reloc-binary-dist-*` target instead.")
    
    332 332
               buildBinDistX "binary-dist-dir" "bindist" compressor
    

  • hadrian/src/Rules/Generate.hs
    ... ... @@ -409,7 +409,7 @@ bindistRules = do
    409 409
         , interpolateSetting "ProjectPatchLevel2" ProjectPatchLevel2
    
    410 410
         , interpolateSetting "ProjectGitCommitId" ProjectGitCommitId
    
    411 411
     
    
    412
    -    , interpolateVar "HostOS_CPP" $ fmap cppify $ interp $ queryHost queryOS
    
    412
    +    , interpolateVar "HostOS_CPP" $ fmap cppify $ interp $ queryHost queryOS Stage1
    
    413 413
     
    
    414 414
         , interpolateVar "TargetPlatform" $ getTarget targetPlatformTriple
    
    415 415
         , interpolateVar "TargetPlatform_CPP" $ cppify <$> getTarget targetPlatformTriple
    
    ... ... @@ -433,7 +433,7 @@ bindistRules = do
    433 433
         , interpolateVar "TargetHasLibm" $ yesNo <$> interp (staged (buildFlag TargetHasLibm))
    
    434 434
         , interpolateVar "TargetPlatform" $ getTarget targetPlatformTriple
    
    435 435
         , interpolateVar "BuildPlatform"  $ interp $ queryBuild targetPlatformTriple
    
    436
    -    , interpolateVar "HostPlatform"   $ interp $ queryHost targetPlatformTriple
    
    436
    +    , interpolateVar "HostPlatform"   $ interp $ queryHost  targetPlatformTriple Stage1
    
    437 437
         , interpolateVar "TargetWordBigEndian" $ getTarget isBigEndian
    
    438 438
         , interpolateVar "TargetWordSize" $ getTarget wordSize
    
    439 439
         , interpolateVar "Unregisterised" $ yesNo <$> getTarget tgtUnregisterised
    
    ... ... @@ -523,7 +523,7 @@ generateConfigHs = do
    523 523
         let chooseSetting x y = case stage of { Stage0 {} -> x; _ -> y }
    
    524 524
         let queryTarget f = f <$> expr (targetStage stage)
    
    525 525
         -- Not right for stage3
    
    526
    -    buildPlatform <- chooseSetting (queryBuild targetPlatformTriple) (queryHost targetPlatformTriple)
    
    526
    +    buildPlatform <- chooseSetting (queryBuild targetPlatformTriple) (queryHost targetPlatformTriple stage)
    
    527 527
         hostPlatform <- queryTarget targetPlatformTriple
    
    528 528
         trackGenerateHs
    
    529 529
         cProjectName        <- getSetting ProjectName
    
    ... ... @@ -626,9 +626,9 @@ generatePlatformHostHs = do
    626 626
         stage <- getStage
    
    627 627
         let chooseHostQuery = case stage of
    
    628 628
                 Stage0 {} -> queryHost
    
    629
    -            _         -> queryTarget stage
    
    630
    -    cHostPlatformArch <- chooseHostQuery (archOS_arch . tgtArchOs)
    
    631
    -    cHostPlatformOS   <- chooseHostQuery (archOS_OS . tgtArchOs)
    
    629
    +            _         -> flip queryTarget
    
    630
    +    cHostPlatformArch <- chooseHostQuery (archOS_arch . tgtArchOs) stage
    
    631
    +    cHostPlatformOS   <- chooseHostQuery (archOS_OS . tgtArchOs) stage
    
    632 632
         return $ unlines
    
    633 633
             [ "module GHC.Platform.Host where"
    
    634 634
             , ""
    

  • hadrian/src/Rules/Lint.hs
    ... ... @@ -42,7 +42,7 @@ runHLint :: [FilePath] -- ^ include directories
    42 42
              -> Action ()
    
    43 43
     runHLint includeDirs defines dir = do
    
    44 44
       threads <- shakeThreads <$> getShakeOptions
    
    45
    -  hostArch <- (<> "_HOST_ARCH") <$> queryHostTarget queryArch
    
    45
    +  hostArch <- (<> "_HOST_ARCH") <$> queryHostTarget Stage1 queryArch
    
    46 46
       let hlintYaml = dir </> ".hlint.yaml"
    
    47 47
           defines' = hostArch : defines
    
    48 48
           cmdLine = unwords $
    

  • hadrian/src/Settings.hs
    ... ... @@ -119,9 +119,11 @@ unsafeFindPackageByPath path = err $ find (\pkg -> pkgPath pkg == path) knownPac
    119 119
     -- Be careful querying values from the HOST and BUILD targets until the targets
    
    120 120
     -- are only generated by ghc-toolchain:
    
    121 121
     -- See Note [The dummy values in the HOST target description]
    
    122
    -queryBuild, queryHost :: (Target -> a) -> Expr a
    
    122
    +queryBuild :: (Target -> a) -> Expr a
    
    123 123
     queryBuild f = expr $ queryBuildTarget f
    
    124
    -queryHost  f = expr $ queryHostTarget f
    
    124
    +
    
    125
    +queryHost :: (Target -> a) -> Stage -> Expr a
    
    126
    +queryHost f stage = expr $ queryHostTarget stage f
    
    125 127
     
    
    126 128
     queryArch, queryOS, queryVendor :: Target -> String
    
    127 129
     queryArch = stringEncodeArch . archOS_arch . tgtArchOs
    

  • hadrian/src/Settings/Builders/Hsc2Hs.hs
    ... ... @@ -13,8 +13,8 @@ hsc2hsBuilderArgs = builder Hsc2Hs ? do
    13 13
         ccPath  <- getBuilderPath $ Cc CompileC stage
    
    14 14
         gmpDir  <- staged (buildSetting GmpIncludeDir)
    
    15 15
         top     <- expr topDirectory
    
    16
    -    hArch   <- queryHost queryArch
    
    17
    -    hOs     <- queryHost queryOS
    
    16
    +    hArch   <- queryHost queryArch stage
    
    17
    +    hOs     <- queryHost queryOS stage
    
    18 18
         tArch   <- queryTarget stage queryArch
    
    19 19
         tOs     <- queryTarget stage queryOS
    
    20 20
         version <- case stage of
    

  • hadrian/src/Settings/Builders/RunTest.hs
    ... ... @@ -124,7 +124,7 @@ inTreeCompilerArgs stg = do
    124 124
         debugged            <- ghcDebugged        <$> flavour <*> pure ghcStage
    
    125 125
         profiled            <- ghcProfiled        <$> flavour <*> pure ghcStage
    
    126 126
     
    
    127
    -    os          <- queryHostTarget queryOS
    
    127
    +    os          <- queryHostTarget ghcStage queryOS
    
    128 128
         arch        <- queryTargetTarget ghcStage queryArch
    
    129 129
         let codegen_arches = ["x86_64", "i386", "powerpc", "powerpc64", "powerpc64le", "aarch64", "wasm32", "riscv64", "loongarch64"]
    
    130 130
         let withNativeCodeGen