[Git][ghc/ghc][wip/js-staging] 3 commits: Hadrian: add perf_stage0 transformer

doyougnu (@doyougnu) gitlab at gitlab.haskell.org
Thu Nov 3 20:19:48 UTC 2022



doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC


Commits:
9384b03f by doyougnu at 2022-11-03T16:19:36-04:00
Hadrian: add perf_stage0 transformer

- - - - -
cae4b93b by doyougnu at 2022-11-03T16:19:36-04:00
Hadrian: remove javascript specific flavours

- - - - -
4a6dfe4a by doyougnu at 2022-11-03T16:19:36-04:00
Hadrian: update docs with new transformers

Specifically:
- ticky_ghc0
- perf_stage0
- no_dynamic_libs

- - - - -


5 changed files:

- hadrian/doc/flavours.md
- hadrian/hadrian.cabal
- hadrian/src/Flavour.hs
- hadrian/src/Settings.hs
- − hadrian/src/Settings/Flavours/JavaScript.hs


Changes:

=====================================
hadrian/doc/flavours.md
=====================================
@@ -211,6 +211,15 @@ The supported transformers are listed below:
         <td><code>ticky_ghc</code></td>
         <td>Compile the GHC executable with Ticky-Ticky profiler support.</td>
     </tr>
+    <tr>
+        <td><code>ticky_ghc0</code></td>
+        <td>Compile the stage0 GHC executable with Ticky-Ticky profiler support. Useful for cross-compilers, which are always stage1 compilers</td>
+    </tr>
+    <tr>
+        <td><code>perf_stage0</code></td>
+        <td>Ensure that the `-O2` flags are passed to the stage0 build thus yielding an optimised stage1 compiler. Useful for cross-compilers, which are always stage1 compilers
+        </td>
+    </tr>
     <tr>
         <td><code>split_sections</code></td>
         <td>Enable section splitting for all libraries (except for the GHC
@@ -239,6 +248,11 @@ The supported transformers are listed below:
             default to loading static rather than dynamic library when,
             e.g., loading libraries during TemplateHaskell evaluations.</td>
     </tr>
+    <tr>
+        <td><code>no_dynamic_libs</code></td>
+        <td>Just like `no_dynamic_ghc`, this transformer ensures statically-linked libraries
+        </td>
+    </tr>
     <tr>
         <td><code>no_profiled_libs</code></td>
         <td>Disables building of libraries in profiled build ways.</td>


=====================================
hadrian/hadrian.cabal
=====================================
@@ -125,7 +125,6 @@ executable hadrian
                        , Settings.Flavours.Quickest
                        , Settings.Flavours.Validate
                        , Settings.Flavours.Release
-                       , Settings.Flavours.JavaScript
                        , Settings.Packages
                        , Settings.Parser
                        , Settings.Program


=====================================
hadrian/src/Flavour.hs
=====================================
@@ -10,7 +10,7 @@ module Flavour
   , enableDebugInfo, enableTickyGhc
   , viaLlvmBackend
   , enableProfiledGhc
-  , enableO2Stage0
+  , perfStage0
   , disableDynamicGhcPrograms
   , disableDynamicLibs
   , disableProfiledLibs
@@ -39,6 +39,7 @@ import Control.Monad.Except
 import UserSettings
 import Oracles.Setting
 
+import {-# SOURCE #-} Settings.Default
 
 flavourTransformers :: Map String (Flavour -> Flavour)
 flavourTransformers = M.fromList
@@ -46,7 +47,7 @@ flavourTransformers = M.fromList
     , "debug_info"       =: enableDebugInfo
     , "ticky_ghc"        =: enableTickyGhc
     , "ticky_ghc0"       =: enableTickyGhc0
-    , "optimize_stage0"  =: enableO2Stage0
+    , "perf_stage0"      =: perfStage0
     , "split_sections"   =: splitSections
     , "thread_sanitizer" =: enableThreadSanitizer
     , "llvm"             =: viaLlvmBackend
@@ -113,9 +114,6 @@ parseFlavour baseFlavours transformers str =
 addArgs :: Args -> Flavour -> Flavour
 addArgs args' fl = fl { args = args fl <> args' }
 
-onArgs :: (Args -> Args) -> Flavour -> Flavour
-onArgs f fl = fl { args = f $ args fl}
-
 -- | Turn on -Werror for packages built with the stage1 compiler.
 -- It mimics the CI settings so is useful to turn on when developing.
 werror :: Flavour -> Flavour
@@ -139,9 +137,20 @@ enableTickyGhc =
       ]
 
 -- | Enable the ticky-ticky profiler in stage1 GHC
