From de880a54b68f71a344d72e44a0f3277d94721e5e Mon Sep 17 00:00:00 2001 From: Herbert Valerio Riedel Date: Sat, 3 Mar 2018 10:31:18 +0100 Subject: [PATCH 1/4] Fine-tune lower bound on lib:Cabal GHC 8.4.1-rc1 (GHC 8.4.0.20180224) unfortunately still shipped with a devel snapshot of Cabal-2.1.0.0; but GHC 8.4.1 final will ship w/ lib:Cabal-2.2.0.0 (cherry picked from commit 5066672fe5b500fdeed4ee4824280675fe690556) --- cabal-install/Distribution/Client/ProjectPlanning.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cabal-install/Distribution/Client/ProjectPlanning.hs b/cabal-install/Distribution/Client/ProjectPlanning.hs index 8fa2d9ec8e8..50ae2ee2210 100644 --- a/cabal-install/Distribution/Client/ProjectPlanning.hs +++ b/cabal-install/Distribution/Client/ProjectPlanning.hs @@ -1039,7 +1039,7 @@ planPackages verbosity comp platform solver SolverSettings{..} -- respective major Cabal version bundled with the respective GHC -- release). -- - -- GHC 8.4 needs Cabal >= 2.1 (GHC 8.4.1-rc1 has Cabal-2.1) + -- 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 @@ -1050,6 +1050,10 @@ planPackages verbosity comp platform solver SolverSettings{..} -- TODO: long-term, this compatibility matrix should be -- stored as a field inside 'Distribution.Compiler.Compiler' setupMinCabalVersionConstraint + | isGHC, compVer >= mkVersion [8,4,1] = mkVersion [2,2] + -- GHC 8.4.1-rc1 (GHC 8.4.0.20180224) still shipped with an + -- devel snapshot of Cabal-2.1.0.0; the rule below can be + -- dropped at some point | isGHC, compVer >= mkVersion [8,4] = mkVersion [2,1] | isGHC, compVer >= mkVersion [8,2] = mkVersion [2,0] | isGHC, compVer >= mkVersion [8,0] = mkVersion [1,24] From c92b71502787acd40bb5012422f80150a6f112c5 Mon Sep 17 00:00:00 2001 From: Herbert Valerio Riedel Date: Sat, 3 Mar 2018 11:15:02 +0100 Subject: [PATCH 2/4] Set upper bound on setup.Cabal relative to current version As we can't predict the future, we also place a global upper bound on the lib:Cabal version we know how to interact with: The upper bound is computed by incrementing the current major version twice in order to allow for the current version, as well as the next adjacent major version (one of which will not be released, as only "even major" versions of Cabal are released to Hackage or bundled with proper GHC releases). For instance, if the current version of cabal-install is an odd development version, e.g. Cabal-2.1.0.0, then we impose an upper bound `setup.Cabal < 2.3`; if `cabal-install` is on a stable/release even version, e.g. Cabal-2.2.1.0, the upper bound is `setup.Cabal < 2.4`. This gives us enough flexibility when dealing with development snapshots of Cabal and cabal-install. This addresses #415 (cherry picked from commit e66106c7b77d6ee6df4948bbe144e4d520f8b311) --- .../Distribution/Client/Dependency.hs | 16 ++++++++++++++ .../Distribution/Client/ProjectPlanning.hs | 21 +++++++++++++++++++ .../Solver/Types/ConstraintSource.hs | 6 ++++++ 3 files changed, 43 insertions(+) diff --git a/cabal-install/Distribution/Client/Dependency.hs b/cabal-install/Distribution/Client/Dependency.hs index f13777ab0b5..0cca0a8816c 100644 --- a/cabal-install/Distribution/Client/Dependency.hs +++ b/cabal-install/Distribution/Client/Dependency.hs @@ -61,6 +61,7 @@ module Distribution.Client.Dependency ( removeUpperBounds, addDefaultSetupDependencies, addSetupCabalMinVersionConstraint, + addSetupCabalMaxVersionConstraint, ) where import Distribution.Solver.Modular @@ -555,6 +556,21 @@ addSetupCabalMinVersionConstraint minVersion = where cabalPkgname = mkPackageName "Cabal" +-- | Variant of 'addSetupCabalMinVersionConstraint' which sets an +-- upper bound on @setup.Cabal@ labeled with 'ConstraintSetupCabalMaxVersion'. +-- +addSetupCabalMaxVersionConstraint :: Version + -> DepResolverParams -> DepResolverParams +addSetupCabalMaxVersionConstraint maxVersion = + addConstraints + [ LabeledPackageConstraint + (PackageConstraint (ScopeAnySetupQualifier cabalPkgname) + (PackagePropertyVersion $ earlierVersion maxVersion)) + ConstraintSetupCabalMaxVersion + ] + where + cabalPkgname = mkPackageName "Cabal" + upgradeDependencies :: DepResolverParams -> DepResolverParams upgradeDependencies = setPreferenceDefault PreferAllLatest diff --git a/cabal-install/Distribution/Client/ProjectPlanning.hs b/cabal-install/Distribution/Client/ProjectPlanning.hs index 50ae2ee2210..1a51276dd8c 100644 --- a/cabal-install/Distribution/Client/ProjectPlanning.hs +++ b/cabal-install/Distribution/Client/ProjectPlanning.hs @@ -80,6 +80,7 @@ import qualified Distribution.Client.SolverInstallPlan as SolverInstallPlan import Distribution.Client.Dependency import Distribution.Client.Dependency.Types import qualified Distribution.Client.IndexUtils as IndexUtils +import Distribution.Client.Init (incVersion) import Distribution.Client.Targets (userToPackageConstraint) import Distribution.Client.DistDirLayout import Distribution.Client.SetupWrapper @@ -950,6 +951,7 @@ planPackages verbosity comp platform solver SolverSettings{..} . packageDescription) . addSetupCabalMinVersionConstraint setupMinCabalVersionConstraint + . addSetupCabalMaxVersionConstraint setupMaxCabalVersionConstraint . addPreferences -- preferences from the config file or command line @@ -1064,6 +1066,25 @@ planPackages verbosity comp platform solver SolverSettings{..} compFlav = compilerFlavor comp compVer = compilerVersion comp + -- As we can't predict the future, we also place a global upper + -- bound on the lib:Cabal version we know how to interact with: + -- + -- The upper bound is computed by incrementing the current major + -- version twice in order to allow for the current version, as + -- well as the next adjacent major version (one of which will not + -- be released, as only "even major" versions of Cabal are + -- released to Hackage or bundled with proper GHC releases). + -- + -- For instance, if the current version of cabal-install is an odd + -- development version, e.g. Cabal-2.1.0.0, then we impose an + -- upper bound `setup.Cabal < 2.3`; if `cabal-install` is on a + -- stable/release even version, e.g. Cabal-2.2.1.0, the upper + -- bound is `setup.Cabal < 2.4`. This gives us enough flexibility + -- when dealing with development snapshots of Cabal and cabal-install. + -- + setupMaxCabalVersionConstraint = + alterVersion (take 2) $ incVersion 1 $ incVersion 1 cabalVersion + ------------------------------------------------------------------------------ -- * Install plan post-processing ------------------------------------------------------------------------------ diff --git a/cabal-install/Distribution/Solver/Types/ConstraintSource.hs b/cabal-install/Distribution/Solver/Types/ConstraintSource.hs index 7697bbec6b6..16afd2e0d80 100644 --- a/cabal-install/Distribution/Solver/Types/ConstraintSource.hs +++ b/cabal-install/Distribution/Solver/Types/ConstraintSource.hs @@ -49,6 +49,10 @@ data ConstraintSource = -- | An internal constraint due to compatibility issues with the Setup.hs -- command line interface requires a minimum lower bound on Cabal | ConstraintSetupCabalMinVersion + + -- | An internal constraint due to compatibility issues with the Setup.hs + -- command line interface requires a maximum upper bound on Cabal + | ConstraintSetupCabalMaxVersion deriving (Eq, Show, Generic) instance Binary ConstraintSource @@ -74,3 +78,5 @@ showConstraintSource ConstraintSourceConfigFlagOrTarget = showConstraintSource ConstraintSourceUnknown = "unknown source" showConstraintSource ConstraintSetupCabalMinVersion = "minimum version of Cabal used by Setup.hs" +showConstraintSource ConstraintSetupCabalMaxVersion = + "maximum version of Cabal used by Setup.hs" From 7438ad1197e74cae600e4ae285988715d79ca2ec Mon Sep 17 00:00:00 2001 From: Herbert Valerio Riedel Date: Sat, 3 Mar 2018 13:04:52 +0100 Subject: [PATCH 3/4] Fixup T4154 testcase (cherry picked from commit 86de9cc97bde8da5248de49f0e38e40227259378) --- .../Regression/T4154/install-time-with-constraint.out | 1 - .../T4154/install-time-with-constraint.test.hs | 10 ++++++---- .../PackageTests/Regression/T4154/time.cabal | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cabal-testsuite/PackageTests/Regression/T4154/install-time-with-constraint.out b/cabal-testsuite/PackageTests/Regression/T4154/install-time-with-constraint.out index 1f5437704ea..de5fbf4bddc 100644 --- a/cabal-testsuite/PackageTests/Regression/T4154/install-time-with-constraint.out +++ b/cabal-testsuite/PackageTests/Regression/T4154/install-time-with-constraint.out @@ -4,5 +4,4 @@ Downloading the latest package list from test-local-repo Resolving dependencies... Build profile: -w ghc- -O1 In order, the following would be built: - - Cabal-99999 (lib) (requires download & build) - time-99999 (lib:time) (first run) diff --git a/cabal-testsuite/PackageTests/Regression/T4154/install-time-with-constraint.test.hs b/cabal-testsuite/PackageTests/Regression/T4154/install-time-with-constraint.test.hs index 54c56fe2ce0..59aad8b34ef 100644 --- a/cabal-testsuite/PackageTests/Regression/T4154/install-time-with-constraint.test.hs +++ b/cabal-testsuite/PackageTests/Regression/T4154/install-time-with-constraint.test.hs @@ -9,7 +9,9 @@ main = cabalTest $ withRepo "repo" $ do -- Temporarily disabled recording here because output is not stable recordMode DoNotRecord $ do - -- Constraining all uses of 'time' results in a cyclic dependency - -- between 'Cabal' and the new 'time'. - r <- fails $ cabal' "new-build" ["time", "--constraint=any.time==99999", "--dry-run"] - assertOutputContains "cyclic dependencies; conflict set: time:setup.Cabal, time:setup.time" r + r <- fails $ cabal' "new-build" ["time", "--constraint=any.time==99999", "--constraint=setup.Cabal installed", "--dry-run"] + -- Constraining all uses of 'time' originally resulted in a cyclic dependency + -- between 'Cabal' and the new 'time': + -- assertOutputContains "cyclic dependencies; conflict set: time:setup.Cabal, time:setup.time" r + -- However, this doesn't work anymore, so instead we more directly look for: + assertOutputContains "time:setup.time~>time-99999 (conflict: time:setup.Cabal" r diff --git a/cabal-testsuite/PackageTests/Regression/T4154/time.cabal b/cabal-testsuite/PackageTests/Regression/T4154/time.cabal index ad72efcdae9..ac9899b035f 100644 --- a/cabal-testsuite/PackageTests/Regression/T4154/time.cabal +++ b/cabal-testsuite/PackageTests/Regression/T4154/time.cabal @@ -4,7 +4,7 @@ cabal-version: >=1.8 build-type: Custom custom-setup - setup-depends: base, Cabal == 99999 + setup-depends: base, Cabal library build-depends: base From fa7496ace281eed6e7c09ad45e6540fba236500b Mon Sep 17 00:00:00 2001 From: Herbert Valerio Riedel Date: Wed, 28 Feb 2018 21:14:13 +0100 Subject: [PATCH 4/4] Skip `setup-custom2` in integration-tests2 for GHC >= 8.2 The `setup-custom2` tests implicit `setup-depends` which implies a `Cabal < 2` upper bound, which is incompatible with GHC 8.2 or later (cherry picked from commit 8947db4976a3bd38b0d652537c6efdacc3b6ea4a) --- cabal-install/tests/IntegrationTests2.hs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/cabal-install/tests/IntegrationTests2.hs b/cabal-install/tests/IntegrationTests2.hs index 02615f9d04a..51e77fee7f4 100644 --- a/cabal-install/tests/IntegrationTests2.hs +++ b/cabal-install/tests/IntegrationTests2.hs @@ -1347,14 +1347,16 @@ testSetupScriptStyles config reportSubCase = do marker1 @?= "ok" removeFile (basedir testdir1 "marker") - reportSubCase (show SetupCustomImplicitDeps) - (plan2, res2) <- executePlan =<< planProject testdir2 config - (pkg2, _) <- expectPackageInstalled plan2 res2 pkgidA - elabSetupScriptStyle pkg2 @?= SetupCustomImplicitDeps - hasDefaultSetupDeps pkg2 @?= Just True - marker2 <- readFile (basedir testdir2 "marker") - marker2 @?= "ok" - removeFile (basedir testdir2 "marker") + -- implicit deps implies 'Cabal < 2' which conflicts w/ GHC 8.2 or later + when (compilerVersion (pkgConfigCompiler sharedConfig) < mkVersion [8,2]) $ do + reportSubCase (show SetupCustomImplicitDeps) + (plan2, res2) <- executePlan =<< planProject testdir2 config + (pkg2, _) <- expectPackageInstalled plan2 res2 pkgidA + elabSetupScriptStyle pkg2 @?= SetupCustomImplicitDeps + hasDefaultSetupDeps pkg2 @?= Just True + marker2 <- readFile (basedir testdir2 "marker") + marker2 @?= "ok" + removeFile (basedir testdir2 "marker") reportSubCase (show SetupNonCustomInternalLib) (plan3, res3) <- executePlan =<< planProject testdir3 config