Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement ghc/cabal compatiblity matrix #5165

Merged
merged 2 commits into from
Feb 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 42 additions & 12 deletions cabal-install/Distribution/Client/ProjectPlanning.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions cabal-testsuite/PackageTests/CustomDep/cabal.test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import Test.Cabal.Prelude
main = cabalTest $ do
-- NB: This variant seems to use the bootstrapped Cabal?
skipUnless =<< hasCabalForGhc
-- implicit setup-depends conflict with GHC >= 8.2; c.f. #415
skipIf =<< (ghcVersionIs (>= mkVersion [8,2]))
-- This test depends heavily on what packages are in the global
-- database, don't record the output
recordMode DoNotRecord $ do
Expand Down
2 changes: 2 additions & 0 deletions cabal-testsuite/PackageTests/CustomPlain/cabal.test.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Test.Cabal.Prelude
main = cabalTest $ do
-- implicit setup-depends conflict with GHC >= 8.2; c.f. #415
skipIf =<< (ghcVersionIs (>= mkVersion [8,2]))
-- Regression test for #4393
recordMode DoNotRecord $ do
-- TODO: Hack; see also CustomDep/cabal.test.hs
Expand Down
5 changes: 4 additions & 1 deletion cabal-testsuite/PackageTests/Regression/T3932/cabal.test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ main = cabalTest $
-- extra constraint that setup Cabal must be 1.20. If we don't
-- have a choice like this available, the unsatisfied constraint
-- won't be reported.
--
-- Due to #415, the lower bound may be even higher based on GHC
-- version
withRepo "repo" $ do
-- Don't record because output wobbles based on installed database.
recordMode DoNotRecord $ do
fails (cabal' "new-build" []) >>=
assertOutputContains "Setup.hs requires >=1.20"
assertOutputContains "Setup.hs requires >="