[Git][ghc/ghc][wip/fix-cabal-reinstall-2] Fixes for cabal-reinstall CI job

Matthew Pickering (@mpickering) gitlab at gitlab.haskell.org
Mon Jan 30 09:36:58 UTC 2023



Matthew Pickering pushed to branch wip/fix-cabal-reinstall-2 at Glasgow Haskell Compiler / GHC


Commits:
b4db0468 by Matthew Pickering at 2023-01-30T09:36:43+00:00
Fixes for cabal-reinstall CI job

* Allow filepath to be reinstalled
* Bump some version bounds to allow newer versions of libraries
* Rework testing logic to avoid "install --lib" and package env files

Fixes #22344

- - - - -


8 changed files:

- .gitlab-ci.yml
- cabal.project-reinstall
- compiler/ghc.cabal.in
- hadrian/src/Rules/CabalReinstall.hs
- hadrian/src/Settings/Builders/Cabal.hs
- libraries/ghc-boot/ghc-boot.cabal.in
- linters/lint-commit-msg/lint-commit-msg.cabal
- linters/lint-whitespace/lint-whitespace.cabal


Changes:

=====================================
.gitlab-ci.yml
=====================================
@@ -454,6 +454,7 @@ test-cabal-reinstall-x86_64-linux-deb10:
     TEST_ENV: "x86_64-linux-deb10-cabal-install"
   rules:
     - if: $NIGHTLY
+    - if: '$CI_MERGE_REQUEST_LABELS =~ /.*test-reinstall.*/'
 
 ########################################
 # Testing ABI is invariant across builds


=====================================
cabal.project-reinstall
=====================================
@@ -12,7 +12,7 @@ packages: ./compiler
           -- ./libraries/deepseq/
           ./libraries/directory/
           ./libraries/exceptions/
-          -- ./libraries/filepath/
+          ./libraries/filepath/
           -- ./libraries/ghc-bignum/
            ./libraries/ghc-boot/
           -- ./libraries/ghc-boot-th/
@@ -55,7 +55,6 @@ constraints: ghc +internal-interpreter +dynamic-system-linke,
              any.array installed,
              any.base installed,
              any.deepseq installed,
-             any.filepath installed,
              any.ghc-bignum installed,
              any.ghc-boot-th installed,
              any.integer-gmp installed,


=====================================
compiler/ghc.cabal.in
=====================================
@@ -39,7 +39,7 @@ extra-source-files:
 
 
 custom-setup
-    setup-depends: base >= 3 && < 5, Cabal >= 1.6 && <3.9, directory, process, filepath
+    setup-depends: base >= 3 && < 5, Cabal >= 1.6 && <3.10, directory, process, filepath
 
 Flag internal-interpreter
     Description: Build with internal interpreter support.


=====================================
hadrian/src/Rules/CabalReinstall.hs
=====================================
@@ -11,6 +11,7 @@ import qualified System.Directory.Extra as IO
 import Data.Either
 import Rules.BinaryDist
 import Hadrian.Haskell.Cabal (pkgIdentifier)
