Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reject solver solutions involving un-buildable libraries. #3988

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion cabal-install/Distribution/Solver/Modular/IndexConversion.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Distribution.PackageDescription as PD -- from Cabal
import Distribution.PackageDescription.Configuration as PDC
import qualified Distribution.Simple.PackageIndex as SI
import Distribution.System
import Distribution.Version

import Distribution.Solver.Types.ComponentDeps (Component(..))
import Distribution.Solver.Types.OptionalStanza
Expand Down Expand Up @@ -126,7 +127,33 @@ convGPD os arch cinfo strfl sexes pi
conv :: Mon.Monoid a => Component -> (a -> BuildInfo) ->
CondTree ConfVar [Dependency] a -> FlaggedDeps Component PN
conv comp getInfo = convCondTree os arch cinfo pi fds comp getInfo ipns sexes .
PDC.addBuildableCondition getInfo
setBuildable comp getInfo

-- Like 'addBuildableCondition' but if a library is marked as un-buildable,
-- that is a hard failure for dependency solving. This is a hack,
-- and the error message you get in this case is not great.
setBuildable :: (Monoid a) =>
Component
-> (a -> BuildInfo)
-> CondTree ConfVar [Dependency] a
-> CondTree ConfVar [Dependency] a
setBuildable comp getInfo t =
case extractCondition (buildable . getInfo) t of
Lit True -> t
Lit False | softFail -> CondNode mempty mempty []
| otherwise -> failTree
c -> CondNode mempty mempty
[(c, t, if softFail
then Nothing
else Just failTree)]
where
softFail = case comp of
ComponentLib -> False
ComponentSubLib _ -> False
ComponentSetup -> False
_ -> True
failTree = CondNode mempty [failDep] []
failDep = Dependency (mkPackageName "unbuildable") (anyVersion)

flagged_deps
= concatMap (\ds -> conv ComponentLib libBuildInfo ds) (maybeToList mlib)
Expand Down