[Git][ghc/ghc][wip/inplace-final] 3 commits: fix prefix

Matthew Pickering (@mpickering) gitlab at gitlab.haskell.org
Sun Aug 21 21:29:36 UTC 2022



Matthew Pickering pushed to branch wip/inplace-final at Glasgow Haskell Compiler / GHC


Commits:
dda447ca by Matthew Pickering at 2022-08-21T22:28:48+01:00
fix prefix

- - - - -
09bdffd9 by Matthew Pickering at 2022-08-21T22:28:59+01:00
Remove uncessary deps

- - - - -
5aebb6cd by Matthew Pickering at 2022-08-21T22:29:23+01:00
fixes

- - - - -


4 changed files:

- hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
- hadrian/src/Rules/Library.hs
- hadrian/src/Rules/Register.hs
- hadrian/src/Rules/ToolArgs.hs


Changes:

=====================================
hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
=====================================
@@ -304,7 +304,7 @@ write_fake_conf pkg_path res_path pd lbi = do
               let fixupIncludeDir dir | cwd `isPrefixOf` dir = [prefix ++ drop (length cwd) dir]
                                       | otherwise            = [dir]
                     where
-                      prefix = "${pkgroot}/../../../../"
+                      prefix = "${pkgroot}/../../../"
               let installedPkgInfo =
 
                     C.inplaceInstalledPackageInfo (cwd </> pkg_path) build_dir pd (C.mkAbiHash "inplace") lib lbi clbi


=====================================
hadrian/src/Rules/Library.hs
=====================================
@@ -119,10 +119,7 @@ buildPackage root fp = do
   depPkgs <- packageDependencies <$> readPackageData (package ctx)
   -- Stage packages are those we have in this stage.
   stagePkgs <- stagePackages stage
-  -- We'll need those packages in our package database.
-  deps <- sequence [ pkgConfFile (ctx { package = pkg })
-                   | pkg <- depPkgs, pkg `elem` stagePkgs ]
-  need deps
+
   need (srcs ++ gens)
 
 --  ways <- interpretInContext context (getLibraryWays <> if package == rts then getRtsWays else mempty)


=====================================
hadrian/src/Rules/Register.hs
=====================================
@@ -119,14 +119,15 @@ registerPackageRules rs stage iplace = do
                 Final   -> buildConfFinal rs ctx conf
 
 buildConfFinal :: [(Resource, Int)] -> Context -> FilePath -> Action ()
-buildConfFinal _ context at Context {..} _conf = do
+buildConfFinal rs context at Context {..} _conf = do
     depPkgIds <- cabalDependencies context
     ensureConfigured context
-    need =<< mapM (\pkgId -> packageDbPath (PackageDbLoc stage Final) <&> (-/- pkgId <.> "conf")) depPkgIds
-
     ways <- interpretInContext context (getLibraryWays <> if package == rts then getRtsWays else mempty)
     need =<< mapM pkgStampFile [ context { way = w } | w <- Set.toList ways ]
 
+    need =<< mapM (\pkgId -> packageDbPath (PackageDbLoc stage Final) <&> (-/- pkgId <.> "conf")) depPkgIds
+
+
     -- We might need some package-db resource to limit read/write, see packageRules.
     path <- buildPath context
 
@@ -150,6 +151,8 @@ buildConfFinal _ context at Context {..} _conf = do
     -- Copy and register the package.
     Cabal.copyPackage context
     Cabal.registerPackage context
