Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
After implementing new installed package ID (hash of sdist), get rid of package keys #2745
The Cabal Nix GSOC is planning to change installed package IDs to be the hash of the sdist tarball of an package (instead of the ABI hash of the compiled code). https://ghc.haskell.org/trac/ghc/wiki/Commentary/GSoC_Cabal_nix Once we do this, SPJ and I propose to GET RID of package keys, removing a nettlesome source of indirection from Cabal and GHC. Here are the details:
Currently, GHC has two notions of package identity: the installed package ID (presently the ABI hash) which uniquely identifies a package in the installed package database, and the package key, which is used for linker symbols and type identity. In fact, package keys are a COARSE version of installed package IDs: they contain information about the transitive dependencies Cabal picked, but not any details about the actual source code. (Put alternately: if the package key changes, the installed package ID changes, but not vice versa.)
Why do we have a fine-grained notion of identity, and a coarse-grained version? Historically, there were two reasons:
(1) is no longer applicable when installed package IDs are computed by hasing sdist. And (2) can be addressed simply by picking STABLE, fake installed package IDs when doing local development; e.g. "containers-2.0-inplace". If you want to install to the global database, you'll have to recompile everything with the right IPIDs, but for inplace development this should work great.
I went ahead and implemented a first draft of this at PR #2792
The primary complication is, whatever we do has to remain compatible with old versions of GHC. This means we still have to generate "package keys" and whatever format we generate has to be compatible with what ghc-pkg accepts. The best thing to do is to just say that an IPID is the PK (and this is what I have implemented). Unfortunately, when I coded ghc-pkg I gave it a very restrictive parser which only accepted "pkgname_HASH". This means, for GHC 7.10, we have to be very careful about the format of IPIDs, because we will otherwise break the parser format.
One possibility of working around with is to bring back is to bring back the distinction between an installed package ID and a "fuller" identifier which includes versions and is used in directory names, but this adds some modest extra complication to the code. This would allow us to make Cabal continue to work with GHC 7.10 in a nearly equivalent way (except for the fact that package keys are being calculated differently).