@@ -952,23 +952,25 @@ planPackages comp platform solver SolverSettings{..}
952
952
. PD. packageDescription
953
953
. packageDescription)
954
954
955
+ . addSetupCabalMinVersionConstraint (mkVersion [1 ,20 ])
956
+ -- While we can talk to older Cabal versions (we need to be able to
957
+ -- do so for custom Setup scripts that require older Cabal lib
958
+ -- versions), we have problems talking to some older versions that
959
+ -- don't support certain features.
960
+ --
961
+ -- For example, Cabal-1.16 and older do not know about build targets.
962
+ -- Even worse, 1.18 and older only supported the --constraint flag
963
+ -- with source package ids, not --dependency with installed package
964
+ -- ids. That is bad because we cannot reliably select the right
965
+ -- dependencies in the presence of multiple instances (i.e. the
966
+ -- store). See issue #3932. So we require Cabal 1.20 as a minimum.
967
+
955
968
. addPreferences
956
969
-- preferences from the config file or command line
957
970
[ PackageVersionPreference name ver
958
971
| Dependency name ver <- solverSettingPreferences ]
959
972
960
973
. addConstraints
961
-
962
- -- If a package has a custom setup then we need to add a setup-depends
963
- -- on Cabal. For now it's easier to add this unconditionally. Once
964
- -- qualified constraints land we can turn this into a custom setup
965
- -- only constraint.
966
- --
967
- -- TODO: use a qualified constraint
968
- [ LabeledPackageConstraint (PackageConstraintVersion cabalPkgname
969
- (orLaterVersion (mkVersion [1 ,20 ])))
970
- ConstraintNewBuildCustomSetupLowerBoundCabal
971
- ] . addConstraints
972
974
-- version constraints from the config file or command line
973
975
[ LabeledPackageConstraint (userToPackageConstraint pc) src
974
976
| (pc, src) <- solverSettingConstraints ]
@@ -2397,6 +2399,10 @@ packageSetupScriptStyle pkg
2397
2399
-- we still need to distinguish the case of explicit and implict setup deps.
2398
2400
-- See 'rememberImplicitSetupDeps'.
2399
2401
--
2402
+ -- Note in addition to adding default setup deps, we also use
2403
+ -- 'addSetupCabalMinVersionConstraint' (in 'planPackages') to require
2404
+ -- @Cabal >= 1.20@ for Setup scripts.
2405
+ --
2400
2406
defaultSetupDeps :: Compiler -> Platform
2401
2407
-> PD. PackageDescription
2402
2408
-> Maybe [Dependency ]
@@ -2415,35 +2421,19 @@ defaultSetupDeps compiler platform pkg =
2415
2421
where
2416
2422
-- The Cabal dep is slightly special:
2417
2423
-- * We omit the dep for the Cabal lib itself, since it bootstraps.
2418
- -- * We constrain it to be >= 1.18 < 2
2424
+ -- * We constrain it to be < 1.25
2419
2425
--
2420
- -- Note: cabalCompatMinVer only gets applied WHEN WE ARE ADDING a
2421
- -- default setup build info, i.e., when there is no custom-setup
2422
- -- stanza. If there is a custom-setup stanza, this codepath never gets
2423
- -- invoked (that's why there's an error case for
2424
- -- SetupCustomExplicitDeps).
2426
+ -- Note: we also add a global constraint to require Cabal >= 1.20
2427
+ -- for Setup scripts (see use addSetupCabalMinVersionConstraint).
2425
2428
--
2426
- -- One way we could solve this problem is by also modifying
2427
- -- custom-setup stanzas when they exist, but we're going to take a
2428
- -- different approach: add an extra constraint on Cabal globally to
2429
- -- make sure the solver respects it regardless of whether or not there
2430
- -- is an explicit setup build info or not. See planPackages.
2431
- cabalConstraint = orLaterVersion cabalCompatMinVer
2432
- `intersectVersionRanges`
2433
- orLaterVersion (PD. specVersion pkg)
2429
+ cabalConstraint = orLaterVersion (PD. specVersion pkg)
2434
2430
`intersectVersionRanges`
2435
2431
earlierVersion cabalCompatMaxVer
2436
2432
-- The idea here is that at some point we will make significant
2437
2433
-- breaking changes to the Cabal API that Setup.hs scripts use.
2438
2434
-- So for old custom Setup scripts that do not specify explicit
2439
2435
-- constraints, we constrain them to use a compatible Cabal version.
2440
2436
cabalCompatMaxVer = mkVersion [1 ,25 ]
2441
- -- In principle we can talk to any old Cabal version, and we need to
2442
- -- be able to do that for custom Setup scripts that require older
2443
- -- Cabal lib versions. However in practice we have currently have
2444
- -- problems with Cabal-1.16. (1.16 does not know about build targets)
2445
- -- If this is fixed we can relax this constraint.
2446
- cabalCompatMinVer = mkVersion [1 ,18 ]
2447
2437
2448
2438
-- For other build types (like Simple) if we still need to compile an
2449
2439
-- external Setup.hs, it'll be one of the simple ones that only depends
@@ -2458,7 +2448,7 @@ defaultSetupDeps compiler platform pkg =
2458
2448
SetupNonCustomInternalLib -> Just []
2459
2449
2460
2450
-- This case gets ruled out by the caller, planPackages, see the note
2461
- -- above in the SetupCustomIplicitDeps case.
2451
+ -- above in the SetupCustomImplicitDeps case.
2462
2452
SetupCustomExplicitDeps ->
2463
2453
error $ " defaultSetupDeps: called for a package with explicit "
2464
2454
++ " setup deps: " ++ display (packageId pkg)
0 commit comments