[commit: ghc] wip/nfs-locking: Allow cmm files in non-custom packages (5b9f6e9)

git at git.haskell.org git at git.haskell.org
Fri Oct 27 01:18:18 UTC 2017


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

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

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

commit 5b9f6e901eb3613544aaf941d33419fb9f8368d0
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Wed Apr 26 01:53:28 2017 +0100

    Allow cmm files in non-custom packages


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

5b9f6e901eb3613544aaf941d33419fb9f8368d0
 src/Rules/Data.hs    |  9 ++++++---
 src/Rules/Library.hs | 21 ++++++++++++++-------
 2 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/src/Rules/Data.hs b/src/Rules/Data.hs
index cff0896..0538f6c 100644
--- a/src/Rules/Data.hs
+++ b/src/Rules/Data.hs
@@ -102,13 +102,16 @@ packageCmmSources pkg
 -- Prepare a given 'packaga-data.mk' file for parsing by readConfigFile:
 -- 1) Drop lines containing '$'. For example, get rid of
 -- @libraries/Win32_dist-install_CMM_SRCS  := $(addprefix cbits/,$(notdir ...@
--- Reason: we don't need them and we can't parse them.
+-- and replace it with a tracked call to getDirectoryFiles.
 -- 2) Drop path prefixes to individual settings.
 -- For example, @libraries/deepseq/dist-install_VERSION = 1.4.0.0@
 -- is replaced by @VERSION = 1.4.0.0 at .
 -- Reason: Shake's built-in makefile parser doesn't recognise slashes
 postProcessPackageData :: Context -> FilePath -> Action ()
 postProcessPackageData context at Context {..} file = do
-    top <- topDirectory
+    top     <- topDirectory
+    cmmSrcs <- getDirectoryFiles (pkgPath package) ["cbits/*.cmm"]
     let len = length (pkgPath package) + length (top -/- buildPath context) + 2
-    fixFile file $ unlines . map (drop len) . filter ('$' `notElem`) . lines
+    fixFile file $ unlines
+                 . (++ ["CMM_SRCS = " ++ unwords (map unifyPath cmmSrcs) ])
+                 . map (drop len) . filter ('$' `notElem`) . lines
diff --git a/src/Rules/Library.hs b/src/Rules/Library.hs
index 2deb6f9..32db232 100644
--- a/src/Rules/Library.hs
+++ b/src/Rules/Library.hs
@@ -23,12 +23,8 @@ buildPackageLibrary context at Context {..} = do
     -- TODO: handle dynamic libraries
     matchVersionedFilePath libPrefix (waySuffix way <.> "a") ?> \a -> do
         removeFile a
-        asmObjs <- map (objectPath context) <$> pkgDataList (AsmSrcs path)
-        cObjs   <- cObjects  context
-        cmmObjs <- map (objectPath context) <$> pkgDataList (CmmSrcs path)
-        eObjs   <- extraObjects context
-        hsObjs  <- hsObjects context
-        let noHsObjs = asmObjs ++ cObjs ++ cmmObjs ++ eObjs
+        hsObjs   <- hsObjects    context
+        noHsObjs <- nonHsObjects context
 
         -- This will create split objects if required (we don't track them
         -- explicitly as this would needlessly bloat the Shake database).
@@ -56,10 +52,21 @@ buildPackageGhciLibrary :: Context -> Rules ()
 buildPackageGhciLibrary context at Context {..} = priority 2 $ do
     let libPrefix = buildPath context -/- "HS" ++ pkgNameString package
     matchVersionedFilePath libPrefix (waySuffix way <.> "o") ?> \obj -> do
-        objs <- concatMapM ($ context) [cObjects, hsObjects, extraObjects]
+        objs <- allObjects context
         need objs
         build $ Target context Ld objs [obj]
 
+allObjects :: Context -> Action [FilePath]
+allObjects context = (++) <$> nonHsObjects context <*> hsObjects context
+
+nonHsObjects :: Context -> Action [FilePath]
+nonHsObjects context = do
+    let path = buildPath context
+    cObjs   <- cObjects context
+    cmmObjs <- map (objectPath context) <$> pkgDataList (CmmSrcs path)
+    eObjs   <- extraObjects context
+    return $ cObjs ++ cmmObjs ++ eObjs
+
 cObjects :: Context -> Action [FilePath]
 cObjects context = do
     objs <- map (objectPath context) <$> pkgDataList (CSrcs $ buildPath context)



More information about the ghc-commits mailing list