Repository navigation
Support reinstalling more packages (including base and template-haskell) with GHC >=9.14 - #10982
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? |
730f5d5 to
99ea7c2
Compare
There was a problem hiding this comment.
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.
|
I was about to ask for solver tests as well. |
|
Thanks folks! I'll try to come back to this and add some tests soon (approx in the next few weeks) |
f54ff0f to
8842fdf
Compare
|
I have added some test cases. I have extended the Solver options to allow setting wired in unit ids. As this setting is quite new, the reasonable default is to have it unset, and only set it for relevant test cases. In the future, this will flip and I will create a ticket, so we remember to update the default in a few years time. |
d520dd8 to
6fc61fb
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]>
6fc61fb to
f30b90c
Compare
GHC-9.14 ships with base-4.22, since that release of GHC, base is "reinstallable". This means that we can install a version of base that is not the one that was shipped with GHC. In #10982, we extended cabal-install to allow reinstalling base when GHC>=9.14 Yet, we should *not* allow solving for very old versions of base. Older versions of base can be picked by the solver, but they are unbuildable and give confusing error messages. To solve this, we simply also add a constraint that base must be >=4.22 if we take it to be reinstallable. So, now the error mentions that versions of base <4.22 are non-reinstallable. This is an unfortunate hack to resolve this error, but it's the best we can do. Alternatively we could try to revise old versions of base so that the solver does not pick them, but then we would still get a somewhat confusing error message (old versions of base require such and such a version of the rts), and it would require that users have a version of the Hackage tarball that is latter than the revisions. Resolves #11356
GHC-9.14 ships with base-4.22, since that release of GHC, base is "reinstallable". This means that we can install a version of base that is not the one that was shipped with GHC. In #10982, we extended cabal-install to allow reinstalling base when GHC>=9.14 Yet, we should *not* allow solving for very old versions of base. Older versions of base can be picked by the solver, but they are unbuildable and give confusing error messages. To solve this, we simply also add a constraint that base must be >=4.22 if we take it to be reinstallable. So, now the error mentions that versions of base <4.22 are non-reinstallable. This is an unfortunate hack to resolve this error, but it's the best we can do. Alternatively we could try to revise old versions of base so that the solver does not pick them, but then we would still get a somewhat confusing error message (old versions of base require such and such a version of the rts), and it would require that users have a version of the Hackage tarball that is latter than the revisions. Resolves #11356
GHC-9.14 ships with base-4.22, since that release of GHC, base is "reinstallable". This means that we can install a version of base that is not the one that was shipped with GHC. In #10982, we extended cabal-install to allow reinstalling base when GHC>=9.14 Yet, we should *not* allow solving for very old versions of base. Older versions of base can be picked by the solver, but they are unbuildable and give confusing error messages. To solve this, we simply also add a constraint that base must be >=4.22 if we take it to be reinstallable. So, now the error mentions that versions of base <4.22 are non-reinstallable. This is an unfortunate hack to resolve this error, but it's the best we can do. Alternatively we could try to revise old versions of base so that the solver does not pick them, but then we would still get a somewhat confusing error message (old versions of base require such and such a version of the rts), and it would require that users have a version of the Hackage tarball that is latter than the revisions. Resolves #11356
GHC-9.14 ships with base-4.22, since that release of GHC, base is "reinstallable". This means that we can install a version of base that is not the one that was shipped with GHC. In #10982, we extended cabal-install to allow reinstalling base when GHC>=9.14 Yet, we should *not* allow solving for very old versions of base. Older versions of base can be picked by the solver, but they are unbuildable and give confusing error messages. To solve this, we simply also add a constraint that base must be >=4.22 if we take it to be reinstallable. So, now the error mentions that versions of base <4.22 are non-reinstallable. This is an unfortunate hack to resolve this error, but it's the best we can do. Alternatively we could try to revise old versions of base so that the solver does not pick them, but then we would still get a somewhat confusing error message (old versions of base require such and such a version of the rts), and it would require that users have a version of the Hackage tarball that is latter than the revisions. Resolves #11356
GHC-9.14 ships with base-4.22, since that release of GHC, base is "reinstallable". This means that we can install a version of base that is not the one that was shipped with GHC. In haskell#10982, we extended cabal-install to allow reinstalling base when GHC>=9.14 Yet, we should *not* allow solving for very old versions of base. Older versions of base can be picked by the solver, but they are unbuildable and give confusing error messages. To solve this, we simply also add a constraint that base must be >=4.22 if we take it to be reinstallable. So, now the error mentions that versions of base <4.22 are non-reinstallable. This is an unfortunate hack to resolve this error, but it's the best we can do. Alternatively we could try to revise old versions of base so that the solver does not pick them, but then we would still get a somewhat confusing error message (old versions of base require such and such a version of the rts), and it would require that users have a version of the Hackage tarball that is latter than the revisions. Resolves haskell#11356
Summary
This change allows reinstalling packages like
baseandtemplate-haskellwith 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,
baseandtemplate-haskellcan 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
ghcifwe 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-haskellfor 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: significantin the changelog file.