[commit: ghc] wip/nfs-locking: Refactor ways, revise comments. (3ff1fc1)

git at git.haskell.org git at git.haskell.org
Fri Oct 27 00:11:34 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/nfs-locking
Link       : http://ghc.haskell.org/trac/ghc/changeset/3ff1fc1097d98f17ab081be3c9f1379bea69d04a/ghc

>---------------------------------------------------------------

commit 3ff1fc1097d98f17ab081be3c9f1379bea69d04a
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Sat Jan 16 23:58:20 2016 +0000

    Refactor ways, revise comments.
    
    See #100.


>---------------------------------------------------------------

3ff1fc1097d98f17ab081be3c9f1379bea69d04a
 src/Rules/Program.hs              |  2 +-
 src/Settings/Builders/Ghc.hs      |  2 +-
 src/Settings/Builders/GhcCabal.hs |  2 +-
 src/Settings/User.hs              | 24 +++++++++++++-----------
 src/Settings/Ways.hs              | 33 +++++++++++++++------------------
 src/Way.hs                        |  1 +
 6 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/src/Rules/Program.hs b/src/Rules/Program.hs
index 93a6d6c..d472e88 100644
--- a/src/Rules/Program.hs
+++ b/src/Rules/Program.hs
@@ -77,7 +77,7 @@ buildBinary target @ (PartialTarget stage pkg) bin = do
              ++ [ buildPath -/- "Paths_hsc2hs.o"      | pkg == hsc2hs  ]
              ++ [ buildPath -/- "Paths_haddock.o"     | pkg == haddock ]
         objs  = cObjs ++ hObjs
-    ways     <- interpretPartial target getWays
+    ways     <- interpretPartial target getLibraryWays
     depNames <- interpretPartial target $ getPkgDataList TransitiveDepNames
     let libStage  = min stage Stage1 -- libraries are built only in Stage0/1
         libTarget = PartialTarget libStage pkg
diff --git a/src/Settings/Builders/Ghc.hs b/src/Settings/Builders/Ghc.hs
index c97cd56..3537aed 100644
--- a/src/Settings/Builders/Ghc.hs
+++ b/src/Settings/Builders/Ghc.hs
@@ -48,7 +48,7 @@ splitObjectsArgs = splitObjects ? do
 
 ghcMBuilderArgs :: Args
 ghcMBuilderArgs = stagedBuilder GhcM ? do
