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