summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-02-19 15:44:10 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-02-20 21:56:20 -0500
commit581753790da8d094ce05b3fc5f5360f5fbf6a7da (patch)
treed6a1205c4ed38e893541f3bebd7828cd2555dfdc
parentabd7f962a9a9207c07cb864921941750818f61a4 (diff)
downloadhaskell-581753790da8d094ce05b3fc5f5360f5fbf6a7da.tar.gz
Hadrian: minor GMP refactoring
Somehow I forgot to totally remove `gmpContext` in d7029cc09edc052c2f97effe33233c53340fcce0. This patch fixes it and adds some additional comments.
-rw-r--r--hadrian/src/Rules/Gmp.hs50
1 files changed, 27 insertions, 23 deletions
diff --git a/hadrian/src/Rules/Gmp.hs b/hadrian/src/Rules/Gmp.hs
index 0524fbed98..2bf41d99e2 100644
--- a/hadrian/src/Rules/Gmp.hs
+++ b/hadrian/src/Rules/Gmp.hs
@@ -9,7 +9,8 @@ import Target
import Utilities
import Hadrian.BuildPath
--- | Build GMP library objects and return their paths.
+-- | Build in-tree GMP library objects (if GmpInTree flag is set) and return
+-- their paths.
gmpObjects :: Stage -> Action [FilePath]
gmpObjects s = do
isInTree <- flag GmpInTree
@@ -22,39 +23,36 @@ gmpObjects s = do
need [integerGmpPath -/- "include/ghc-gmp.h"]
-- The line below causes a Shake Lint failure on Windows, which forced
- -- us to disable Lint by default. See more details here:
- -- https://gitlab.haskell.org/ghc/ghc/issues/15971.
+ -- us to disable Lint by default (we don't track the object files of the
+ -- in-tree GMP library).
+ -- See more details here: https://gitlab.haskell.org/ghc/ghc/issues/15971.
gmpPath <- gmpIntreePath s
map (unifyPath . (gmpPath -/-)) <$>
liftIO (getDirectoryFilesIO gmpPath [gmpObjectsDir -/- "*.o"])
-gmpBase :: FilePath
-gmpBase = pkgPath integerGmp -/- "gmp"
-
--- | GMP is considered a Stage1 package. This determines GMP build directory.
-gmpContext :: Context
-gmpContext = vanillaContext Stage1 integerGmp
-
--- | Build directory for in-tree GMP library.
+-- | Build directory for in-tree GMP library
+-- <root>/stageN/gmp/gmpbuild
gmpBuildPath :: Stage -> Action FilePath
gmpBuildPath s = gmpIntreePath s <&> (-/- "gmpbuild")
+-- | Root directory for in-tree GMP library
+-- <root>/stageN/gmp
gmpIntreePath :: Stage -> Action FilePath
gmpIntreePath s = buildRoot <&> (-/- stageString s -/- "gmp")
--- | Directory for GMP library object files, relative to 'gmpIntreePath'.
+-- | Directory for in-tree GMP library object files, relative to 'gmpIntreePath'.
gmpObjectsDir :: FilePath
gmpObjectsDir = "objs"
-configureEnvironment :: Stage -> Action [CmdOption]
-configureEnvironment s = sequence [ builderEnvironment "CC" $ Cc CompileC s
- , builderEnvironment "AR" (Ar Unpack s)
- , builderEnvironment "NM" Nm ]
-
gmpRules :: Rules ()
gmpRules = do
root <- buildRootRules
+ let
+ -- Path to libraries/integer-gmp/gmp in the source tree
+ gmpBase :: FilePath
+ gmpBase = pkgPath integerGmp -/- "gmp"
+
-- Build in-tree gmp if necessary
-- Produce: integer-gmp/build/include/ghc-gmp.h
-- In-tree: copy gmp.h from in-tree build
@@ -121,18 +119,24 @@ gmpRules = do
let gmpBuildP = takeDirectory mk
gmpP = takeDirectory gmpBuildP
ctx <- makeGmpPathContext gmpP
- env <- configureEnvironment (stage ctx)
+ env <- sequence
+ [ builderEnvironment "CC" $ Cc CompileC (stage ctx)
+ , builderEnvironment "AR" (Ar Unpack (stage ctx))
+ , builderEnvironment "NM" Nm
+ ]
need [mk <.> "in"]
buildWithCmdOptions env $
- target gmpContext (Configure gmpBuildP) [mk <.> "in"] [mk]
+ target ctx (Configure gmpBuildP) [mk <.> "in"] [mk]
-- Extract in-tree GMP sources and apply patches. Produce
-- - <root>/stageN/gmp/gmpbuild/Makefile.in
-- - <root>/stageN/gmp/gmpbuild/configure
[gmpPath -/- "gmpbuild/Makefile.in", gmpPath -/- "gmpbuild/configure"] &%> \[mkIn,_] -> do
top <- topDirectory
- let destPath = takeDirectory mkIn
- removeDirectory destPath
+ let gmpBuildP = takeDirectory mkIn
+ gmpP = takeDirectory gmpBuildP
+ ctx <- makeGmpPathContext gmpP
+ removeDirectory gmpBuildP
-- Note: We use a tarball like gmp-4.2.4-nodoc.tar.bz2, which is
-- gmp-4.2.4.tar.bz2 repacked without the doc/ directory contents.
-- That's because the doc/ directory contents are under the GFDL,
@@ -143,7 +147,7 @@ gmpRules = do
withTempDir $ \dir -> do
let tmp = unifyPath dir
need [top -/- tarball]
- build $ target gmpContext (Tar Extract) [top -/- tarball] [tmp]
+ build $ target ctx (Tar Extract) [top -/- tarball] [tmp]
let patch = gmpBase -/- "gmpsrc.patch"
patchName = takeFileName patch
@@ -155,4 +159,4 @@ gmpRules = do
++ "-nodoc (found: " ++ name ++ ")."
libName = unpack $ stripSuffix "-nodoc" name
- moveDirectory (tmp -/- libName) destPath
+ moveDirectory (tmp -/- libName) gmpBuildP