Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC

Commits:

2 changed files:

Changes:

  • hadrian/doc/flavours.md
    ... ... @@ -249,10 +249,6 @@ The supported transformers are listed below:
    249 249
         <tr>
    
    250 250
             <td><code>profiled_ghc</code></td>
    
    251 251
             <td>Build the GHC executable with cost-centre profiling support.
    
    252
    -            It is recommended that you use this in conjunction with `no_dynamic_ghc` since
    
    253
    -            GHC does not support loading of profiled libraries with the
    
    254
    -            dynamic linker. You should use a flavour that builds profiling libs and rts,
    
    255
    -            i.e. not <code>quick</code>. <br>
    
    256 252
                 This flag adds cost centres with the -fprof-late flag.</td>
    
    257 253
         </tr>
    
    258 254
         <tr>
    
    ... ... @@ -274,6 +270,10 @@ The supported transformers are listed below:
    274 270
             <td><code>text_simdutf</code></td>
    
    275 271
             <td>Enable building the <code>text</code> package with <code>simdutf</code> support.</td>
    
    276 272
         </tr>
    
    273
    +    <tr>
    
    274
    +        <td><code>with_profiled_libs</code></td>
    
    275
    +        <td>Enables building of stage1+ libraries and the RTS in profiled build ways (the opposite of <code>no_profiled_libs</code>).</td>
    
    276
    +    </tr>
    
    277 277
         <tr>
    
    278 278
             <td><code>no_profiled_libs</code></td>
    
    279 279
             <td>Disables building of libraries in profiled build ways.</td>
    

  • hadrian/src/Flavour.hs
    ... ... @@ -15,6 +15,7 @@ module Flavour
    15 15
       , enableProfiledGhc
    
    16 16
       , disableDynamicGhcPrograms
    
    17 17
       , disableDynamicLibs
    
    18
    +  , enableProfiledLibs
    
    18 19
       , disableProfiledLibs
    
    19 20
       , enableLinting
    
    20 21
       , enableHaddock
    
    ... ... @@ -62,6 +63,7 @@ flavourTransformers = M.fromList
    62 63
         , "no_dynamic_libs"  =: disableDynamicLibs
    
    63 64
         , "native_bignum"    =: useNativeBignum
    
    64 65
         , "text_simdutf"     =: enableTextWithSIMDUTF
    
    66
    +    , "with_profiled_libs" =: enableProfiledLibs
    
    65 67
         , "no_profiled_libs" =: disableProfiledLibs
    
    66 68
         , "omit_pragmas"     =: omitPragmas
    
    67 69
         , "ipe"              =: enableIPE
    
    ... ... @@ -308,29 +310,11 @@ enableUBSan =
    308 310
     viaLlvmBackend :: Flavour -> Flavour
    
    309 311
     viaLlvmBackend = addArgs $ notStage0 ? builder Ghc ? arg "-fllvm"
    
    310 312
     
    
    311
    --- | Build the GHC executable with profiling enabled in stages 2 and later. It
    
    312
    --- is also recommended that you use this with @'dynamicGhcPrograms' = False@
    
    313
    --- since GHC does not support loading of profiled libraries with the
    
    314
    --- dynamically-linker.
    
    313
    +-- | Build the GHC executable with profiling enabled in stages 2 and
    
    314
    +-- later.
    
    315 315
     enableProfiledGhc :: Flavour -> Flavour
    
    316 316
     enableProfiledGhc flavour =
    
    317
    -  enableLateCCS flavour
    
    318
    -    { rtsWays = do
    
    319
    -        ws <- rtsWays flavour
    
    320
    -        mconcat
    
    321
    -          [ pure ws
    
    322
    -          , buildingCompilerStage' (>= Stage2) ? pure (foldMap profiled_ways ws)
    
    323
    -          ]
    
    324
    -    , libraryWays = mconcat
    
    325
    -        [ libraryWays flavour
    
    326
    -        , buildingCompilerStage' (>= Stage2) ? pure (Set.singleton profiling)
    
    327
    -        ]
    
    328
    -    , ghcProfiled = (>= Stage2)
    
    329
    -    }
    
    330
    -    where
    
    331
    -      profiled_ways w
    
    332
    -        | wayUnit Dynamic w = Set.empty
    
    333
    -        | otherwise         = Set.singleton (w <> profiling)
    
    317
    +  enableLateCCS $ enableProfiledLibs flavour { ghcProfiled = (>= Stage2) }
    
    334 318
     
    
    335 319
     -- | Disable 'dynamicGhcPrograms'.
    
    336 320
     disableDynamicGhcPrograms :: Flavour -> Flavour
    
    ... ... @@ -347,6 +331,20 @@ disableDynamicLibs flavour =
    347 331
         prune :: Ways -> Ways
    
    348 332
         prune = fmap $ Set.filter (not . wayUnit Dynamic)
    
    349 333
     
    
    334
    +-- | Build libraries and the RTS in profiled ways (opposite of
    
    335
    +-- 'disableProfiledLibs').
    
    336
    +enableProfiledLibs :: Flavour -> Flavour
    
    337
    +enableProfiledLibs flavour =
    
    338
    +  flavour
    
    339
    +    { libraryWays = addProfilingWays $ libraryWays flavour,
    
    340
    +      rtsWays = addProfilingWays $ rtsWays flavour
    
    341
    +    }
    
    342
    +  where
    
    343
    +    addProfilingWays :: Ways -> Ways
    
    344
    +    addProfilingWays ways = do
    
    345
    +      ws <- ways
    
    346
    +      buildProfiled <- notStage0
    
    347
    +      pure $ if buildProfiled then ws <> Set.map (<> profiling) ws else ws
    
    350 348
     
    
    351 349
     -- | Don't build libraries in profiled 'Way's.
    
    352 350
     disableProfiledLibs :: Flavour -> Flavour