Repository navigation
inplace packages, expose by unit id, recompile check - #1
Closed
philderbeast wants to merge 3 commits into
Closed
philderbeast wants to merge 3 commits into
philderbeast wants to merge 3 commits into
Conversation
A Hackage package that depends on a local package (hackage-security
depends on Cabal-syntax in the cabal repository) is built by cabal
in-place, with style "inplace" in plan.json, rather than installed in
the store. Two problems followed:
* collect_packages() records such a package as None, and main() then
crashed unpacking it:
used_roots = {db for _, db in packages.values() if db in STORE_DBS}
TypeError: cannot unpack non-iterable NoneType object
* get_root_dep_ids() only walked the dependencies of "local"
components, so the store packages that only an in-place package
needs (ed25519, base64-bytestring for hackage-security) got no
haskell_prebuilt_library() rule.
Treat "inplace" like "local" when collecting root dependencies: not a
root itself (buck2 has to build it from source, like a local package),
but everything it depends on from the store is. Skip the None entries
when choosing the store root.
get_packages_info() passed each direct dependency as `-package <name>`,
which GHC resolves by picking the highest version visible in any of the
package dbs on the command line. That goes wrong as soon as two
versions of a package are visible:
* a boot package rebuilt in the cabal store (time-1.14, directory,
unix, process) lost to the newer one in GHC's global db
(time-1.15), and everything built against the store version then
failed with mismatched types such as
`time-1.14:Data.Time.Clock.Internal.UTCTime.UTCTime` vs `UTCTime`;
* a library built from source by buck2 (registered as version 1.0.0)
lost to a same-named package in the global db, e.g. the Cabal and
Cabal-syntax that ship with GHC.
HaskellLibraryInfo already carries the unit id (the full hashed id for
prebuilt packages, the target name for buck2-built ones), so use
`-package-id <id>` whenever it is set. Resolution is then exact
regardless of what else the dbs contain. The `-package`/
`-expose-package` path is kept for infos without an id.
Each haskell_library()/haskell_binary() is a single `ghc --make` action writing to fresh -odir/-hidir directories, so any edit recompiled the whole package, and every dependent package in full after it. On the cabal repository a whitespace-only change in one Cabal module cost 87s. Set no_outputs_cleanup on the compile action so that the previous run's objects and interfaces are still there and `ghc --make` only recompiles the modules whose sources or imported interfaces changed. Dependent packages still re-run their action, but their --make finds the ABIs unchanged and finishes in well under a second. The same edit now takes 3s. The comment being replaced said this had to wait for GHC 9.4, which tracks file changes by hash rather than timestamp; that is long since the case.
Owner
|
I think this is done - the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Following its mention on discourse, I tried haskell-buck2 with haskell/cabal, with help from Claude Fable 5.1.
Because Cabal is a boot library, I needed to vendor1 hackage-security, so it became inplace.
After an initial build, I tested the rebuild by making a whitespace change to
Cabal/src/Distribution/Simple/GHCJS.hsand then building:cabal build all --enable-teststook 22sbuck2 build //...took 1m 30sAfter the changes in this pull request, the buck2 build now takes 4s.
Footnotes
Cabal doesn't yet have a vendor command, https://github.com/haskell/cabal/issues/10935. ↩