Skip to content

Commit 8b3bd34

Browse files
committed
prune inRepo from build deps
1 parent 57fca26 commit 8b3bd34

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

cabal-install-solver/src/Distribution/Solver/Modular/Preference.hs

+9-3
Original file line numberDiff line numberDiff line change
@@ -350,22 +350,28 @@ avoidReinstalls p = go
350350

351351
-- | Ensure that Setup (Build time) dependencies only have Build dependencies
352352
-- available and that Host dependencies only have Host dependencies available.
353+
-- We also do not want to use InRepo dependencies for setup/build-depends. This
354+
-- easily leads to cycles.
353355
pruneHostFromSetup :: EndoTreeTrav d c
354356
pruneHostFromSetup = go
355357
where
356358
-- for Setup(.hs) and build-depends, we want to force Build packages.
357359
go (PChoiceF qpn rdm gr cs) | (Q (PackagePath _ (QualSetup _)) _) <- qpn =
358-
PChoiceF qpn rdm gr (W.filterKey (not . isHost) cs)
360+
PChoiceF qpn rdm gr (W.filterKey (not . isHostOrRepo) cs)
359361
-- QualExe are build-depends. Structure is QualExe (comp) (build-depend).
360362
go (PChoiceF qpn rdm gr cs) | (Q (PackagePath _ (QualExe _ _)) _) <- qpn =
361-
PChoiceF qpn rdm gr (W.filterKey (not . isHost) cs)
363+
PChoiceF qpn rdm gr (W.filterKey (not . isHostOrRepo) cs)
362364
-- everything else use Host packages.
363365
go (PChoiceF qpn rdm gr cs) | (Q (PackagePath _ _) _) <- qpn =
364366
PChoiceF qpn rdm gr (W.filterKey isHost cs)
365367
go x = x
366368

367369
isHost :: POption -> Bool
368-
isHost (POption (I s _ _) _) = s == Host
370+
isHost (POption (I s _v _l) _) = s == Host
371+
isInRepo :: POption -> Bool
372+
isInRepo (POption (I _s _v l) _) = l == InRepo
373+
isHostOrRepo :: POption -> Bool
374+
isHostOrRepo (POption (I s _v l) _) = s == Host || l == InRepo
369375

370376
-- | Require all packages to be mentioned in a constraint or as a goal.
371377
onlyConstrained :: (PN -> Bool) -> EndoTreeTrav d QGoalReason

cabal-install-solver/src/Distribution/Solver/Modular/Solver.hs

+7-3
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ solve sc toolchains idx pkgConfigDB userPrefs userConstraints userGoals =
114114
validationCata .
115115
traceTree "pruned.json" id .
116116
trav prunePhase .
117+
stageBuildDeps "build: " .
117118
(if buildIsHost toolchains then id else trav P.pruneHostFromSetup) .
118-
-- stageBuildDeps "build: " .
119119
traceTree "build.json" id $
120120
buildPhase
121121
where
@@ -158,11 +158,15 @@ solve sc toolchains idx pkgConfigDB userPrefs userConstraints userGoals =
158158
-- may not be able to produce code that runs on the build machine.
159159
go (PChoice qpn rdm gr cs) | (Q (PackagePath _ (QualSetup _)) _) <- qpn =
160160
(PChoice qpn rdm gr (trace (prefix ++ show qpn ++ '\n':unlines (map (" - " ++) candidates)) (go <$> cs)))
161-
where candidates = map show . filter (\(I _s _v l) -> l /= InRepo) . map (\(_w, (POption i _), _v) -> i) $ W.toList cs
161+
where candidates = map show
162+
-- . filter (\(I _s _v l) -> l /= InRepo)
163+
. map (\(_w, (POption i _), _v) -> i) $ W.toList cs
162164
-- Same for build-depends. These show up as QualExe (component) (build-depends).
163165
go (PChoice qpn rdm gr cs) | (Q (PackagePath _ (QualExe _ _)) _) <- qpn =
164166
(PChoice qpn rdm gr (trace (prefix ++ show qpn ++ '\n':unlines (map (" - " ++) candidates)) (go <$> cs)))
165-
where candidates = map show . filter (\(I _s _v l) -> l /= InRepo) . map (\(_w, (POption i _), _v) -> i) $ W.toList cs
167+
where candidates = map show
168+
-- . filter (\(I _s _v l) -> l /= InRepo)
169+
. map (\(_w, (POption i _), _v) -> i) $ W.toList cs
166170
go (PChoice qpn rdm gr cs) =
167171
(PChoice qpn rdm gr (go <$> cs))
168172
go (FChoice qfn rdm gr t b d cs) =

0 commit comments

Comments
 (0)