[commit: ghc] wip/nfs-locking: Add support for utility packages. (2f1eda7)

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


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

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

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

commit 2f1eda773f2d11e11e9f46591078e50be94e458b
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Thu Dec 10 01:42:07 2015 +0000

    Add support for utility packages.


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

2f1eda773f2d11e11e9f46591078e50be94e458b
 src/GHC.hs                   | 18 +++++++++++-------
 src/Package.hs               |  9 ++++++---
 src/Rules/Library.hs         |  8 +++-----
 src/Settings/Builders/Ghc.hs |  3 +--
 src/Settings/Packages.hs     |  3 ++-
 5 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/src/GHC.hs b/src/GHC.hs
index 668cf48..de482f4 100644
--- a/src/GHC.hs
+++ b/src/GHC.hs
@@ -1,6 +1,6 @@
 module GHC (
     array, base, binPackageDb, binary, bytestring, cabal, compiler, containers,
-    deepseq, directory, filepath, ghc, ghcPrim, haskeline, hoopl, hpc,
+    deepseq, directory, filepath, ghc, ghcCabal, ghcPrim, haskeline, hoopl, hpc,
     integerGmp, integerSimple, parallel, pretty, primitive, process, stm,
     templateHaskell, terminfo, time, transformers, unix, win32, xhtml,
 
@@ -19,13 +19,14 @@ import Stage
 defaultKnownPackages :: [Package]
 defaultKnownPackages =
     [ array, base, binPackageDb, binary, bytestring, cabal, compiler
-    , containers, deepseq, directory, filepath, ghc, ghcPrim, haskeline, hoopl
-    , hpc, integerGmp, integerSimple, parallel, pretty, primitive, process, stm
-    , templateHaskell, terminfo, time, transformers, unix, win32, xhtml ]
+    , containers, deepseq, directory, filepath, ghc, ghcCabal, ghcPrim
+    , haskeline, hoopl, hpc, integerGmp, integerSimple, parallel, pretty
+    , primitive, process, stm, templateHaskell, terminfo, time, transformers
+    , unix, win32, xhtml ]
 
 -- Package definitions
 array, base, binPackageDb, binary, bytestring, cabal, compiler, containers,
-    deepseq, directory, filepath, ghc, ghcPrim, haskeline, hoopl, hpc,
+    deepseq, directory, filepath, ghc, ghcCabal, ghcPrim, haskeline, hoopl, hpc,
     integerGmp, integerSimple, parallel, pretty, primitive, process, stm,
     templateHaskell, terminfo, time, transformers, unix, win32, xhtml :: Package
 
@@ -41,6 +42,7 @@ deepseq         = library  "deepseq"
 directory       = library  "directory"
 filepath        = library  "filepath"
 ghc             = topLevel "ghc-bin"        `setPath` "ghc"
+ghcCabal        = utility  "ghc-cabal"
 ghcPrim         = library  "ghc-prim"
 haskeline       = library  "haskeline"
 hoopl           = library  "hoopl"
@@ -60,6 +62,7 @@ unix            = library  "unix"
 win32           = library  "Win32"
 xhtml           = library  "xhtml"
 
+
 -- GHC build results will be placed into target directories with the following
 -- typical structure:
 -- * build/          : contains compiled object code
@@ -75,8 +78,9 @@ defaultTargetDirectory stage pkg
 
 defaultProgramPath :: Stage -> Package -> Maybe FilePath
 defaultProgramPath stage pkg
-    | pkg == ghc = program $ "ghc-stage" ++ show (fromEnum stage + 1)
-    | otherwise  = Nothing
+    | pkg == ghc      = program $ "ghc-stage" ++ show (fromEnum stage + 1)
+    | pkg == ghcCabal = program $ pkgName pkg
+    | otherwise       = Nothing
   where
     program name = Just $ pkgPath pkg -/- defaultTargetDirectory stage pkg
                                       -/- "build/tmp" -/- name <.> exe
