Switch to Cabal-syntax; widen compatibility range#112
Conversation
| if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/main' | ||
| # if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/main' |
| cabal v2-configure \ | ||
| --constraint 'Cabal-syntax installed' \ | ||
| --enable-tests --enable-benchmarks |
There was a problem hiding this comment.
haskell-actions/setup already installs Cabal from the matrix.
the added --constraint 'Cabal-syntax installed' prevents the build from satisfying the dependency via compiling another (newest) version.
|
Thanks. In principle this looks like the right thing to do, but I don't understand who benefits from this. For each recent version of GHC there is a compatible |
|
In general: any consumer of the library might benefit from wider compatibility in its dependencies. In particular: I'm packaging up
|
|
... Case in point: here's a benchmark.
Measurement detailsAll builds made in a simple cabal.project with just On GHC 9.12.2, dependency resolution fails without You can see that without this patch, builds of Stan are consistently 50% larger. This happens because both |
|
I still don't understand. Arch is on GHC 9.4, right? So you should be using |
For the benchmark, I built stan with the latest |
|
Oh, well I'm definitely in favour of depending on only I'm skeptical whether the numbers you post have anything to do with different versions of Cabal linked. I wasn't even aware that Cabal/GHC could do that! Can you post some additional evidence, like the output of [EDIT: Oh I see, it's static, so My current guess is that the difference in size is due to depending on |
Then You might be right that the size reduction is due to reduced dependency footprint — I haven't checked symbol tables, only guessed a conjecture. |
|
Thanks. If you can reproduce the same behaviour on top of current |
|
Got it; thanks for clarity. I must switch to something else now; will postpone this for a day or two. After rechecking, will either close the PR or send a ping. |
These are, obviously, needed for Cabal < 3.6 which is already outside the supported version range.
* Cabal-syntax is a smaller package than Cabal; reduce dependency footprint. * Using Cabal-syntax requires Cabal >= 3.8 (and 3.6, with workarounds). * In addition to GHC version checks (which guard case arms' RHS's), also guard the LHS patterns, which may not exist depending on Cabal-syntax version. In all configurations, the entire case is exhaustive, and -Werror=incomplete-patterns (in extensions.cabal) guards that.
The library interface stay exactly the same -- thus, sub-patch-level version bump.
cf90f04 to
9b23e9f
Compare
|
I do still reproduce the issue. The build with my fix is 90 MB smaller. (repro steps, isolated in Docker)Same repository setup as before: Add packages: . extensions
shared: True
static: True
executable-dynamic: True
executable-static: False
optimization: 2
documentation: FalseAdd ARG GHC=9.6.7
FROM haskell:$GHC-slim
RUN cabal v2-update hackage.haskell.org,2025-06-21T11:05:47Z
COPY . /BUILD
WORKDIR /BUILD
RUN cabal install stan:exe:stanBuild the 2 images: I've switched to builds with dynamic linking — because they're more transparent for analysis than static builds. The size difference is fully explained by an additional build of The @tomjaguarpaw ping; additional discussion in #111. |
Firstly I'm very surprised to hear this because I thought that But secondly, you could have achieved the same size reduction by depending on |
|
By the way, your build matrix is not actually building against different versions of |
I'm pretty sure that's not the case.
|
|
The "cabal install" installed by the CI script is an executable not a library, and therefore has no bearing on what library versions |
Correct. Yet, I think this approach asks for vastly more maintenance overhead: next time a release (or revision) must be made — the release process now must be replicated three times. So, I guess it's desirable to avoid having 3 versions |
That is simply because you'd added 9.12 to the matrix — and I rebased, resolving conflicts. Watch if I comment out 9.12... |
I asked about this here: https://discourse.haskell.org/t/how-does-cabal-install-choose-boot-library-versions/12352 |
It has direct bearing.
I think Cabal just gives preference to already-installed versions (if they satisfy bounds, of course) — exactly to mitigate this multiple-versions-of-a-dependency bloat. |
OK, good. Let's say that's the supported workflow for now.
Or users of older compilers could just stick to the older version? It's not like In principle I agree with you: wider versions bounds are better. I just don't see that it's worth the effort in this case.
It has nothing to do with the matrix or CI. Try in your local checkout of your branch. It will fail. |
Yes; because of breaking changes in Cabal 3.14 (which 9.12 ships in boot-libs by default). See here haskell/cabal#10559 |
But having a particular version of
It doesn't. It installs newer versions of packages even if earlier versions are already installed, at least for non-boot packages. This is trivial to confirm: give it a go! |
OK, but that means that not only is your PR broken because it allows failing build configurations, it's also broken because the matrix doesn't pick that up. The matrix claims that 9.6.3 works with 3.14, but it doesn't: https://github.com/kowainik/extensions/actions/runs/15797159640/job/44530750661 |
|
Yes, the PR will need additional work to support 3.14, you're right. |
This does: extensions/.github/workflows/ci.yml Line 53 in b2df9fc |
It clearly doesn't because it doesn't pick up the build failure! Since there's a simple workaround and the proposed solution introduces additional complexity into the source and the CI system which seems difficult to get correct I'm not interested in tackling this issue now. Thank you for bringing it to my attention and your work so far. I am willing to revisit the issue if a situation arises where there is no longer a simple workaround. |
Resolves #111.
Dependency footprint reduced by switching
Cabal→Cabal-syntax.Compatibility widened from 3.14 (only) to
3.8,3.10,3.12,3.14.CI matrix extended accordingly.
The new cabal version guards — cross-checked by hand with the Cabal-syntax API(s).
Tested in this CI run — I'm leaving the branch exactly as was in CI; the workflow yaml will obviously have to revert a few tweaks before merging.
Maintainer edits open.