[commit: ghc] wip/nfs-locking: Refactor generated dependencies (41ecfdc)

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


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

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

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

commit 41ecfdc70602aed5335f7205a092c336c090ec90
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Wed Jan 6 11:56:22 2016 +0000

    Refactor generated dependencies
    
    Do not proceed with building a package until all its generated dependencies are in place. List generated files in ghcPrim package, see #117.


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

41ecfdc70602aed5335f7205a092c336c090ec90
 src/Rules/Data.hs         |  5 +++++
 src/Rules/Dependencies.hs |  3 ---
 src/Rules/Generate.hs     | 17 ++++++++++-------
 src/Rules/IntegerGmp.hs   |  7 ++++++-
 4 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/src/Rules/Data.hs b/src/Rules/Data.hs
index 42fb2a6..29f8d3d 100644
--- a/src/Rules/Data.hs
+++ b/src/Rules/Data.hs
@@ -6,6 +6,7 @@ import GHC
 import Oracles
 import Predicates (registerPackage)
 import Rules.Actions
+import Rules.Generate
 import Rules.Resources
 import Settings
 import Settings.Builders.Common
@@ -19,6 +20,10 @@ buildPackageData rs target @ (PartialTarget stage pkg) = do
         dataFile  = pkgDataFile stage pkg
 
     dataFile %> \mk -> do
+        -- The first thing we do with any package is make sure all generated
+        -- dependencies are in place before proceeding.
+        orderOnly $ generatedDependencies stage pkg
+
         -- GhcCabal may run the configure script, so we depend on it
         -- We don't know who built the configure script from configure.ac
         whenM (doesFileExist $ configure <.> "ac") $ need [configure]
diff --git a/src/Rules/Dependencies.hs b/src/Rules/Dependencies.hs
index 5b51c1d..79bcdb2 100644
--- a/src/Rules/Dependencies.hs
+++ b/src/Rules/Dependencies.hs
@@ -4,7 +4,6 @@ import Base
 import Expression
 import Oracles
 import Rules.Actions
-import Rules.Generate
 import Rules.Resources
 import Settings
 import Development.Shake.Util (parseMakefile)
@@ -18,13 +17,11 @@ buildPackageDependencies _ target @ (PartialTarget stage pkg) =
     in do
         [ buildPath ++ "//*.c.deps", buildPath ++ "//*.cmm.deps" ] |%> \out -> do
             let srcFile = dropBuild . dropExtension $ out
-            orderOnly $ generatedDependencies stage pkg
             need [srcFile]
             build $ fullTarget target (GccM stage) [srcFile] [out]
 
         hDepFile %> \out -> do
             srcs <- interpretPartial target getPackageSources
-            orderOnly $ generatedDependencies stage pkg
             need srcs
             if srcs == []
             then writeFileChanged out ""
diff --git a/src/Rules/Generate.hs b/src/Rules/Generate.hs
index 2b33a53..3eb1231 100644
--- a/src/Rules/Generate.hs
+++ b/src/Rules/Generate.hs
@@ -35,13 +35,15 @@ includesDependencies = ("includes" -/-) <$>
     , "ghcplatform.h"
     , "ghcversion.h" ]
 
-integerGmpDependencies :: [FilePath]
-integerGmpDependencies = [integerGmpLibraryH]
-
 defaultDependencies :: [FilePath]
 defaultDependencies =
     includesDependencies ++ libffiDependencies ++ integerGmpDependencies
 
+ghcPrimDependencies :: Stage -> [FilePath]
+ghcPrimDependencies stage = ((targetPath stage ghcPrim -/- "build") -/-) <$>
+       [ "GHC/PrimopWrappers.hs"
+       , "autogen/GHC/Prim.hs" ]
+
 derivedConstantsDependencies :: [FilePath]
 derivedConstantsDependencies = (derivedConstantsPath -/-) <$>
     [ "DerivedConstants.h"
@@ -72,10 +74,11 @@ compilerDependencies stage =
 
 generatedDependencies :: Stage -> Package -> [FilePath]
 generatedDependencies stage pkg
-    | pkg == compiler = compilerDependencies stage
-    | pkg == rts = derivedConstantsDependencies
-    | stage == Stage0 = defaultDependencies
-    | otherwise = []
+    | pkg   == compiler = compilerDependencies stage
+    | pkg   == ghcPrim  = ghcPrimDependencies stage
+    | pkg   == rts      = derivedConstantsDependencies
+    | stage == Stage0   = defaultDependencies
+    | otherwise         = []
 
 -- The following generators and corresponding source extensions are supported:
 knownGenerators :: [ (Builder, String) ]
diff --git a/src/Rules/IntegerGmp.hs b/src/Rules/IntegerGmp.hs
index b82dcbb..b796c6c 100644
--- a/src/Rules/IntegerGmp.hs
+++ b/src/Rules/IntegerGmp.hs
@@ -1,4 +1,6 @@
-module Rules.IntegerGmp (integerGmpRules, integerGmpObjects, integerGmpLibraryH) where
+module Rules.IntegerGmp (
+    integerGmpRules, integerGmpObjects, integerGmpLibraryH, integerGmpDependencies
+    ) where
 
 import Base
 import Expression
@@ -28,6 +30,9 @@ integerGmpLibraryH = pkgPath integerGmp -/- "include/ghc-gmp.h"
 integerGmpLibraryFakeH :: FilePath
 integerGmpLibraryFakeH = integerGmpBase -/- "ghc-gmp.h"
 
+integerGmpDependencies :: [FilePath]
+integerGmpDependencies = [integerGmpLibraryH]
+
 -- relative to integerGmpBuild
 integerGmpPatch :: FilePath
 integerGmpPatch = ".." -/- "tarball" -/- "gmp-5.0.4.patch"



More information about the ghc-commits mailing list