diff --git a/src/Package.hs b/src/Package.hs
index fba192c..85fbd13 100644
--- a/src/Package.hs
+++ b/src/Package.hs
@@ -1,6 +1,6 @@
 {-# LANGUAGE DeriveGeneric #-}
 module Package (
-    Package (..), PackageName, pkgCabalFile, setPath, library, topLevel
+    Package (..), PackageName, pkgCabalFile, setPath, topLevel, library, utility
     ) where
 
 import Base
@@ -21,11 +21,14 @@ data Package = Package
 pkgCabalFile :: Package -> FilePath
 pkgCabalFile pkg = pkgPath pkg -/- pkgName pkg <.> "cabal"
 
+topLevel :: PackageName -> Package
+topLevel name = Package name name
+
 library :: PackageName -> Package
 library name = Package name ("libraries" -/- name)
 
-topLevel :: PackageName -> Package
-topLevel name = Package name name
+utility :: PackageName -> Package
+utility name = Package name ("utils" -/- name)
 
 setPath :: Package -> FilePath -> Package
 setPath pkg path = pkg { pkgPath = path }
diff --git a/src/Rules/Library.hs b/src/Rules/Library.hs
index b0afdc6..1bf668d 100644
--- a/src/Rules/Library.hs
+++ b/src/Rules/Library.hs
@@ -71,8 +71,6 @@ hSources target = do
     return . map (replaceEq '.' '/') . filter (/= "GHC.Prim") $ modules
 
 extraObjects :: PartialTarget -> Action [FilePath]
-extraObjects (PartialTarget _ pkg) = do
-    gmpObjs <- getDirectoryFiles "" [pkgPath pkg -/- "gmp/objs/*.o"]
-    if pkg == integerGmp
-    then return gmpObjs
-    else return []
+extraObjects (PartialTarget _ pkg)
+    | pkg == integerGmp = getDirectoryFiles "" [pkgPath pkg -/- "gmp/objs/*.o"]
+    | otherwise         = return []
diff --git a/src/Settings/Builders/Ghc.hs b/src/Settings/Builders/Ghc.hs
index 8d1a30f..15944f3 100644
--- a/src/Settings/Builders/Ghc.hs
+++ b/src/Settings/Builders/Ghc.hs
@@ -7,7 +7,6 @@ import Oracles
 import GHC
 import Predicates (package, stagedBuilder, splitObjects, stage0, notStage0)
 import Settings
-import Settings.Builders.GhcCabal
 
 -- TODO: add support for -dyno
 -- TODO: consider adding a new builder for programs (e.g. GhcLink?)
@@ -30,7 +29,7 @@ ghcArgs = stagedBuilder Ghc ? do
             , arg "-fwarn-tabs"
             , buildObj ? splitObjects ? arg "-split-objs"
             , package ghc ? arg "-no-hs-main"
-            , not buildObj ? arg "-no-auto-link-packages"
+            -- , not buildObj ? arg "-no-auto-link-packages"
             , not buildObj ? append [ "-optl-l" ++ lib | lib <- libs    ]
             , not buildObj ? append [ "-optl-L" ++ dir | dir <- libDirs ]
             , buildObj ? arg "-c"
diff --git a/src/Settings/Packages.hs b/src/Settings/Packages.hs
index 1fe70dc..5ac9c6e 100644
--- a/src/Settings/Packages.hs
+++ b/src/Settings/Packages.hs
@@ -25,7 +25,8 @@ packagesStage1 :: Packages
 packagesStage1 = mconcat
     [ packagesStage0
     , append [ array, base, bytestring, containers, deepseq, directory, filepath
-             , ghcPrim, haskeline, integerLibrary, pretty, process, time ]
+             , ghcCabal, ghcPrim, haskeline, integerLibrary, pretty, process
+             , time ]
     , windowsHost      ? append [win32]
     , notM windowsHost ? append [unix]
     , buildHaddock     ? append [xhtml] ]



More information about the ghc-commits mailing list