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

Commits:

10 changed files:

Changes:

  • hadrian/src/Expression.hs
    ... ... @@ -52,7 +52,6 @@ package p = (p ==) <$> getPackage
    52 52
     packageOneOf :: [Package] -> Predicate
    
    53 53
     packageOneOf ps = (`elem` ps) <$> getPackage
    
    54 54
     
    
    55
    -
    
    56 55
     -- | This type class allows the user to construct both precise builder
    
    57 56
     -- predicates, such as @builder (Ghc CompileHs Stage1)@, as well as predicates
    
    58 57
     -- covering a set of similar builders. For example, @builder (Ghc CompileHs)@
    

  • hadrian/src/Rules/Compile.hs
    ... ... @@ -62,12 +62,11 @@ compilePackage rs = do
    62 62
           forM_ wayPats $ \wayPat -> ( root -/- ("**/build/**/*." ++ wayPat ++ "dyn_o") :& root -/- ("**/build/**/*." ++ wayPat ++ "dyn_hi") :& Nil )
    
    63 63
             &%> \ ( dyn_o :& _dyn_hi :& _ ) -> do
    
    64 64
     
    
    65
    -          (BuildPath _root stage _path _o)
    
    65
    +          b@(BuildPath _root stage _path _o)
    
    66 66
                 <- parsePath (parseBuildObject root) "<object file path parser>" dyn_o
    
    67 67
               p <- targetSupportsSharedLibs stage
    
    68 68
               if p
    
    69 69
                 then do
    
    70
    -               b <- parsePath (parseBuildObject root) "<object file path parser>" dyn_o
    
    71 70
                    let ctx = objectContext b
    
    72 71
                        way = removeWayUnit Dynamic $ C.way ctx
    
    73 72
                    -- We `need` ".o/.hi" because GHC is called with `-dynamic-too`
    

  • hadrian/src/Rules/Generate.hs
    ... ... @@ -5,6 +5,7 @@ module Rules.Generate (
    5 5
         ) where
    
    6 6
     
    
    7 7
     import Development.Shake.FilePath
    
    8
    +import qualified Data.Set as Set
    
    8 9
     import Base
    
    9 10
     import qualified Context
    
    10 11
     import Expression
    
    ... ... @@ -12,7 +13,6 @@ import Hadrian.Oracles.TextFile (lookupStageBuildConfig)
    12 13
     import Oracles.Flag hiding (arSupportsAtFile, arSupportsDashL)
    
    13 14
     import Oracles.ModuleFiles
    
    14 15
     import Oracles.Setting
    
    15
    -import Settings.Program (ghcWithInterpreter)
    
    16 16
     import Hadrian.Haskell.Cabal.Type (PackageData(version))
    
    17 17
     import Hadrian.Haskell.Cabal
    
    18 18
     import Hadrian.Oracles.Cabal (readPackageData)
    
    ... ... @@ -23,7 +23,7 @@ import Utilities
    23 23
     
    
    24 24
     import GHC.Toolchain as Toolchain hiding (HsCpp(HsCpp))
    
    25 25
     import GHC.Platform.ArchOS
    
    26
    -import qualified Data.Set as Set
    
    26
    +import Settings.Program (ghcWithInterpreter)
    
    27 27
     import UserSettings (finalStage)
    
    28 28
     
    
    29 29
     -- | Track this file to rebuild generated files whenever it changes.
    

  • hadrian/src/Settings/Builders/RunTest.hs
    ... ... @@ -343,7 +343,6 @@ getTestArgs = do
    343 343
         hp2ps_path <- expr $ getTestExePath testGhc hp2ps
    
    344 344
         hpc_path <- expr $ getTestExePath testGhc hpc
    
    345 345
     
    
    346
    -
    
    347 346
         -- the testsuite driver will itself tell us if we need to generate the docs target
    
    348 347
         -- So we always pass the haddock path if the hadrian configuration allows us to build
    
    349 348
         -- docs
    

  • hadrian/src/Settings/Builders/SplitSections.hs
    ... ... @@ -12,19 +12,17 @@ import Flavour.Type
    12 12
     splitSectionsArgs :: Args
    
    13 13
     splitSectionsArgs = do
    
    14 14
       pkg <- getPackage
    
    15
    -  stage <- getStage
    
    16
    -  osx <- expr (isOsxTarget stage)
    
    17
    -  cross <- expr $ flag CrossCompiling
    
    15
    +  osx <- staged isOsxTarget
    
    18 16
       notSt0 <- notStage0
    
    19 17
       flav <- expr flavour
    
    20 18
       if ( ghcSplitSections flav
    
    21 19
              -- Flavour enables split-sections
    
    22 20
         && not osx
    
    23 21
              -- OS X doesn't support split sections
    
    24
    -    && (cross || notSt0)
    
    22
    +    && notSt0
    
    25 23
              -- Disable for stage 0 because we aren't going to ship
    
    26 24
              -- the resulting binaries and consequently there is no
    
    27
    -         -- reason to minimize size. Unless cross compiling.
    
    25
    +         -- reason to minimize size.
    
    28 26
         && (pkg /= ghc)
    
    29 27
              -- Disable section splitting for the GHC library.
    
    30 28
              -- It takes too long and there is little benefit.
    

  • hadrian/src/Settings/Default.hs
    ... ... @@ -71,9 +71,9 @@ stageBootPackages = return
    71 71
       , hsc2hs
    
    72 72
       , compareSizes
    
    73 73
       , deriveConstants
    
    74
    +  , genapply
    
    74 75
       , genprimopcode
    
    75 76
       , unlit
    
    76
    -  , genapply
    
    77 77
       ]
    
    78 78
     
    
    79 79
     -- | Packages built in 'Stage0' by default. You can change this in "UserSettings".
    
    ... ... @@ -220,7 +220,7 @@ defaultLibraryWays = do
    220 220
           mconcat
    
    221 221
           [ pure [vanilla]
    
    222 222
           , notStage0 ? pure [profiling]
    
    223
    -      , notStage0 ? targetSupportsSharedLibs stage ? pure [profilingDynamic, dynamic]
    
    223
    +      , notStage0 ? targetSupportsSharedLibs stage ? pure [dynamic, profilingDynamic]
    
    224 224
           ]
    
    225 225
     
    
    226 226
     -- | Default build ways for the RTS.
    

  • hadrian/src/Settings/Flavours/GhcInGhci.hs
    ... ... @@ -15,7 +15,7 @@ ghcInGhciFlavour = disableProfiledLibs $ defaultFlavour
    15 15
             Set.fromList
    
    16 16
                 <$> mconcat
    
    17 17
                     [ pure [vanilla]
    
    18
    -                , staged targetSupportsThreadedRts ? pure [dynamic]
    
    18
    +                , staged targetSupportsSharedLibs ? pure [dynamic]
    
    19 19
                     ]
    
    20 20
         }
    
    21 21
     
    

  • hadrian/src/Settings/Flavours/Validate.hs
    1 1
     module Settings.Flavours.Validate (validateFlavour, slowValidateFlavour,
    
    2 2
                                         quickValidateFlavour) where
    
    3 3
     
    
    4
    +
    
    4 5
     import Expression
    
    5 6
     import Flavour
    
    6 7
     import {-# SOURCE #-} Settings.Default
    

  • hadrian/src/Settings/Packages.hs
    1 1
     module Settings.Packages (packageArgs) where
    
    2 2
     
    
    3
    -import Data.Version.Extra
    
    4 3
     import Expression
    
    5 4
     import Flavour
    
    6 5
     import Oracles.Setting
    
    ... ... @@ -8,11 +7,12 @@ import Oracles.Flag
    8 7
     import Packages
    
    9 8
     import Settings
    
    10 9
     import Settings.Builders.Common (wayCcArgs)
    
    11
    -import Settings.Program (ghcWithInterpreter)
    
    12 10
     
    
    13 11
     import qualified GHC.Toolchain.Library as Lib
    
    14 12
     import GHC.Toolchain.Target
    
    15 13
     import GHC.Platform.ArchOS
    
    14
    +import Data.Version.Extra
    
    15
    +import Settings.Program (ghcWithInterpreter)
    
    16 16
     
    
    17 17
     -- | Package-specific command-line arguments.
    
    18 18
     packageArgs :: Args
    
    ... ... @@ -312,8 +312,7 @@ rtsPackageArgs = package rts ? do
    312 312
                       predStage stage
    
    313 313
                      else
    
    314 314
                       stage
    
    315
    -    -- Figure out if the host (the arch where GHC is running on) is x86
    
    316
    -    x86Host <- queryTarget stage' (\ tgt -> archOS_arch (tgtArchOs tgt) `elem` [ ArchX86, ArchX86_64 ])
    
    315
    +    x86 <- queryTarget stage' (\ tgt -> archOS_arch (tgtArchOs tgt) `elem` [ ArchX86, ArchX86_64 ])
    
    317 316
     
    
    318 317
         -- Arguments passed to GHC when compiling C and .cmm sources.
    
    319 318
         let ghcArgs = mconcat
    
    ... ... @@ -330,11 +329,11 @@ rtsPackageArgs = package rts ? do
    330 329
                 --
    
    331 330
                 -- In particular, we **do not** pass -mavx when compiling
    
    332 331
                 -- AutoApply_V16.cmm, as that would lock out targets with SSE2 but not AVX.
    
    333
    -          , inputs ["**/AutoApply_V32.cmm"] ? pure [ "-mavx2"    | x86Host ]
    
    334
    -          , inputs ["**/AutoApply_V64.cmm"] ? pure [ "-mavx512f" | x86Host ]
    
    332
    +          , inputs ["**/AutoApply_V32.cmm"] ? pure [ "-mavx2"    | x86 ]
    
    333
    +          , inputs ["**/AutoApply_V64.cmm"] ? pure [ "-mavx512f" | x86 ]
    
    335 334
     
    
    336
    -          , inputs ["**/Jumps_V32.cmm"] ? pure [ "-mavx2"    | x86Host ]
    
    337
    -          , inputs ["**/Jumps_V64.cmm"] ? pure [ "-mavx512f" | x86Host ]
    
    335
    +          , inputs ["**/Jumps_V32.cmm"] ? pure [ "-mavx2"    | x86 ]
    
    336
    +          , inputs ["**/Jumps_V64.cmm"] ? pure [ "-mavx512f" | x86 ]
    
    338 337
               ]
    
    339 338
     
    
    340 339
         let cArgs = mconcat
    
    ... ... @@ -379,11 +378,11 @@ rtsPackageArgs = package rts ? do
    379 378
               , inputs ["**/Evac.c", "**/Evac_thr.c"] ? arg "-funroll-loops"
    
    380 379
     
    
    381 380
                 -- See Note [AutoApply.cmm for vectors] in genapply/Main.hs
    
    382
    -          , inputs ["**/AutoApply_V32.c"] ? pure [ "-mavx2"    | x86Host ]
    
    383
    -          , inputs ["**/AutoApply_V64.c"] ? pure [ "-mavx512f" | x86Host ]
    
    381
    +          , inputs ["**/AutoApply_V32.c"] ? pure [ "-mavx2"    | x86 ]
    
    382
    +          , inputs ["**/AutoApply_V64.c"] ? pure [ "-mavx512f" | x86 ]
    
    384 383
     
    
    385
    -          , inputs ["**/Jumps_V32.c"] ? pure [ "-mavx2"    | x86Host ]
    
    386
    -          , inputs ["**/Jumps_V64.c"] ? pure [ "-mavx512f" | x86Host ]
    
    384
    +          , inputs ["**/Jumps_V32.c"] ? pure [ "-mavx2"    | x86 ]
    
    385
    +          , inputs ["**/Jumps_V64.c"] ? pure [ "-mavx512f" | x86 ]
    
    387 386
     
    
    388 387
               -- emits warnings about call-clobbered registers on x86_64
    
    389 388
               , inputs [ "**/StgCRun.c"
    

  • hadrian/src/Settings/Program.hs
    ... ... @@ -6,7 +6,6 @@ module Settings.Program
    6 6
     import Base
    
    7 7
     import Context
    
    8 8
     import Oracles.Flavour
    
    9
    -import Oracles.Flag
    
    10 9
     import Packages
    
    11 10
     
    
    12 11
     import GHC.Platform.ArchOS
    
    ... ... @@ -31,16 +30,11 @@ programContext stage pkg = do
    31 30
               notStage0 (Stage0 {}) = False
    
    32 31
               notStage0 _ = True
    
    33 32
     
    
    34
    --- | When cross compiling, enable for stage0 to get ghci
    
    35
    --- support. But when not cross compiling, disable for
    
    36
    --- stage0, otherwise we introduce extra dependencies
    
    37
    --- like haskeline etc, and mixing stageBoot/stage0 libs
    
    38
    --- can cause extra trouble (e.g. #25406)
    
    39
    ---
    
    40
    --- Also checks whether the target supports GHCi.
    
    33
    +-- | Check whether the target supports GHCi.
    
    34
    +-- Disable for stage 0: it would introduce extra dependencies like haskeline,
    
    35
    +-- and mixing stageBoot/stage0 libs can cause trouble (e.g. #25406).
    
    41 36
     ghcWithInterpreter :: Stage -> Action Bool
    
    42 37
     ghcWithInterpreter stage = do
    
    43
    -    is_cross <- flag CrossCompiling
    
    44 38
         goodOs <- anyTargetOs stage [ OSMinGW32, OSLinux, OSSolaris2
    
    45 39
                               , OSFreeBSD, OSDragonFly, OSNetBSD, OSOpenBSD
    
    46 40
                               , OSDarwin, OSKFreeBSD
    
    ... ... @@ -58,6 +52,4 @@ ghcWithInterpreter stage = do
    58 52
         -- fall back on dynamic linking:
    
    59 53
         dynamicGhcProgs <- askDynGhcPrograms stage
    
    60 54
     
    
    61
    -    -- Maybe this should just be false for cross compilers. But for now
    
    62
    -    -- I've kept the old behaviour where it will say yes. (See #25939)
    
    63
    -    return $ ((goodOs && goodArch) || dynamicGhcProgs) && (stage >= Stage1 || is_cross)
    55
    +    return $ ((goodOs && goodArch) || dynamicGhcProgs) && stage >= Stage1