Commit c18974b9 authored by Mikhail Glushenkov's avatar Mikhail Glushenkov Committed by GitHub
Browse files

Merge pull request #3879 from ezyang/pr/no-legacy-exe-solving

Don't solve for executables in legacy code path.
parents 99c7c221 9e99b3f4
......@@ -39,6 +39,7 @@ import Distribution.Package (PackageId)
import Distribution.Client.JobControl (Lock)
import qualified Distribution.Solver.Types.ComponentDeps as CD
import Distribution.Solver.Types.Settings
import Distribution.Solver.Types.ConstraintSource
import Distribution.Solver.Types.LabeledPackageConstraint
import Distribution.Solver.Types.OptionalStanza
......@@ -348,8 +349,16 @@ planLocalPackage verbosity comp platform configFlags configExFlags
in LabeledPackageConstraint pc ConstraintSourceConfigFlagOrTarget
]
-- Don't solve for executables, since we use an empty source
-- package database and executables never show up in the
-- installed package index
. setSolveExecutables (SolveExecutables False)
$ standardInstallPolicy
installedPkgIndex
-- NB: We pass in an *empty* source package database,
-- because cabal configure assumes that all dependencies
-- have already been installed
(SourcePackageDb mempty packagePrefs)
[SpecificSourcePackage localPkg]
......
......@@ -51,6 +51,7 @@ module Distribution.Client.Dependency (
setStrongFlags,
setMaxBackjumps,
setEnableBackjumping,
setSolveExecutables,
setGoalOrder,
removeLowerBounds,
removeUpperBounds,
......@@ -158,6 +159,11 @@ data DepResolverParams = DepResolverParams {
depResolverStrongFlags :: StrongFlags,
depResolverMaxBackjumps :: Maybe Int,
depResolverEnableBackjumping :: EnableBackjumping,
-- | Whether or not to solve for dependencies on executables.
-- This should be true, except in the legacy code path where
-- we can't tell if an executable has been installed or not,
-- so we shouldn't solve for them. See #3875.
depResolverSolveExecutables :: SolveExecutables,
-- | Function to override the solver's goal-ordering heuristics.
depResolverGoalOrder :: Maybe (Variable QPN -> Variable QPN -> Ordering)
......@@ -235,6 +241,7 @@ basicDepResolverParams installedPkgIndex sourcePkgIndex =
depResolverStrongFlags = StrongFlags False,
depResolverMaxBackjumps = Nothing,
depResolverEnableBackjumping = EnableBackjumping True,
depResolverSolveExecutables = SolveExecutables True,
depResolverGoalOrder = Nothing
}
......@@ -316,6 +323,12 @@ setEnableBackjumping b params =
depResolverEnableBackjumping = b
}
setSolveExecutables :: SolveExecutables -> DepResolverParams -> DepResolverParams
setSolveExecutables b params =
params {
depResolverSolveExecutables = b
}
setGoalOrder :: Maybe (Variable QPN -> Variable QPN -> Ordering)
-> DepResolverParams
-> DepResolverParams
......@@ -609,7 +622,7 @@ resolveDependencies platform comp pkgConfigDB solver params =
$ fmap (validateSolverResult platform comp indGoals)
$ runSolver solver (SolverConfig reordGoals cntConflicts
indGoals noReinstalls
shadowing strFlags maxBkjumps enableBj order)
shadowing strFlags maxBkjumps enableBj solveExes order)
platform comp installedPkgIndex sourcePkgIndex
pkgConfigDB preferences constraints targets
where
......@@ -627,6 +640,7 @@ resolveDependencies platform comp pkgConfigDB solver params =
strFlags
maxBkjumps
enableBj
solveExes
order) = dontUpgradeNonUpgradeablePackages params
preferences = interpretPackagesPreference targets defpref prefs
......@@ -852,7 +866,7 @@ resolveWithoutDependencies :: DepResolverParams
resolveWithoutDependencies (DepResolverParams targets constraints
prefs defpref installedPkgIndex sourcePkgIndex
_reorderGoals _countConflicts _indGoals _avoidReinstalls
_shadowing _strFlags _maxBjumps _enableBj _order) =
_shadowing _strFlags _maxBjumps _enableBj _solveExes _order) =
collectEithers $ map selectPackage (Set.toList targets)
where
selectPackage :: PackageName -> Either ResolveNoDepsError UnresolvedSourcePackage
......
......@@ -38,7 +38,7 @@ modularResolver sc (Platform arch os) cinfo iidx sidx pkgConfigDB pprefs pcs pns
solve sc cinfo idx pkgConfigDB pprefs gcs pns
where
-- Indices have to be converted into solver-specific uniform index.
idx = convPIs os arch cinfo (shadowPkgs sc) (strongFlags sc) iidx sidx
idx = convPIs os arch cinfo (shadowPkgs sc) (strongFlags sc) (solveExecutables sc) iidx sidx
-- Constraints have to be converted into a finite map indexed by PN.
gcs = M.fromListWith (++) (map pair pcs)
where
......
......@@ -41,10 +41,10 @@ import Distribution.Solver.Modular.Version
-- resolving these situations. However, the right thing to do is to
-- fix the problem there, so for now, shadowing is only activated if
-- explicitly requested.
convPIs :: OS -> Arch -> CompilerInfo -> ShadowPkgs -> StrongFlags ->
convPIs :: OS -> Arch -> CompilerInfo -> ShadowPkgs -> StrongFlags -> SolveExecutables ->
SI.InstalledPackageIndex -> CI.PackageIndex (SourcePackage loc) -> Index
convPIs os arch comp sip strfl iidx sidx =
mkIndex (convIPI' sip iidx ++ convSPI' os arch comp strfl sidx)
convPIs os arch comp sip strfl sexes iidx sidx =
mkIndex (convIPI' sip iidx ++ convSPI' os arch comp strfl sexes sidx)
-- | Convert a Cabal installed package index to the simpler,
-- more uniform index format of the solver.
......@@ -93,24 +93,24 @@ convIPId pn' idx ipid =
-- | Convert a cabal-install source package index to the simpler,
-- more uniform index format of the solver.
convSPI' :: OS -> Arch -> CompilerInfo -> StrongFlags ->
convSPI' :: OS -> Arch -> CompilerInfo -> StrongFlags -> SolveExecutables ->
CI.PackageIndex (SourcePackage loc) -> [(PN, I, PInfo)]
convSPI' os arch cinfo strfl = L.map (convSP os arch cinfo strfl) . CI.allPackages
convSPI' os arch cinfo strfl sexes = L.map (convSP os arch cinfo strfl sexes) . CI.allPackages
-- | Convert a single source package into the solver-specific format.
convSP :: OS -> Arch -> CompilerInfo -> StrongFlags -> SourcePackage loc -> (PN, I, PInfo)
convSP os arch cinfo strfl (SourcePackage (PackageIdentifier pn pv) gpd _ _pl) =
convSP :: OS -> Arch -> CompilerInfo -> StrongFlags -> SolveExecutables -> SourcePackage loc -> (PN, I, PInfo)
convSP os arch cinfo strfl sexes (SourcePackage (PackageIdentifier pn pv) gpd _ _pl) =
let i = I pv InRepo
in (pn, i, convGPD os arch cinfo strfl (PI pn i) gpd)
in (pn, i, convGPD os arch cinfo strfl sexes (PI pn i) gpd)
-- We do not use 'flattenPackageDescription' or 'finalizePD'
-- from 'Distribution.PackageDescription.Configuration' here, because we
-- want to keep the condition tree, but simplify much of the test.
-- | Convert a generic package description to a solver-specific 'PInfo'.
convGPD :: OS -> Arch -> CompilerInfo -> StrongFlags ->
convGPD :: OS -> Arch -> CompilerInfo -> StrongFlags -> SolveExecutables ->
PI PN -> GenericPackageDescription -> PInfo
convGPD os arch cinfo strfl pi
convGPD os arch cinfo strfl sexes pi
(GenericPackageDescription pkg flags mlib sub_libs exes tests benchs) =
let
fds = flagInfo strfl flags
......@@ -125,7 +125,7 @@ convGPD os arch cinfo strfl 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 .
conv comp getInfo = convCondTree os arch cinfo pi fds comp getInfo ipns sexes .
PDC.addBuildableCondition getInfo
flagged_deps
......@@ -175,22 +175,29 @@ convCondTree :: OS -> Arch -> CompilerInfo -> PI PN -> FlagInfo ->
Component ->
(a -> BuildInfo) ->
IPNs ->
SolveExecutables ->
CondTree ConfVar [Dependency] a -> FlaggedDeps Component PN
convCondTree os arch cinfo pi@(PI pn _) fds comp getInfo ipns (CondNode info ds branches) =
convCondTree os arch cinfo pi@(PI pn _) fds comp getInfo ipns sexes@(SolveExecutables sexes') (CondNode info ds branches) =
concatMap
(\d -> filterIPNs ipns d (D.Simple (convLibDep pn d) comp))
ds -- unconditional package dependencies
++ L.map (\e -> D.Simple (Ext e) comp) (PD.allExtensions bi) -- unconditional extension dependencies
++ L.map (\l -> D.Simple (Lang l) comp) (PD.allLanguages bi) -- unconditional language dependencies
++ L.map (\(Dependency pkn vr) -> D.Simple (Pkg pkn vr) comp) (PD.pkgconfigDepends bi) -- unconditional pkg-config dependencies
++ concatMap (convBranch os arch cinfo pi fds comp getInfo ipns) branches
++ concatMap (convBranch os arch cinfo pi fds comp getInfo ipns sexes) branches
-- build-tools dependencies
++ concatMap
-- NB: Only include these dependencies if SolveExecutables
-- is True. It might be false in the legacy solver
-- codepath, in which case there won't be any record of
-- an executable we need.
++ (if sexes'
then concatMap
(\(Dependency (PackageName exe) vr) ->
case packageProvidingBuildTool exe of
Nothing -> []
Just pn' -> [D.Simple (convExeDep pn (Dependency pn' vr)) comp])
(PD.buildTools bi)
else [])
where
bi = getInfo info
......@@ -244,12 +251,13 @@ convBranch :: OS -> Arch -> CompilerInfo ->
Component ->
(a -> BuildInfo) ->
IPNs ->
SolveExecutables ->
(Condition ConfVar,
CondTree ConfVar [Dependency] a,
Maybe (CondTree ConfVar [Dependency] a)) -> FlaggedDeps Component PN
convBranch os arch cinfo pi@(PI pn _) fds comp getInfo ipns (c', t', mf') =
go c' ( convCondTree os arch cinfo pi fds comp getInfo ipns t')
(maybe [] (convCondTree os arch cinfo pi fds comp getInfo ipns) mf')
convBranch os arch cinfo pi@(PI pn _) fds comp getInfo ipns sexes (c', t', mf') =
go c' ( convCondTree os arch cinfo pi fds comp getInfo ipns sexes t')
(maybe [] (convCondTree os arch cinfo pi fds comp getInfo ipns sexes) mf')
where
go :: Condition ConfVar ->
FlaggedDeps Component PN -> FlaggedDeps Component PN -> FlaggedDeps Component PN
......
......@@ -61,6 +61,7 @@ data SolverConfig = SolverConfig {
strongFlags :: StrongFlags,
maxBackjumps :: Maybe Int,
enableBackjumping :: EnableBackjumping,
solveExecutables :: SolveExecutables,
goalOrder :: Maybe (Variable QPN -> Variable QPN -> Ordering)
}
......
......@@ -8,6 +8,7 @@ module Distribution.Solver.Types.Settings
, StrongFlags(..)
, EnableBackjumping(..)
, CountConflicts(..)
, SolveExecutables(..)
) where
import Distribution.Simple.Setup ( BooleanFlag(..) )
......@@ -35,9 +36,13 @@ newtype StrongFlags = StrongFlags Bool
newtype EnableBackjumping = EnableBackjumping Bool
deriving (BooleanFlag, Eq, Generic, Show)
newtype SolveExecutables = SolveExecutables Bool
deriving (BooleanFlag, Eq, Generic, Show)
instance Binary ReorderGoals
instance Binary CountConflicts
instance Binary IndependentGoals
instance Binary AvoidReinstalls
instance Binary ShadowPkgs
instance Binary StrongFlags
instance Binary SolveExecutables
Supports Markdown
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