+    buildWithResources rs $
+      target context (GhcPkg Init stage) [] []
 
     -- We declare that this rule also produces files matching:
     --   - <root>/stage<N>/lib/<arch>-<os>-ghc-<version>/*libHS<pkgid>*
@@ -167,7 +170,7 @@ buildConfFinal _ context at Context {..} _conf = do
     produces files
 
 buildConfInplace :: [(Resource, Int)] -> Context -> FilePath -> Action ()
-buildConfInplace _ context at Context {..} _conf = do
+buildConfInplace rs context at Context {..} _conf = do
     depPkgIds <- cabalDependencies context
     ensureConfigured context
     need =<< mapM (\pkgId -> packageDbPath (PackageDbLoc stage Inplace) <&> (-/- pkgId <.> "conf")) depPkgIds
@@ -201,7 +204,7 @@ buildConfInplace _ context at Context {..} _conf = do
     conf <- pkgInplaceConfig context
 --    runBuilder (GhcPkg Update stage) [] [conf] []
 
-    build $
+    buildWithResources rs $
       target context (GhcPkg Update stage) [conf] []
 --    Cabal.
 


=====================================
hadrian/src/Rules/ToolArgs.hs
=====================================
@@ -16,6 +16,7 @@ import System.Directory (canonicalizePath)
 import System.Environment (lookupEnv)
 import qualified Data.Set as Set
 import Oracles.ModuleFiles
+import Utilities
 
 -- | @tool:@ is used by tooling in order to get the arguments necessary
 -- to set up a GHC API session which can compile modules from GHC. When
@@ -123,7 +124,7 @@ mkToolTarget es p = do
     -- this generically yet.
     putProgressInfo ("Computing arguments for " ++ pkgName p)
     allDeps
-    let fake_target = target (Context stage0InTree p (if windowsHost then vanilla else dynamic) Inplace)
+    let fake_target = target (Context stage0InTree p (if windowsHost then vanilla else dynamic) Final)
                         (Ghc ToolArgs stage0InTree) [] ["ignored"]
     arg_list <- interpret fake_target getArgs
     liftIO $ writeOutput (arg_list ++ es)
@@ -134,7 +135,7 @@ allDeps = do
     -- We can't build DLLs on Windows (yet). Actually we should only
     -- include the dynamic way when we have a dynamic host GHC, but just
     -- checking for Windows seems simpler for now.
-    let fake_target = target (Context stage0InTree compiler (if windowsHost then vanilla else dynamic) Inplace)
+    let fake_target = target (Context stage0InTree compiler (if windowsHost then vanilla else dynamic) Final)
                              (Ghc ToolArgs stage0InTree) [] ["ignored"]
 
     -- need the autogenerated files so that they are precompiled
@@ -189,6 +190,8 @@ toolTargets = [ binary
 -- | Create a mapping from files to which component it belongs to.
 dirMap :: Action [(FilePath, (Package, [String]))]
 dirMap = do
+  depPkgIds <- concat <$> mapM (cabalDependencies . vanillaContext stage0InTree) toolTargets
+  need =<< mapM (\pkgId -> packageDbPath (PackageDbLoc stage0InTree Final) <&> (-/- pkgId <.> "conf")) depPkgIds
   auto <- concatMapM go toolTargets
   -- Mush the ghc executable into the compiler component so the whole of ghc is not built when
   -- configuring
@@ -200,12 +203,12 @@ dirMap = do
     -- configuring would build the whole GHC library which we probably
     -- don't want to do.
     mkGhc = do
-      let c = (Context stage0InTree compiler (if windowsHost then vanilla else dynamic) Inplace)
+      let c = (Context stage0InTree compiler (if windowsHost then vanilla else dynamic) Final)
       cd <- readContextData c
       fp <- liftIO $ canonicalizePath "ghc/"
       return (fp, (compiler, "-ighc" : modules cd ++ otherModules cd ++ ["ghc/Main.hs"]))
     go p = do
-      let c = (Context stage0InTree p (if windowsHost then vanilla else dynamic) Inplace)
+      let c = (Context stage0InTree p (if windowsHost then vanilla else dynamic) Final)
       -- readContextData has the effect of configuring the package so all
       -- dependent packages will also be built.
       cd <- readContextData c



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/aed9cf4fe1d1c419b7ab7d3f3569c2f4fd7b77b3...5aebb6cd77ecc9e07c0e45e8b1880811d5b9b71e

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/aed9cf4fe1d1c419b7ab7d3f3569c2f4fd7b77b3...5aebb6cd77ecc9e07c0e45e8b1880811d5b9b71e
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20220821/f4c8cc7b/attachment-0001.html>


More information about the ghc-commits mailing list