[Haskell-cafe] GHC API + Cabal API + Cabal version checks: is there a way out?
Niklas Hambüchen
mail at nh2.me
Fri Sep 6 16:17:44 CEST 2013
On Fri 06 Sep 2013 22:52:40 JST, Roman Cheplyaka wrote:
> The right solution for Cabal would be not to know anything about the
> GHC's database format at all.
>
> GHC and cabal communicate via a command line interface (`ghc-pkg dump`
> in our direction; `ghc-pkg update` in the other). So it would suffice to
> have a library which implements parsing and printing of the package
> description, and have that library shared between GHC and Cabal.
You are right. This is better.
GHC's dependency on cabal seems to actually be quite minimal!
I did a quick grep:
% grep -rI "import Distribution" --include "*.hs" --include "*.lhs*" .
| grep -v "libraries/" | grep -v Setup.hs | grep -v Setup.lhs | grep -v
utils/haddock
./utils/ghc-cabal/Main.hs:import Distribution.PackageDescription
./utils/ghc-cabal/Main.hs:import Distribution.PackageDescription.Check
hiding (doesFileExist)
./utils/ghc-cabal/Main.hs:import
Distribution.PackageDescription.Configuration
./utils/ghc-cabal/Main.hs:import Distribution.PackageDescription.Parse
./utils/ghc-cabal/Main.hs:import Distribution.System
./utils/ghc-cabal/Main.hs:import Distribution.Simple
./utils/ghc-cabal/Main.hs:import Distribution.Simple.Configure
./utils/ghc-cabal/Main.hs:import Distribution.Simple.LocalBuildInfo
./utils/ghc-cabal/Main.hs:import Distribution.Simple.Program
./utils/ghc-cabal/Main.hs:import Distribution.Simple.Program.HcPkg
./utils/ghc-cabal/Main.hs:import Distribution.Simple.Utils
(defaultPackageDesc, writeFileAtomic, toUTF8)
./utils/ghc-cabal/Main.hs:import Distribution.Simple.Build
(writeAutogenFiles)
./utils/ghc-cabal/Main.hs:import Distribution.Simple.Register
./utils/ghc-cabal/Main.hs:import Distribution.Text
./utils/ghc-cabal/Main.hs:import Distribution.Verbosity
./utils/ghctags/Main.hs:import Distribution.Simple.GHC (
componentGhcOptions )
./utils/ghctags/Main.hs:import Distribution.Simple.Configure (
getPersistBuildConfig )
./utils/ghctags/Main.hs:import Distribution.Simple.Compiler (
compilerVersion )
./utils/ghctags/Main.hs:import Distribution.Simple.Program.GHC (
renderGhcOptions )
./utils/ghctags/Main.hs:import Distribution.PackageDescription (
library, libBuildInfo )
./utils/ghctags/Main.hs:import Distribution.Simple.LocalBuildInfo
./utils/ghc-pkg/Main.hs:import
Distribution.InstalledPackageInfo.Binary()
./utils/ghc-pkg/Main.hs:import Distribution.ModuleName hiding (main)
./utils/ghc-pkg/Main.hs:import Distribution.InstalledPackageInfo
./utils/ghc-pkg/Main.hs:import Distribution.Compat.ReadP
./utils/ghc-pkg/Main.hs:import Distribution.ParseUtils
./utils/ghc-pkg/Main.hs:import Distribution.Package hiding (depends)
./utils/ghc-pkg/Main.hs:import Distribution.Text
./utils/ghc-pkg/Main.hs:import Distribution.Version
./compiler/ghci/Linker.lhs:import Distribution.Package hiding (depends,
PackageId)
./compiler/main/Packages.lhs:import Distribution.InstalledPackageInfo
./compiler/main/Packages.lhs:import
Distribution.InstalledPackageInfo.Binary
./compiler/main/Packages.lhs:import Distribution.Package hiding
(PackageId,depends)
./compiler/main/PackageConfig.hs:import
Distribution.InstalledPackageInfo
./compiler/main/PackageConfig.hs:import Distribution.ModuleName
./compiler/main/PackageConfig.hs:import Distribution.Package hiding
(PackageId)
./compiler/main/PackageConfig.hs:import Distribution.Text
./compiler/main/PackageConfig.hs:import Distribution.Version
./compiler/main/Finder.lhs:import Distribution.Text
./compiler/main/Finder.lhs:import Distribution.Package hiding
(PackageId)
As you can see, there are only 4 files in ghc itself that depend on
Cabal:
./compiler/ghci/Linker.lhs
./compiler/main/Packages.lhs
./compiler/main/PackageConfig.hs
./compiler/main/Finder.lhs
(plus 1 file for ghc-pkg: ./utils/ghc-pkg/Main.hs)
The ones in GHC core seem to rely only on quite basic data types.
From this, I would boldly claim that people have spent more time making
the GHC build system work with this Cabal dependency than it would take
stripping it off!
(In fact, I would try to do this right now if the GHC build system
wouldn't take so long to compile even the smallest changes ...)
More information about the Haskell-Cafe
mailing list