[commit: ghc] master: Hadrian: Make libsuf and distDir stage aware (6126455)

git at git.haskell.org git at git.haskell.org
Tue Mar 12 13:15:20 UTC 2019


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/61264556d5c817b55332a199b03fa1f559e92ee2/ghc

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

commit 61264556d5c817b55332a199b03fa1f559e92ee2
Author: Matthew Pickering <matthewtpickering at gmail.com>
Date:   Sun Mar 10 17:34:42 2019 +0000

    Hadrian: Make libsuf and distDir stage aware
    
    The version suffix needs to be the version of the stage 0 compiler
    when building shared libraries with the stage 0 compiler.


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

61264556d5c817b55332a199b03fa1f559e92ee2
 hadrian/src/Context.hs               |  8 ++++----
 hadrian/src/Oracles/Setting.hs       | 10 +++++++---
 hadrian/src/Rules/BinaryDist.hs      |  2 +-
 hadrian/src/Rules/Libffi.hs          |  2 +-
 hadrian/src/Settings/Builders/Ghc.hs |  3 ++-
 5 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/hadrian/src/Context.hs b/hadrian/src/Context.hs
index f8a07d7..4ecf101 100644
--- a/hadrian/src/Context.hs
+++ b/hadrian/src/Context.hs
@@ -52,9 +52,9 @@ libPath Context {..} = buildRoot <&> (-/- (stageString stage -/- "lib"))
 --
 -- We preform some renaming to accomodate Cabal's slightly different naming
 -- conventions (see 'cabalOsString' and 'cabalArchString').
-distDir :: Action FilePath
-distDir = do
-    version        <- setting ProjectVersion
+distDir :: Stage -> Action FilePath
+distDir st = do
+    version        <- ghcVersionStage st
     hostOs         <- cabalOsString <$> setting BuildOs
     hostArch       <- cabalArchString <$> setting BuildArch
     return $ hostArch ++ "-" ++ hostOs ++ "-ghc-" ++ version
@@ -85,7 +85,7 @@ pkgHaddockFile Context {..} = do
 -- @_build/stage1/libraries/array/build/libHSarray-0.5.1.0.a at .
 pkgLibraryFile :: Context -> Action FilePath
 pkgLibraryFile context at Context {..} = do
-    extension <- libsuf way
+    extension <- libsuf stage way
     pkgFile context "libHS" extension
 
 -- | Path to the GHCi library file of a given 'Context', e.g.:
diff --git a/hadrian/src/Oracles/Setting.hs b/hadrian/src/Oracles/Setting.hs
index 02ac42e..4666539 100644
--- a/hadrian/src/Oracles/Setting.hs
+++ b/hadrian/src/Oracles/Setting.hs
@@ -210,6 +210,10 @@ ghcCanonVersion = do
 topDirectory :: Action FilePath
 topDirectory = fixAbsolutePathOnWindows =<< setting GhcSourcePath
 
+ghcVersionStage :: Stage -> Action String
+ghcVersionStage Stage0 = setting GhcVersion
+ghcVersionStage _      = setting ProjectVersion
+
 -- | The file suffix used for libraries of a given build 'Way'. For example,
 -- @_p.a@ corresponds to a static profiled library, and @-ghc7.11.20141222.so@
 -- is a dynamic vanilly library. Why do we need GHC version number in the
@@ -219,11 +223,11 @@ topDirectory = fixAbsolutePathOnWindows =<< setting GhcSourcePath
 -- live in their own per-package directory and hence do not need a unique
 -- filename. We also need to respect the system's dynamic extension, e.g. @.dll@
 -- or @.so at .
-libsuf :: Way -> Action String
-libsuf way
+libsuf :: Stage -> Way -> Action String
+libsuf st way
     | not (wayUnit Dynamic way) = return (waySuffix way ++ ".a") -- e.g., _p.a
     | otherwise = do
         extension <- setting DynamicExtension -- e.g., .dll or .so
-        version   <- setting ProjectVersion   -- e.g., 7.11.20141222
+        version   <- ghcVersionStage st -- e.g. 8.4.4 or 8.9.xxxx
         let suffix = waySuffix (removeWayUnit Dynamic way)
         return (suffix ++ "-ghc" ++ version ++ extension)
diff --git a/hadrian/src/Rules/BinaryDist.hs b/hadrian/src/Rules/BinaryDist.hs
index 609766d..610e668 100644
--- a/hadrian/src/Rules/BinaryDist.hs
+++ b/hadrian/src/Rules/BinaryDist.hs
@@ -98,7 +98,7 @@ bindistRules = do
 
         version        <- setting ProjectVersion
         targetPlatform <- setting TargetPlatformFull
-        distDir        <- Context.distDir
+        distDir        <- Context.distDir Stage1
         rtsDir         <- pkgIdentifier rts
         windows        <- windowsHost
 
diff --git a/hadrian/src/Rules/Libffi.hs b/hadrian/src/Rules/Libffi.hs
index 5b25aab..ddc739d 100644
--- a/hadrian/src/Rules/Libffi.hs
+++ b/hadrian/src/Rules/Libffi.hs
@@ -60,7 +60,7 @@ libffiLibrary = "inst/lib/libffi.a"
 rtsLibffiLibrary :: Stage -> Way -> Action FilePath
 rtsLibffiLibrary stage way = do
     name    <- libffiLibraryName
-    suf     <- libsuf way
+    suf     <- libsuf stage way
     rtsPath <- rtsBuildPath stage
     return $ rtsPath -/- "lib" ++ name ++ suf
 
diff --git a/hadrian/src/Settings/Builders/Ghc.hs b/hadrian/src/Settings/Builders/Ghc.hs
index b952a01..7fb3082 100644
--- a/hadrian/src/Settings/Builders/Ghc.hs
+++ b/hadrian/src/Settings/Builders/Ghc.hs
@@ -53,7 +53,8 @@ ghcLinkArgs = builder (Ghc LinkHs) ? do
     originPath <- dropFileName <$> getOutput
     context <- getContext
     libPath' <- expr (libPath context)
-    distDir <- expr Context.distDir
+    st <- getStage
+    distDir <- expr (Context.distDir st)
 
     useSystemFfi <- expr (flag UseSystemFfi)
     buildPath <- getBuildPath



More information about the ghc-commits mailing list