Group installed multilib packages#11788
Conversation
15fb9bf to
1b7db36
Compare
|
Would it be possible to add some prose about "the grouping approach" somewhere close to this PR (commit message or PR description or both)? |
Before this patch, sub-libraries (either public or private) of installed packages are treated as top level separate packages from solvers point of view. This differs from how source packages are handled, which are treated as a single package. Sub-libraries of installed packages needed munging to prevent conflicts like described in `Note [Index conversion with internal libraries]`. Due to package name munging, top level library we are trying to build, cannot depend on public sub-libraries, more precisely - it can, but the installed packages are never used. Instead they are always rebuilt from source (as only source package index exposes public sub-libs correctly). The idea is to make packages coming from *installed* package index look similar to packages coming from *source* - appearing as a single package instead of multiple. The approach we choose is adding a grouping pass to solvers installed package index conversion. After the index is converted, we group installed packages by name and version and adjust all dependencies to point to newly built groups instead of split sub-lib packages. This way, solver only sees a single package (similar to how source packages are treated). This is done by means of adding * `InstGroup` `Loc` to solver * `installedSublibs` field to `InstalledPackageInfo` * and finally expanding `installedSublibs` in `ProjectPlanning` Now the sub-libs are handled correctly and build process picks installed public sub-libs when available. It also allows us to drop package name munging hacks from solver completely. Closes haskell#6039
same as `IPI.sourceComponentName`
This is no longer needed since private sub-libraries won't appear at top level, only as `installedSublibs` of top-level ones. Related to haskell#6039
1b7db36 to
c7e3c0a
Compare
|
Sure! Adding a stripped before/after trace: cabal freeze trace beforeNote two libraries, both exposing cabal freeze trace after |
|
@sorki Thanks for working on finishing #6039! I haven't read the code yet, but it sounds like this PR doesn't currently add a way to check whether two installed libraries with the same package name and version were installed together. I'm concerned that that could cause the solver to err in the unsafe direction and allow inconsistent dependencies. For example, a source package (A-1.0) could depend on one installed sub-library from B-2.0 configured with one set of flags and a second installed sub-library from B-2.0 configured with a different set of flags. This inconsistency in dependencies could lead to subtle and confusing bugs. There is some discussion of how to group libraries by instance starting at #6039 (comment). Would it be possible to add a check in this PR, even if it's initially too conservative and needs to be loosened later? Here are a few ideas for how to implement the check:
|
Thanks for the feedback! This indeed only helps in simple
I've tried this but quickly found issues:
Trying this approach now - grabbing |
I'm not sure I understand. I would expect the situation in the second bullet point to lead to a conflict, because the solver can't choose two instances for the same package name. I would expect it to have to choose one instance, either the one with the main library or the one with the sub-library. So there would be no solution if a source package depended on both libraries. I know that this approach isn't perfect, but I suggested it because I think that it only fails in the safe direction (failing to find a solution when there is one), so it could be a good temporary solution. It would allow us to merge this PR quickly without increasing the scope too much. Then the full solution, such as |
Before this patch, sub-libraries (either public or private) of installed
packages are treated as top level separate packages from solvers point of view.
This differs from how source packages are handled, which are treated as
a single package.
Sub-libraries of installed packages needed munging to prevent conflicts
like described in
Note [Index conversion with internal libraries].Due to package name munging, top level library we are trying to build,
cannot depend on public sub-libraries, more precisely - it can, but
the installed packages are never used. Instead they are always
rebuilt from source (as only source package index exposes public
sub-libs correctly).
The idea is to make packages coming from installed package index look
similar to packages coming from source - appearing as a single package
instead of multiple.
The approach we choose is adding a grouping pass to solvers installed package
index conversion. After the index is converted, we group installed
packages by name and version and adjust all dependencies to point to
newly built groups instead of split sub-lib packages. This way, solver
only sees a single package (similar to how source packages are treated).
This is done by means of adding
InstGroupLocto solverinstalledSublibsfield toInstalledPackageInfoinstalledSublibsinProjectPlanningNow the sub-libs are handled correctly and build process
picks installed public sub-libs when available. It also
allows us to drop package name munging hacks from solver
completely.
See #6039
Template Α: This PR modifies behaviour or interface
Include the following checklist in your PR:
significance: significantin the changelog file.