-enableO2Stage0 :: Flavour -> Flavour
-enableO2Stage0 fl = onArgs ensureO2 fl
-  where ensureO2 as = (builder Ghc ? stage0 ? arg "-O2") <> remove ["-O"] as
+perfStage0 :: Flavour -> Flavour
+perfStage0 fl = addArgs args fl
+  -- This is a bit sloppy because it does not preclude any predicates that turn
+  -- on (or off) optimizations that were added be the flavor or by another
+  -- transformer. Luckily though if we're using this transformer then we want O2
+  -- for each subsequent stage and ghc doesn't choke on the redundant flags
+  -- There is the remove in Hadrian.Expression but it doesn't handle predicates
+  where 
+        args           = sourceArgs SourceArgs
+          { hsDefault  = mconcat [ arg "-O2", arg "-H64m"]
+          , hsLibrary  = arg "-O2"
+          , hsCompiler = arg "-O2"
+          , hsGhc      = arg "-O2"
+          }
 
 -- | Enable the ticky-ticky profiler in stage1 GHC
 enableTickyGhc0 :: Flavour -> Flavour


=====================================
hadrian/src/Settings.hs
=====================================
@@ -23,7 +23,6 @@ import Settings.Flavours.Quickest
 import Settings.Flavours.QuickCross
 import Settings.Flavours.Validate
 import Settings.Flavours.Release
-import Settings.Flavours.JavaScript
 
 
 getArgs :: Args
@@ -54,12 +53,10 @@ hadrianFlavours :: [Flavour]
 hadrianFlavours =
     [ benchmarkFlavour, defaultFlavour, developmentFlavour Stage1
     , developmentFlavour Stage2, performanceFlavour
-    , releaseFlavour, releaseJsFlavour
+    , releaseFlavour
     , quickFlavour, quickValidateFlavour, quickDebugFlavour
     , quickestFlavour
     , quickCrossFlavour
-    , quickJsFlavour
-    , perfJsFlavour
     , ghcInGhciFlavour, validateFlavour, slowValidateFlavour
     ]
 


=====================================
hadrian/src/Settings/Flavours/JavaScript.hs deleted
=====================================
@@ -1,57 +0,0 @@
-module Settings.Flavours.JavaScript
- ( quickJsFlavour
- , perfJsFlavour
- , releaseJsFlavour
- ) where
-
-import qualified Data.Set as Set
-
-import Flavour
-import Expression
-import Settings.Flavours.Performance
-import {-# SOURCE #-} Settings.Default
-
-releaseJsFlavour :: Flavour
-releaseJsFlavour =   disableDynamicLibs
-                   . disableDynamicGhcPrograms
-                   . disableProfiledLibs
-                   . enableO2Stage0
-                   . useNativeBignum
-                   $ performanceFlavour { name = "release-js" }
-
-quickJsFlavour :: Flavour
-quickJsFlavour = defaultFlavour
-    { name        = "quick-js"
-    , args        = defaultBuilderArgs <> quickJsArgs <> defaultPackageArgs
-    , dynamicGhcPrograms = pure False
-    , libraryWays = pure $ Set.singleton vanilla
-    , rtsWays     = pure $ Set.singleton vanilla
-    }
-
-perfJsFlavour :: Flavour
-perfJsFlavour = defaultFlavour
-    { name        = "perf-js"
-    , args        = defaultBuilderArgs <> perfJsArgs <> defaultPackageArgs
-    , dynamicGhcPrograms = pure False
-    , libraryWays = pure $ Set.singleton vanilla
-    , rtsWays     = pure $ Set.singleton vanilla
-    }
-
-quickJsArgs :: Args
-quickJsArgs = sourceArgs SourceArgs
-    { hsDefault  = mconcat $
-        [ pure ["-O0", "-H64m"]
-        ]
-    , hsLibrary  = notStage0 ? mconcat [ arg "-O" ]
-    , hsCompiler = stage0 ? arg "-O2"
-    , hsGhc      = mconcat
-                   [ stage0 ? arg "-O"
-                   , stage1 ? mconcat [ arg "-O0" ] ] }
-
-perfJsArgs :: Args
-perfJsArgs = sourceArgs SourceArgs
-    { hsDefault  = mconcat [ arg "-O2", arg "-H64m"]
-    , hsLibrary  = arg "-O2"
-    , hsCompiler = arg "-O2"
-    , hsGhc      = arg "-O2"
-    }



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/978f301075f3fa8505a2614aaaf3ec0486a912c3...4a6dfe4a83165977b43e996fda15cb7876d62b84

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/978f301075f3fa8505a2614aaaf3ec0486a912c3...4a6dfe4a83165977b43e996fda15cb7876d62b84
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20221103/50544011/attachment-0001.html>


More information about the ghc-commits mailing list