Commit 80de7ff4 authored by Jason Dagit's avatar Jason Dagit Committed by Edward Z. Yang
Browse files

Require Cabal >= 1.20 in new-build. (#4051)

Constrain Cabal >= 1.20 in all new-build install plans. This solves problems where Cabal 1.18 don't have a good enough API to let us handle the new-style store (we need --dependency flags.)

In the future we plan to relax this to only Setup.hs dependencies.

Fixes issue #3932.
parent 20bed063
......@@ -952,6 +952,17 @@ planPackages comp platform solver SolverSettings{..}
| Dependency name ver <- solverSettingPreferences ]
. addConstraints
-- If a package has a custom setup then we need to add a setup-depends
-- on Cabal. For now it's easier to add this unconditionally. Once
-- qualified constraints land we can turn this into a custom setup
-- only constraint.
--
-- TODO: use a qualified constraint
[ LabeledPackageConstraint (PackageConstraintVersion cabalPkgname
(orLaterVersion (mkVersion [1,20])))
ConstraintNewBuildCustomSetupLowerBoundCabal
] . addConstraints
-- version constraints from the config file or command line
[ LabeledPackageConstraint (userToPackageConstraint pc) src
| (pc, src) <- solverSettingConstraints ]
......@@ -2392,6 +2403,17 @@ defaultSetupDeps compiler platform pkg =
-- * We omit the dep for the Cabal lib itself, since it bootstraps.
-- * We constrain it to be >= 1.18 < 2
--
-- Note: cabalCompatMinVer only gets applied WHEN WE ARE ADDING a
-- default setup build info, i.e., when there is no custom-setup
-- stanza. If there is a custom-setup stanza, this codepath never gets
-- invoked (that's why there's an error case for
-- SetupCustomExplicitDeps).
--
-- One way we could solve this problem is by also modifying
-- custom-setup stanzas when they exist, but we're going to take a
-- different approach: add an extra constraint on Cabal globally to
-- make sure the solver respects it regardless of whether or not there
-- is an explicit setup build info or not. See planPackages.
cabalConstraint = orLaterVersion cabalCompatMinVer
`intersectVersionRanges`
orLaterVersion (PD.specVersion pkg)
......@@ -2421,6 +2443,8 @@ defaultSetupDeps compiler platform pkg =
-- The internal setup wrapper method has no deps at all.
SetupNonCustomInternalLib -> Just []
-- This case gets ruled out by the caller, planPackages, see the note
-- above in the SetupCustomIplicitDeps case.
SetupCustomExplicitDeps ->
error $ "defaultSetupDeps: called for a package with explicit "
++ "setup deps: " ++ display (packageId pkg)
......
......@@ -45,6 +45,9 @@ data ConstraintSource =
-- | The source of the constraint is not specified.
| ConstraintSourceUnknown
-- | Custom setup requires a minimum lower bound on Cabal
| ConstraintNewBuildCustomSetupLowerBoundCabal
deriving (Eq, Show, Generic)
instance Binary ConstraintSource
......@@ -68,3 +71,4 @@ showConstraintSource ConstraintSourceFreeze = "cabal freeze"
showConstraintSource ConstraintSourceConfigFlagOrTarget =
"config file, command line flag, or user target"
showConstraintSource ConstraintSourceUnknown = "unknown source"
showConstraintSource ConstraintNewBuildCustomSetupLowerBoundCabal = "new-build's support of Custom Setup (issue #3932)"
......@@ -51,6 +51,8 @@ Extra-Source-Files:
tests/IntegrationTests/custom-setup/Cabal-99998/CabalMessage.hs
tests/IntegrationTests/custom-setup/Cabal-99999/Cabal.cabal
tests/IntegrationTests/custom-setup/Cabal-99999/CabalMessage.hs
tests/IntegrationTests/custom-setup/custom-setup-old-cabal/Setup.hs
tests/IntegrationTests/custom-setup/custom-setup-old-cabal/custom-setup-old-cabal.cabal
tests/IntegrationTests/custom-setup/custom-setup-without-cabal-defaultMain/Setup.hs
tests/IntegrationTests/custom-setup/custom-setup-without-cabal-defaultMain/custom-setup-without-cabal-defaultMain.cabal
tests/IntegrationTests/custom-setup/custom-setup-without-cabal/Setup.hs
......@@ -60,6 +62,7 @@ Extra-Source-Files:
tests/IntegrationTests/custom-setup/custom_setup_without_Cabal_doesnt_allow_Cabal_import.sh
tests/IntegrationTests/custom-setup/custom_setup_without_Cabal_doesnt_require_Cabal.sh
tests/IntegrationTests/custom-setup/installs_Cabal_as_setup_dep.sh
tests/IntegrationTests/custom-setup/new_build_requires_Cabal_1_20.sh
tests/IntegrationTests/custom/custom_dep.sh
tests/IntegrationTests/custom/custom_dep/client/B.hs
tests/IntegrationTests/custom/custom_dep/client/Setup.hs
......@@ -171,11 +174,6 @@ Extra-Source-Files:
tests/IntegrationTests/regression/t3199/Main.hs
tests/IntegrationTests/regression/t3199/Setup.hs
tests/IntegrationTests/regression/t3199/test-3199.cabal
tests/IntegrationTests/regression/t3335.sh
tests/IntegrationTests/regression/t3335/A.hs
tests/IntegrationTests/regression/t3335/Setup.hs
tests/IntegrationTests/regression/t3335/cabal.project
tests/IntegrationTests/regression/t3335/t3335.cabal
tests/IntegrationTests/regression/t3827.sh
tests/IntegrationTests/regression/t3827/cabal.project
tests/IntegrationTests/regression/t3827/p/P.hs
......
import CabalMessage (message)
import System.Exit
import System.IO
main = hPutStrLn stderr message >> exitFailure
name: custom-setup
version: 1.0
build-type: Custom
custom-setup
setup-depends: base, Cabal < 1.20
library
# Regression test for issue #3932
. ./common.sh
cd custom-setup-old-cabal
! cabal new-build > output 2>&1
cat output
grep -q "(issue #3932) requires >=1.20" output || die "Expect constraint failure"
. ./common.sh
require_ghc_le 706
cd t3335
cabal new-build t3335
name: t3335
version: 0.1.0.0
license: BSD3
author: Edward Z. Yang
maintainer: ezyang@cs.stanford.edu
category: Test
build-type: Custom
cabal-version: >=1.10
library
exposed-modules: A
build-depends: base
default-language: Haskell2010
custom-setup
setup-depends: Cabal == 1.16.*, base
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment