Implement ComponentId, replacing PackageKey and InstalledPackageId.
Today in Cabal, when you build and install a package, it is
uniquely identified using an InstalledPackageId which is computed
using the ABI hash of the library that was installed. There
are few problems with doing it this way:
- In a Nix-like world, we should instead uniquely identify
build products by some sort of hash on the inputs to the
compilation (source files, dependencies, flags). The ABI
hash doesn't capture any of this!
- An InstalledPackageId suggests that we can uniquely identify
build products by hashing the source and dependencies of
a package as a whole. But Cabal packages contain many components:
a library, test suite, executables, etc. Currently, when
we say InstalledPackageId, we are really just talking about
the dependencies of the library; however, this is unacceptable
if a Cabal package can install multiple libraries; we need
different identifiers for each.
- We've also needed to compute another ID, which we've called
the "package key", which is to be used for linker symbols
and type equality GHC-side. It is confusing what the distinction
between this ID and InstalledPackageIds are; the main reason
we needed another ID was because the package key was needed
prior to compilation, whereas the ABI hash was only available
afterwards.
This patch replaces InstalledPackageId and PackageKey with a
new identifier called ComponentId, which has the following
properties:
- It is computed per-component, and consists of a package
name, package version, hash of the ComponentIds
of the dependencies it is built against, and the name
of the component. For example, "foo-0.1-abcdef" continues
to identify the library of package foo-0.1, but
"foo-0.1-123455-foo.exe" would identify the executable,
and "foo-0.1-abcdef-bar" would identify a private sub-library
named bar.
- It is passed to GHC to be used for linker symbols and
type equality. So as far as GHC is concerned, this is
the end-all be-all identifier.
- Cabal the library has a simple, default routine for computing
a ComponentId which DOES NOT hash source code;
in a later patch Duncan is working on, cabal-install can
specify a more detailed ComponentId for a package
to be built with.
Here are some knock-on effects:
- 'id' is a ComponentId
- 'depends' is now a list of ComponentIds
- New 'abi' field to record what the ABI of a unit is (as it is no longer
computed by looking at the output of ghc --abi-hash).
- The 'HasInstalledPackageId' typeclass is renamed to
'HasComponentId'.
- GHC 7.10 has explicit compatibility handling with
a 'compatPackageKey' (an 'ComponentId') which is
in a compatible format. The value of this is read out
from the 'key' field.
Signed-off-by:
Edward Z. Yang <ezyang@cs.stanford.edu>
Showing
- Cabal/Cabal.cabal 5 additions, 0 deletionsCabal/Cabal.cabal
- Cabal/Distribution/InstalledPackageInfo.hs 32 additions, 19 deletionsCabal/Distribution/InstalledPackageInfo.hs
- Cabal/Distribution/Package.hs 25 additions, 195 deletionsCabal/Distribution/Package.hs
- Cabal/Distribution/Simple/Bench.hs 1 addition, 2 deletionsCabal/Distribution/Simple/Bench.hs
- Cabal/Distribution/Simple/Build.hs 8 additions, 11 deletionsCabal/Distribution/Simple/Build.hs
- Cabal/Distribution/Simple/Build/Macros.hs 5 additions, 5 deletionsCabal/Distribution/Simple/Build/Macros.hs
- Cabal/Distribution/Simple/Build/PathsModule.hs 0 additions, 3 deletionsCabal/Distribution/Simple/Build/PathsModule.hs
- Cabal/Distribution/Simple/BuildPaths.hs 4 additions, 4 deletionsCabal/Distribution/Simple/BuildPaths.hs
- Cabal/Distribution/Simple/Compiler.hs 5 additions, 0 deletionsCabal/Distribution/Simple/Compiler.hs
- Cabal/Distribution/Simple/Configure.hs 125 additions, 48 deletionsCabal/Distribution/Simple/Configure.hs
- Cabal/Distribution/Simple/GHC.hs 2 additions, 2 deletionsCabal/Distribution/Simple/GHC.hs
- Cabal/Distribution/Simple/GHC/IPI641.hs 7 additions, 6 deletionsCabal/Distribution/Simple/GHC/IPI641.hs
- Cabal/Distribution/Simple/GHC/IPI642.hs 7 additions, 6 deletionsCabal/Distribution/Simple/GHC/IPI642.hs
- Cabal/Distribution/Simple/GHC/Internal.hs 6 additions, 7 deletionsCabal/Distribution/Simple/GHC/Internal.hs
- Cabal/Distribution/Simple/GHCJS.hs 4 additions, 4 deletionsCabal/Distribution/Simple/GHCJS.hs
- Cabal/Distribution/Simple/Haddock.hs 2 additions, 2 deletionsCabal/Distribution/Simple/Haddock.hs
- Cabal/Distribution/Simple/HaskellSuite.hs 2 additions, 1 deletionCabal/Distribution/Simple/HaskellSuite.hs
- Cabal/Distribution/Simple/Install.hs 29 additions, 30 deletionsCabal/Distribution/Simple/Install.hs
- Cabal/Distribution/Simple/InstallDirs.hs 8 additions, 8 deletionsCabal/Distribution/Simple/InstallDirs.hs
- Cabal/Distribution/Simple/JHC.hs 13 additions, 5 deletionsCabal/Distribution/Simple/JHC.hs
Loading
Please register or sign in to comment