+import Oracles.Setting
 
 {-
 Note [Testing reinstallable GHC]
@@ -26,18 +27,11 @@ The libdir of the reinstalled GHC points to the libdir of the stage 2 compiler (
 cabalExcludedPackages :: [Package]
 cabalExcludedPackages = [array, base, deepseq, filepath, ghcBignum, ghcBootTh, ghcPrim, integerGmp, integerSimple, pretty, templateHaskell]
 
-findCabalPackageDb :: String -> FilePath
-findCabalPackageDb env = go $ map (\l -> (words l, l)) (lines env)
-  where
-    go [] = error $ "Couldn't find installed package db in " ++ show env
-    go (("package-db":_, l):_) = drop 11 l
-    go (_:xs) = go xs
-
 
 cabalBuildRules :: Rules ()
 cabalBuildRules = do
     root <- buildRootRules
-    root -/- "stage-cabal" -/- "cabal-packages" %> \_ -> do
+    root -/- "stage-cabal" -/- "cabal-packages" %> \outpath -> do
       -- Always rerun to pass onto cabal's own recompilation logic
       alwaysRerun
       all_pkgs <- stagePackages Stage1
@@ -45,6 +39,7 @@ cabalBuildRules = do
         withVerbosity Diagnostic $
           buildWithCmdOptions [] $
             target (vanillaContext Stage2 pkg) (Cabal Install Stage2) [] []
+      liftIO $ writeFile outpath "done"
 
     phony "build-cabal" $ need [root -/- "stage-cabal" -/- "bin" -/- ".stamp"]
 
@@ -73,8 +68,11 @@ cabalBuildRules = do
         createDirectory outputDir
 
         need [root -/- "stage-cabal" -/- "cabal-packages"]
-        env <- liftIO $ readFile $ root -/- "stage-cabal" -/- "cabal-packages"
-        let cabal_package_db = findCabalPackageDb env
+
+        cwd <- liftIO $ IO.getCurrentDirectory
+        version        <- setting ProjectVersion
+
+        let cabal_package_db = cwd -/- root -/- "stage-cabal" -/- "dist-newstyle" -/- "packagedb" -/- "ghc-" ++ version
 
         forM_ (filter ((/= iserv) . fst) bin_targets) $ \(bin_pkg,_bin_path) -> do
             let pgmName pkg


=====================================
hadrian/src/Settings/Builders/Cabal.hs
=====================================
@@ -27,9 +27,10 @@ cabalInstallArgs = builder (Cabal Install) ?  do
         | otherwise     = pkgName pkg
   assertNoBuildRootLeak $
     mconcat [ arg $ "--store-dir="   ++ (root -/- "stage-cabal" -/- "cabal-store")
-            , arg "install"
-            , if isProgram pkg then arg $ "exe:" ++ pgmName else mconcat [arg "--lib", arg $ pkgName pkg]
+            , if isProgram pkg then arg "install" else arg "build"
+            , if isProgram pkg then (arg $ "exe:" ++ pgmName) else (arg $ pkgName pkg)
             , commonReinstallCabalArgs
+            , if isProgram pkg then extraInstallArgs else mempty
             ]
 
 -- | Checks that _build/stageN/lib/* doesn't leak into the arguments for
@@ -45,6 +46,13 @@ assertNoBuildRootLeak args = do
                                        | libPath <- libPaths]) xs)
                 xs
 
+extraInstallArgs :: Args
+extraInstallArgs = do
+    root      <- getBuildRoot
+    mconcat [ arg $ "--install-method=copy"
+            , arg $ "--overwrite-policy=always"
+            , arg $ "--installdir="  ++ (root -/- "stage-cabal" -/- "cabal-bin") ]
+
 commonReinstallCabalArgs :: Args
 commonReinstallCabalArgs = do
     top       <- expr topDirectory
@@ -56,12 +64,7 @@ commonReinstallCabalArgs = do
             , arg $ top -/- "cabal.project-reinstall"
             , arg "--distdir"
             , arg $ root -/- "stage-cabal" -/- "dist-newstyle"
-            , arg ("--ghc-option=-j" ++ show threads)
-            , arg $ "--install-method=copy"
-            , arg $ "--overwrite-policy=always"
             , arg $ "--with-compiler=" ++ top -/- compiler
-            , arg $ "--installdir="  ++ (root -/- "stage-cabal" -/- "cabal-bin")
-            , arg $ "--package-env=" ++ (root -/- "stage-cabal" -/- "cabal-packages")
             , arg "--enable-executable-dynamic"
             , arg "--enable-library-vanilla"
             ]


=====================================
libraries/ghc-boot/ghc-boot.cabal.in
=====================================
@@ -28,7 +28,7 @@ build-type:     Custom
 extra-source-files: changelog.md
 
 custom-setup
-    setup-depends: base >= 3 && < 5, Cabal >= 1.6 && <3.9, directory, filepath
+    setup-depends: base >= 3 && < 5, Cabal >= 1.6 && <3.10, directory, filepath
 
 source-repository head
     type:     git


=====================================
linters/lint-commit-msg/lint-commit-msg.cabal
=====================================
@@ -22,7 +22,7 @@ executable lint-commit-msg
   build-depends:
     linters-common,
     mtl
-      >=2.1 && <2.3,
+      >=2.1 && <2.4,
     base
        >= 4.14 && < 5,
     text


=====================================
linters/lint-whitespace/lint-whitespace.cabal
=====================================
@@ -20,7 +20,7 @@ executable lint-whitespace
   build-depends:
     linters-common,
     mtl
-      >=2.1 && <2.3,
+      >=2.1 && <2.4,
     process
       ^>= 1.6,
     containers



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b4db0468e84bb3bf8d0d8c486a949c2ce7dbe74e

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b4db0468e84bb3bf8d0d8c486a949c2ce7dbe74e
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/20230130/ac5c44fe/attachment-0001.html>


More information about the ghc-commits mailing list