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

Remove single instance restriction from dependency solver for v2-build #6459

Open
grayjay opened this issue Dec 23, 2019 · 2 comments
Open

Comments

@grayjay
Copy link
Collaborator

grayjay commented Dec 23, 2019

The dependency solver always avoids choosing multiple instances for the same package and version within an install plan, even though that restriction isn't necessary with v2-build.

The constraint is enforced in a separate tree transformation:

-- | Enforce ghc's single instance restriction
--
-- From the solver's perspective, this means that for any package instance
-- (that is, package name + package version) there can be at most one qualified
-- goal resolving to that instance (there may be other goals _linking_ to that
-- instance however).
enforceSingleInstanceRestriction :: Tree d c -> Tree d c

Removing the single instance restriction has several benefits:

One disadvantage of removing the single instance restriction is that it would complicate the install plan by making it so that an instance is no longer uniquely identified by its package name and version. We might need to add more information when logging the install plan or errors.

Removing the single instance restriction requires improving the code that converts the solver's install plan to the install plan used by new-build, such as this TODO:

-- | Delivers an ordered list of fully configured packages.
--
-- TODO: This function is (sort of) ok. However, there's an open bug
-- w.r.t. unqualification. There might be several different instances
-- of one package version chosen by the solver, which will lead to
-- clashes.
toCPs :: Assignment -> RevDepMap -> [CP QPN]

@phadej
Copy link
Collaborator

phadej commented Dec 23, 2019

I'm not sure I follow, it's the case that solver does pick different versions for packages already, e.g. even building cabal project, we have local Cabal-3.3, and Cabal-3.0.0.0 somewhere for build-type: Custom.

Or is there a restriction that all qualified goals would pick the same Cabal-3.0.0.0 now? (if it's so, it feels silly IMHO, it thought that solver prefers to pick the same, but isn't required to do so)

EDIT: or do you mean, that there might be Cabal-3.0.0.0 and Cabal-3.2.0.0 in setup-depends, but all the Cabal-3.0.0.0 are the same? Hmm. I maybe start to understand what's happening.

@grayjay
Copy link
Collaborator Author

grayjay commented Dec 23, 2019

Yes, the solver just forces Cabal-3.0.0.0 under all qualifiers to be the same instance (have the same version and exactly the same dependencies), so that Cabal-3.0.0.0 is only built once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants