-
Notifications
You must be signed in to change notification settings - Fork 714
Support reinstalling more packages (including base and template-haskell) with GHC >=9.14 #10982
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
base: master
Are you sure you want to change the base?
Conversation
6cfbe6a
to
e49a4b5
Compare
ecb3159
to
dd63604
Compare
0bd8ca6
to
7b65354
Compare
7b65354
to
c035d6f
Compare
3f1729d
to
f087826
Compare
How does it affect solver's error messages, when it complains about impossible |
This change would only have an impact for GHC >9.14, Do you have a particular solver error in mind? |
f087826
to
730f5d5
Compare
In short, this change allows reinstalling packages like `base` and `template-haskell` with GHC >9.14, and it doesn't modify the behaviour of cabal-install with older versions of GHC for backwards-compatibility. cabal-install includes a hardcoded list of non-reinstallable packages. cabal-install will refuse to use a different version of these packages in a build plan unless the --allow-boot-library-installs flag is set. This list of packages is too pessimistic, and needlessly coupled to GHC. For instance, as of GHC-9.12, `base` and `template-haskell` can be "re-installed" without issue. This patch allows compilers to specify exactly which packages are wired-in and so should not be reinstalled. In the case of GHC-9.14+, this amounts to ghc-internal and ghc itself. If a compiler chooses to specify this information then it overrides the hardcoded non-reinstallable package list. Otherwise, it is still used for the sake of backwards compatibility. Note that this information comes in the form of unit-ids rather than package names. This patch extends the solver with constraints that force the use of a precise unit-id. The behaviour here is still somewhat pessimistic. In the future, we could further relax this restriction and only ban reinstalling these packafes when absolutely necessary, eg, only ban re-installing `ghc` if we are using plugins, etc. For the GHC change that added the interface to expose the unit-id of ghc-internal, see: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/13297 Resolves #10087 Co-Authored-By: Matthew Pickering <[email protected]>
730f5d5
to
99ea7c2
Compare
@@ -0,0 +1,14 @@ | |||
synopsis: Allow reinstalling packages like base and template-haskell for GHC>9.14 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
synopsis: Allow reinstalling packages like base and template-haskell for GHC>9.14 | |
synopsis: Allow reinstalling packages like base and template-haskell for GHC>=9.14 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the commit message also needs to be updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, except that it needs tests. It would be great to have solver tests in https://github.com/haskell/cabal/blob/master/cabal-install/tests/UnitTests/Distribution/Solver/Modular/Solver.hs, including one that tests the new error message.
I wonder if we'll need to update the heuristics in the solver that assume that there is only one version of base (though not in this PR).
EDIT: I mainly reviewed the changes to the solver. I'm not familiar with the changes to GHC.
@@ -0,0 +1,14 @@ | |||
synopsis: Allow reinstalling packages like base and template-haskell for GHC>9.14 | |||
packages: cabal-install |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line should include cabal-install-solver
.
@@ -0,0 +1,14 @@ | |||
synopsis: Allow reinstalling packages like base and template-haskell for GHC>9.14 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the commit message also needs to be updated.
, compilerInfoWiredInUnitIds :: Maybe [(PackageName, UnitId)] | ||
-- ^ 'UnitId's that the compiler doesn't support reinstalling. | ||
-- For instance, when using GHC plugins, one wants to use the | ||
-- exact same version of the `ghc` package as the one the | ||
-- compiler was linked against. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would help to describe the meaning of Nothing
.
, compilerWiredInUnitIds :: Maybe [(PackageName, UnitId)] | ||
-- ^ 'UnitId's that the compiler doesn't support reinstalling. | ||
-- For instance, when using GHC plugins, one wants to use the | ||
-- exact same version of the `ghc` package as the one the | ||
-- compiler was linked against. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
I was about to ask for solver tests as well. |
Summary
This change allows reinstalling packages like
base
andtemplate-haskell
with GHC >=9.14, and it doesn't modify the behaviourof cabal-install with older versions of GHC for backwards-compatibility.
Context
cabal-install includes a hardcoded list of non-reinstallable packages.
cabal-install will refuse to use a different version of these packages
in a build plan unless the --allow-boot-library-installs flag is set.
This list of packages is too pessimistic, and needlessly coupled to GHC.
For instance, as of GHC-9.12,
base
andtemplate-haskell
can be"re-installed" without issue.
Change
This patch allows compilers to specify exactly which packages are wired-in
and so should not be reinstalled.
In the case of GHC-9.14+, this amounts to ghc-internal and ghc itself.
If a compiler chooses to specify this information then it overrides the
hardcoded non-reinstallable package list. Otherwise, it is still used
for the sake of backwards compatibility.
Note that this information comes in the form of unit-ids rather than
package names. This patch extends the solver with constraints that force
the use of a precise unit-id.
The behaviour here is still somewhat pessimistic. In the future, we
could further relax this restriction and only ban reinstalling these
packafes when absolutely necessary, eg, only ban re-installing
ghc
ifwe are using plugins, etc.
For the GHC change that added the interface to expose the unit-id of
ghc-internal, see: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/13297
Resolves #10087
Manual QA Notes
Build a compiler from this branch: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/13297
and then confirm that when used with cabal from this branch it allows you to reinstall
template-haskell
for instance.For instance this is what happens if I try to build template-haskell with a released version of cabal-install:
cabal output
versus from this branch
cabal output
Include the following checklist in your PR:
significance: significant
in the changelog file.