From 114c294c1ed963fc2ccd8c80f598b3e2465eef71 Mon Sep 17 00:00:00 2001 From: Herbert Valerio Riedel Date: Sat, 24 Feb 2018 17:30:00 +0100 Subject: [PATCH] Implement ghc/cabal compatiblity matrix (re #415) This injects lower-bound constraints on Cabal for custom setup dependencies to prevent the solver from selecting unsupported configurations. Previously we already added an absolute lower bound `Cabal >= 1.20` for nix-local builds, as that's the minimum version we need to be able to interact with custom Setup.hs scripts. This refines with logic by restricting that lower bound even more based on GHC version. This patch augments this with the following rules: - GHC 8.4+ constrains Cabal >= 2.2 - GHC 8.2 constrains Cabal >= 2.0 - GHC 8.0 constrains Cabal >= 1.24 - GHC 7.10 constrains Cabal >= 1.22 - (default constraint Cabal >= 1.20) This only affects nix-style local builds codepaths. (cherry picked from commit 71e797eac3b342f2b83a2e51c3fb4d9592c9b7d4) --- .../Distribution/Client/ProjectPlanning.hs | 54 ++++++++++++++----- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/cabal-install/Distribution/Client/ProjectPlanning.hs b/cabal-install/Distribution/Client/ProjectPlanning.hs index 02287958b5d..ecefdbbc81f 100644 --- a/cabal-install/Distribution/Client/ProjectPlanning.hs +++ b/cabal-install/Distribution/Client/ProjectPlanning.hs @@ -949,18 +949,7 @@ planPackages verbosity comp platform solver SolverSettings{..} . PD.packageDescription . packageDescription) - . addSetupCabalMinVersionConstraint (mkVersion [1,20]) - -- While we can talk to older Cabal versions (we need to be able to - -- do so for custom Setup scripts that require older Cabal lib - -- versions), we have problems talking to some older versions that - -- don't support certain features. - -- - -- For example, Cabal-1.16 and older do not know about build targets. - -- Even worse, 1.18 and older only supported the --constraint flag - -- with source package ids, not --dependency with installed package - -- ids. That is bad because we cannot reliably select the right - -- dependencies in the presence of multiple instances (i.e. the - -- store). See issue #3932. So we require Cabal 1.20 as a minimum. + . addSetupCabalMinVersionConstraint setupMinCabalVersionConstraint . addPreferences -- preferences from the config file or command line @@ -1029,6 +1018,47 @@ planPackages verbosity comp platform solver SolverSettings{..} installedPkgIndex sourcePkgDb localPackages + -- While we can talk to older Cabal versions (we need to be able to + -- do so for custom Setup scripts that require older Cabal lib + -- versions), we have problems talking to some older versions that + -- don't support certain features. + -- + -- For example, Cabal-1.16 and older do not know about build targets. + -- Even worse, 1.18 and older only supported the --constraint flag + -- with source package ids, not --dependency with installed package + -- ids. That is bad because we cannot reliably select the right + -- dependencies in the presence of multiple instances (i.e. the + -- store). See issue #3932. So we require Cabal 1.20 as a minimum. + -- + -- Moreover, lib:Cabal generally only supports the interface of + -- current and past compilers; in fact recent lib:Cabal versions + -- will warn when they encounter a too new or unknown GHC compiler + -- version (c.f. #415). To avoid running into unsupported + -- configurations we encode the compatiblity matrix as lower + -- bounds on lib:Cabal here (effectively corresponding to the + -- respective major Cabal version bundled with the respective GHC + -- release). + -- + -- GHC 8.4 needs Cabal >= 2.2 + -- GHC 8.2 needs Cabal >= 2.0 + -- GHC 8.0 needs Cabal >= 1.24 + -- GHC 7.10 needs Cabal >= 1.22 + -- + -- (NB: we don't need to consider older GHCs as Cabal >= 1.20 is + -- the absolute lower bound) + -- + -- TODO: long-term, this compatibility matrix should be + -- stored as a field inside 'Distribution.Compiler.Compiler' + setupMinCabalVersionConstraint + | isGHC, compVer >= mkVersion [8,4] = mkVersion [2,2] + | isGHC, compVer >= mkVersion [8,2] = mkVersion [2,0] + | isGHC, compVer >= mkVersion [8,0] = mkVersion [1,24] + | isGHC, compVer >= mkVersion [7,10] = mkVersion [1,22] + | otherwise = mkVersion [1,20] + where + isGHC = compFlav `elem` [GHC,GHCJS] + compFlav = compilerFlavor comp + compVer = compilerVersion comp ------------------------------------------------------------------------------ -- * Install plan post-processing