-    ways <- getWays
+    ways <- getLibraryWays
     mconcat [ arg "-M"
             , commonGhcArgs
             , arg "-include-pkg-deps"
diff --git a/src/Settings/Builders/GhcCabal.hs b/src/Settings/Builders/GhcCabal.hs
index 8591bd5..afd3def 100644
--- a/src/Settings/Builders/GhcCabal.hs
+++ b/src/Settings/Builders/GhcCabal.hs
@@ -49,7 +49,7 @@ ghcCabalHsColourBuilderArgs = builder GhcCabalHsColour ? do
 -- TODO: Need compiler_stage1_CONFIGURE_OPTS += --disable-library-for-ghci?
 libraryArgs :: Args
 libraryArgs = do
-    ways     <- getWays
+    ways     <- getLibraryWays
     withGhci <- lift ghcWithInterpreter
     append [ if vanilla `elem` ways
              then  "--enable-library-vanilla"
diff --git a/src/Settings/User.hs b/src/Settings/User.hs
index 2a1471d..f57a2ac 100644
--- a/src/Settings/User.hs
+++ b/src/Settings/User.hs
@@ -1,6 +1,6 @@
 module Settings.User (
     buildRootPath, userTargetDirectory, userProgramPath, trackBuildSystem,
-    userArgs, userPackages, userLibWays, userRtsWays, userKnownPackages,
+    userArgs, userPackages, userLibraryWays, userRtsWays, userKnownPackages,
     integerLibrary, buildHaddock, validating, ghciWithDebugger, ghcProfiled,
     ghcDebugged, dynamicGhcPrograms, laxDependencies, buildSystemConfigFile,
     verboseCommands, turnWarningsIntoErrors, splitObjects,
@@ -36,24 +36,26 @@ userPackages = mempty
 userKnownPackages :: [Package]
 userKnownPackages = []
 
--- Control which ways libraries and rts are built
--- TODO: skip profiling for speed, skip dynamic since it's currently broken
-userLibWays :: Ways
-userLibWays = remove [profiling, dynamic]
+-- | Control which ways library packages are built
+-- FIXME: skip profiling for speed
+-- FIXME: skip dynamic since it's currently broken #4
+userLibraryWays :: Ways
+userLibraryWays = remove [profiling, dynamic]
 
+-- | Control which ways the 'rts' package is built
 userRtsWays :: Ways
 userRtsWays = mempty
 
--- Choose integer library: integerGmp, integerGmp2 or integerSimple
+-- | Choose the integer library: integerGmp or integerSimple
 integerLibrary :: Package
 integerLibrary = integerGmp
 
--- User-defined flags. Note the following type semantics:
+-- | User-defined flags. Note the following type semantics:
 -- * Bool: a plain Boolean flag whose value is known at compile time
 -- * Action Bool: a flag whose value can depend on the build environment
 -- * Predicate: a flag depending on the build environment and the current target
 
--- Set this to True if you are making any changes in the build system and want
+-- | Set this to True if you are making any changes in the build system and want
 -- appropriate rebuilds to be initiated. Switching this to False speeds things
 -- up a little (particularly zero builds).
 -- WARNING: a complete rebuild is required when changing this setting.
@@ -80,7 +82,7 @@ ghcProfiled = False
 ghcDebugged :: Bool
 ghcDebugged = False
 
--- When laxDependencies flag is set to True, dependencies on the GHC executable
+-- | When laxDependencies is set to True, dependencies on the GHC executable
 -- are turned into order-only dependencies to avoid needless recompilation when
 -- making changes to GHC's sources. In certain situations this can lead to build
 -- failures, in which case you should reset the flag (at least temporarily).
@@ -93,8 +95,8 @@ buildHaddock = return False -- FIXME: should be return True, see #98
 buildSystemConfigFile :: Bool
 buildSystemConfigFile = False
 
--- Set to True to print full command lines during the build process. Note, this
--- is a Predicate, hence you can enable verbose output for a chosen package
+-- | Set to True to print full command lines during the build process. Note,
+-- this is a Predicate, hence you can enable verbose output for a chosen package
 -- only, e.g.: verboseCommands = package ghcPrim
 verboseCommands :: Predicate
 verboseCommands = return False
diff --git a/src/Settings/Ways.hs b/src/Settings/Ways.hs
index 8376213..223bc79 100644
--- a/src/Settings/Ways.hs
+++ b/src/Settings/Ways.hs
@@ -1,34 +1,31 @@
-module Settings.Ways (getWays, getLibWays, getRtsWays) where
+module Settings.Ways (getLibraryWays, getRtsWays) where
 
-import Data.Monoid
+import Base
 import Expression
 import Predicates
 import Settings.User
 import Oracles.Config.Flag
 
--- TODO: use a single expression Ways parameterised by package instead of
--- expressions libWays and rtsWays
-
--- Combining default ways with user modifications
-getLibWays :: Expr [Way]
-getLibWays = fromDiffExpr $ defaultLibWays <> userLibWays
-
--- In Stage0 we only build vanilla
-getWays :: Expr [Way]
-getWays = mconcat [ stage0 ? return [vanilla], notStage0 ? getLibWays ]
+-- | Combine default ways with user modifications
+getLibraryWays :: Expr [Way]
+getLibraryWays = fromDiffExpr $ defaultLibraryWays <> userLibraryWays
 
 getRtsWays :: Expr [Way]
 getRtsWays = fromDiffExpr $ defaultRtsWays <> userRtsWays
 
--- These are default ways
-defaultLibWays :: Ways
-defaultLibWays = mconcat
-    [ append [vanilla, profiling]
-    , platformSupportsSharedLibs ? append [dynamic] ]
+-- These are default ways for library packages:
+-- * We always build 'vanilla' way.
+-- * We build 'profiling' way when stage > Stage0.
+-- * We build 'dynamic' way when stage > Stage0 and the platform supports it.
+defaultLibraryWays :: Ways
+defaultLibraryWays = mconcat
+    [ append [vanilla]
+    , notStage0 ? append [profiling]
+    , notStage0 ? platformSupportsSharedLibs ? append [dynamic] ]
 
 defaultRtsWays :: Ways
 defaultRtsWays = do
-    ways <- getLibWays
+    ways <- getLibraryWays
     mconcat
         [ append [ logging, debug, threaded, threadedDebug, threadedLogging ]
         , (profiling `elem` ways) ? append [threadedProfiling]
diff --git a/src/Way.hs b/src/Way.hs
index ba20bd7..8923571 100644
--- a/src/Way.hs
+++ b/src/Way.hs
@@ -101,6 +101,7 @@ granSim = wayFromUnits [GranSim]
 
 -- RTS only ways
 -- TODO: do we need to define *only* these? Shall we generalise/simplify?
+-- See compiler/main/DynFlags.hs.
 threaded, threadedProfiling, threadedLogging, debug, debugProfiling,
     threadedDebug, threadedDebugProfiling, dynamic, profilingDynamic,
     threadedProfilingDynamic, threadedDynamic, threadedDebugDynamic,



More information about the ghc-commits mailing list