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

Merge pull request #3813 from ezyang/pr/profile-libs-only

Compute profiling/shared based on library deps only.
parents cdc5b60e 4100c376
......@@ -76,6 +76,7 @@ import Distribution.Solver.Types.ConstraintSource
import Distribution.Solver.Types.LabeledPackageConstraint
import Distribution.Solver.Types.OptionalStanza
import Distribution.Solver.Types.PkgConfigDb
import Distribution.Solver.Types.ResolverPackage
import Distribution.Solver.Types.Settings
import Distribution.Solver.Types.SolverId
import Distribution.Solver.Types.SolverPackage
......@@ -1541,7 +1542,7 @@ elaborateInstallPlan platform compiler compilerprogdb pkgConfigDB
pkgsUseSharedLibrary :: Set PackageId
pkgsUseSharedLibrary =
packagesWithDownwardClosedProperty needsSharedLib
packagesWithLibDepsDownwardClosedProperty needsSharedLib
where
needsSharedLib pkg =
fromMaybe compilerShouldUseSharedLibByDefault
......@@ -1562,7 +1563,7 @@ elaborateInstallPlan platform compiler compilerprogdb pkgConfigDB
pkgsUseProfilingLibrary :: Set PackageId
pkgsUseProfilingLibrary =
packagesWithDownwardClosedProperty needsProfilingLib
packagesWithLibDepsDownwardClosedProperty needsProfilingLib
where
needsProfilingLib pkg =
fromFlagOrDefault False (profBothFlag <> profLibFlag)
......@@ -1572,11 +1573,15 @@ elaborateInstallPlan platform compiler compilerprogdb pkgConfigDB
profLibFlag = lookupPerPkgOption pkgid packageConfigProfLib
--TODO: [code cleanup] unused: the old deprecated packageConfigProfExe
packagesWithDownwardClosedProperty property =
libDepGraph = Graph.fromList (map LibDepSolverPlanPackage
(SolverInstallPlan.toList solverPlan))
packagesWithLibDepsDownwardClosedProperty property =
Set.fromList
$ map packageId
$ SolverInstallPlan.dependencyClosure
solverPlan
. map packageId
. fromMaybe []
$ Graph.closure
libDepGraph
[ Graph.nodeKey pkg
| pkg <- SolverInstallPlan.toList solverPlan
, property pkg ] -- just the packages that satisfy the propety
......@@ -1591,6 +1596,22 @@ elaborateInstallPlan platform compiler compilerprogdb pkgConfigDB
-- + vanilla libs & exes, exe needs lib, recursive
-- + ghci or shared lib needed by TH, recursive, ghc version dependent
-- | A newtype for 'SolverInstallPlan.SolverPlanPackage' for which the
-- dependency graph considers only library dependencies (so, no setup
-- dependencies or executable dependencies.) Used to compute the set
-- of packages needed for profiling and dynamic libraries.
newtype LibDepSolverPlanPackage
= LibDepSolverPlanPackage { unLibDepSolverPlanPackage :: SolverInstallPlan.SolverPlanPackage }
instance Package LibDepSolverPlanPackage where
packageId = packageId . unLibDepSolverPlanPackage
instance IsNode LibDepSolverPlanPackage where
type Key LibDepSolverPlanPackage = SolverId
nodeKey = nodeKey . unLibDepSolverPlanPackage
nodeNeighbors (LibDepSolverPlanPackage spkg)
= ordNub $ CD.libraryDeps (resolverPackageLibDeps spkg)
---------------------------
-- Build targets
--
......
......@@ -25,6 +25,7 @@ module Distribution.Client.SolverInstallPlan(
-- * Operations on 'SolverInstallPlan's
new,
toList,
toMap,
remove,
......@@ -143,6 +144,9 @@ new indepGoals index =
toList :: SolverInstallPlan -> [SolverPlanPackage]
toList = Graph.toList . planIndex
toMap :: SolverInstallPlan -> Map SolverId SolverPlanPackage
toMap = Graph.toMap . planIndex
-- | Remove packages from the install plan. This will result in an
-- error if there are remaining packages that depend on any matching
-- package. This is primarily useful for obtaining an install plan for
......
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