[commit: ghc] wip/nfs-locking: Add support for separate interface file compilation. (6b532ba)

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


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

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

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

commit 6b532baa0dd71e5c61229c0be832d871bf0bf705
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Sat Jan 16 03:11:31 2016 +0000

    Add support for separate interface file compilation.
    
    See #174.


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

6b532baa0dd71e5c61229c0be832d871bf0bf705
 src/Rules/Compile.hs         | 16 ++++++++++++++--
 src/Settings/Builders/Ghc.hs | 15 +++++++++------
 src/Settings/User.hs         |  7 ++++++-
 3 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/src/Rules/Compile.hs b/src/Rules/Compile.hs
index 2fb315c..2065415 100644
--- a/src/Rules/Compile.hs
+++ b/src/Rules/Compile.hs
@@ -12,10 +12,22 @@ compilePackage _ target @ (PartialTarget stage pkg) = do
     let buildPath = targetPath stage pkg -/- "build"
 
     matchBuildResult buildPath "hi" ?> \hi ->
-        need [ hi -<.> osuf (detectWay hi) ]
+        if compileInterfaceFilesSeparately
+        then do
+            let way = detectWay hi
+            (src, deps) <- dependencies buildPath $ hi -<.> osuf way
+            need $ src : deps
+            build $ fullTargetWithWay target (Ghc stage) way [src] [hi]
+        else need [ hi -<.> osuf (detectWay hi) ]
 
     matchBuildResult buildPath "hi-boot" ?> \hiboot ->
-        need [ hiboot -<.> obootsuf (detectWay hiboot) ]
+        if compileInterfaceFilesSeparately
+        then do
+            let way = detectWay hiboot
+            (src, deps) <- dependencies buildPath $ hiboot -<.> obootsuf way
+            need $ src : deps
+            build $ fullTargetWithWay target (Ghc stage) way [src] [hiboot]
+        else need [ hiboot -<.> obootsuf (detectWay hiboot) ]
 
     -- TODO: add dependencies for #include of .h and .hs-incl files (gcc -MM?)
     matchBuildResult buildPath "o" ?> \obj -> do
diff --git a/src/Settings/Builders/Ghc.hs b/src/Settings/Builders/Ghc.hs
index 40b5a0f..0f1fc32 100644
--- a/src/Settings/Builders/Ghc.hs
+++ b/src/Settings/Builders/Ghc.hs
@@ -24,7 +24,9 @@ ghcBuilderArgs :: Args
 ghcBuilderArgs = stagedBuilder Ghc ? do
     output <- getOutput
     way    <- getWay
-    let buildObj = ("//*." ++ osuf way) ?== output || ("//*." ++ obootsuf way) ?== output
+    let buildObj  = ("//*." ++  osuf way) ?== output || ("//*." ++  obootsuf way) ?== output
+        buildHi   = ("//*." ++ hisuf way) ?== output || ("//*." ++ hibootsuf way) ?== output
+        buildProg = not (buildObj || buildHi)
     libs    <- getPkgDataList DepExtraLibs
     gmpLibs <- lift $ readFileLines gmpLibNameCache
     libDirs <- getPkgDataList DepLibDirs
@@ -35,12 +37,13 @@ ghcBuilderArgs = stagedBuilder Ghc ? do
             , arg "-Wall"
             , arg "-fwarn-tabs"
             , splitObjectsArgs
-            , not buildObj ? arg "-no-auto-link-packages"
-            , not buildObj ? append [ "-optl-l" ++ lib | lib <- libs ++ gmpLibs ]
-            , not buildObj ? append [ "-optl-L" ++ dir | dir <- libDirs ]
-            , buildObj ? arg "-c"
+            , buildProg ? arg "-no-auto-link-packages"
+            , buildProg ? append [ "-optl-l" ++ lib | lib <- libs ++ gmpLibs ]
+            , buildProg ? append [ "-optl-L" ++ dir | dir <- libDirs ]
+            , not buildProg ? arg "-c"
             , append =<< getInputs
-            , arg "-o", arg =<< getOutput ]
+            , buildHi ? append ["-fno-code", "-fwrite-interface"]
+            , not buildHi ? mconcat [ arg "-o", arg =<< getOutput ] ]
 
 splitObjectsArgs :: Args
 splitObjectsArgs = splitObjects ? do
diff --git a/src/Settings/User.hs b/src/Settings/User.hs
index 3cebe13..5b82571 100644
--- a/src/Settings/User.hs
+++ b/src/Settings/User.hs
@@ -3,7 +3,8 @@ module Settings.User (
     userArgs, userPackages, userLibWays, userRtsWays, userKnownPackages,
     integerLibrary, buildHaddock, validating, ghciWithDebugger, ghcProfiled,
     ghcDebugged, dynamicGhcPrograms, laxDependencies, buildSystemConfigFile,
-    verboseCommands, turnWarningsIntoErrors, splitObjects
+    verboseCommands, turnWarningsIntoErrors, splitObjects,
+    compileInterfaceFilesSeparately
     ) where
 
 import GHC
@@ -101,3 +102,7 @@ verboseCommands = return False
 -- | To enable -Werror in Stage2 set turnWarningsIntoErrors = stage2.
 turnWarningsIntoErrors :: Predicate
 turnWarningsIntoErrors = return False
+
+-- | Decouple the compilation of @*.hi@ and @*.o@ files by setting to True.
+compileInterfaceFilesSeparately :: Bool
+compileInterfaceFilesSeparately = True



More information about the ghc-commits mailing list