Commit f47732a5 authored by Edward Z. Yang's avatar Edward Z. Yang
Browse files

Refactor Cabal around the idea of "library names".



In GHC 7.10, Cabal always generate package keys, including in
cases where Backpack was involved (e.g. --instantiated-with).
In fact, in these case, GHC needs to be able to generate the
package key (because it will often make a substitution on the
instantiation, and needs to know if this identity coincides with
anything else we've seen previously).

Thus, we introduce a new notion, the 'LibraryName', which
is JUST the non-Backpack portion of a package key.  For ordinary
packages that are definite, a 'LibraryName' is simply
the 'PackageId' plus 'PackageKey'; for indefinite Backpack packages,
when a package gets instantiatied, it may end up with different
'PackageKey's even though the 'LibraryName' stays the same.
'LibraryName's can be computed purely by Cabal.

This patch:

    - Defines library name, which are the source package ID plus
      a hash of all the source package ID and the library names of external,
      textual dependencies,

    - Redefines the package key to be JUST the hash portion of a
      library name, in the case that Backpack is not used,

    - Records the library name in InstalledPackageInfo.

Note: the source package ID is included both externally (so the library
name is a useful handle to refer to package) and internally (so the
hash can stand alone as the package key.)

A major refactoring which is part of this commit is moving package keys/library
names from LocalBuildInfo to LibComponentBuildInfo.  If you have an LBI, you can
still extract a package key/library name using the new
localPackageKey/localLibraryName function (which looks through the
ComponentBuildInfos of a LocalBuildInfo for the library in question).  This is
conceptually cleaner for two reasons:

    1. Only dependencies of the *library* are counted as part
    of the library name, as opposed to *all* dependencies which
    we previously used.

    2. A library name doesn't really mean much for an executable,
    or a test suite, since no one else will have to link against
    them.  So we can fall back on something simpler.

A more minor refactoring is the 'LibraryName' type, which was
previously defined by LocalBuildInfo and generally looked something
like "HSprocess-0.1-XXXX".  We change the meaning of 'LibraryName'
to be "process-0.1-XXXX" (thus we have to insert some HS additions
in the code) and eliminate componentLibraries, thus assuming that
there is only ONE Haskell library (which was the case.)  So
we remove a little bit of generality and in return get code
that is much easier to read.  (The only downside is GHC's hack
to split DLLs into multiples has to be adjusted slightly, but
this is not a big price to pay.)
Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
parent 060f91e5
......@@ -28,6 +28,7 @@
module Distribution.InstalledPackageInfo (
InstalledPackageInfo_(..), InstalledPackageInfo,
libraryName,
OriginalModule(..), ExposedModule(..),
ParseResult(..), PError(..), PWarning,
emptyInstalledPackageInfo,
......@@ -50,7 +51,8 @@ import Distribution.License ( License(..) )
import Distribution.Package
( PackageName(..), PackageIdentifier(..)
, PackageId, InstalledPackageId(..)
, packageName, packageVersion, PackageKey(..) )
, packageName, packageVersion, PackageKey(..)
, LibraryName(..) )
import qualified Distribution.Package as Package
import Distribution.ModuleName
( ModuleName )
......@@ -110,6 +112,9 @@ data InstalledPackageInfo_ m
}
deriving (Generic, Read, Show)
libraryName :: InstalledPackageInfo_ a -> LibraryName
libraryName ipi = Package.packageKeyLibraryName (sourcePackageId ipi) (packageKey ipi)
instance Binary m => Binary (InstalledPackageInfo_ m)
instance Package.Package (InstalledPackageInfo_ str) where
......@@ -287,7 +292,7 @@ basicFieldDescrs =
installedPackageId (\ipid pkg -> pkg{installedPackageId=ipid})
, simpleField "key"
disp parse
packageKey (\ipid pkg -> pkg{packageKey=ipid})
packageKey (\pk pkg -> pkg{packageKey=pk})
, simpleField "license"
disp parseLicenseQ
license (\l pkg -> pkg{license=l})
......
......@@ -24,12 +24,17 @@ module Distribution.Package (
-- * Installed package identifiers
InstalledPackageId(..),
-- * Package keys (used for linker symbols and library name)
-- * Package keys (used for linker symbols)
PackageKey(..),
mkPackageKey,
packageKeyHash,
packageKeyLibraryName,
-- * Library name (used for install path, package key)
LibraryName(..),
emptyLibraryName,
getHSLibraryName,
-- * Package source dependencies
Dependency(..),
thisPackageVersion,
......@@ -42,7 +47,6 @@ module Distribution.Package (
PackageInstalled(..),
) where
import Distribution.ModuleName ( ModuleName )
import Distribution.Version
( Version(..), VersionRange, anyVersion, thisVersion
, notThisVersion, simplifyVersionRange )
......@@ -53,12 +57,11 @@ import Distribution.Compat.ReadP ((<++))
import qualified Text.PrettyPrint as Disp
import Control.DeepSeq (NFData(..))
import Data.Ord ( comparing )
import Distribution.Compat.Binary (Binary)
import qualified Data.Char as Char
( isDigit, isAlphaNum, isUpper, isLower, ord, chr )
import Data.Data ( Data )
import Data.List ( intercalate, foldl', sortBy )
import Data.List ( intercalate, foldl', sort )
import Data.Typeable ( Typeable )
import Data.Word ( Word64 )
import GHC.Fingerprint ( Fingerprint(..), fingerprintString )
......@@ -140,50 +143,14 @@ instance Text InstalledPackageId where
-- concept written explicity in Cabal files; on the other hand, a 'PackageKey'
-- may contain, for example, information about the transitive dependency
-- tree of a package. Why is this not an 'InstalledPackageId'? A 'PackageKey'
-- affects the ABI because it is used for linker symbols; however, an
-- 'InstalledPackageId' can be used to distinguish two ABI-compatible versions
-- of a library.
--
-- The key is defined to be a 128-bit MD5 hash, separated into two 64-bit
-- components (the most significant component coming first) which are
-- individually base-62 encoded (A-Z, a-z, 0-9).
--
-- @
-- key ::= hash64 hash64
-- hash64 ::= [A-Za-z0-9]{11}
-- @
--
-- The string that is hashed is specified as raw_key:
--
-- @
-- raw_key ::= package_id "\n"
-- holes_nl
-- depends_nl
-- package_id ::= package_name "-" package_version
-- holes_nl ::= ""
-- | hole_inst "\n" holes_nl
-- hole_inst ::= modulename " " key ":" modulename
-- depends_nl ::= ""
-- | depend "\n" depends_nl
-- depend ::= key
-- should be stable so that we can incrementally recompile after a source edit;
-- however, an 'InstalledPackageId' may change even with source.
--
--
-- The holes list MUST be sorted by the first modulename; the depends list
-- MUST be sorted by the key. holes describes the backing implementations of
-- all holes in the package; depends describes all of the build-depends of
-- a package. A package key MAY be used in holes even if it is not
-- mentioned in depends: depends contains STRICTLY packages which are
-- textually mentioned in the package description.
--
-- The trailing newline is MANDATORY.
--
-- There is also a variant of package key which is prefixed by a informational
-- string. This is strictly for backwards compatibility with GHC 7.10.
--
-- @
-- infokey ::= infostring "_" key
-- infostring ::= [A-Za-z0-9-]+
-- Package keys may be generated either by Cabal or GHC. In particular,
-- ordinary, "old-style" packages which don't use Backpack features can
-- have their package keys generated directly by Cabal and coincide with
-- 'LibraryName's. However, Backpack keys are generated by GHC may exhibit
-- more variation than a 'LibraryName'.
--
data PackageKey
-- | Modern package key which is a hash of the PackageId and the transitive
......@@ -207,19 +174,13 @@ fingerprintPackageKey (Fingerprint a b) = PackageKey Nothing a b
-- immediate dependencies.
mkPackageKey :: Bool -- are modern style package keys supported?
-> PackageId
-> [PackageKey] -- dependencies
-> [(ModuleName, (PackageKey, ModuleName))] -- hole instantiations
-> [LibraryName] -- dependencies
-> PackageKey
mkPackageKey True pid deps holes =
mkPackageKey True pid deps =
fingerprintPackageKey . fingerprintString $
display pid ++ "\n" ++
-- NB: packageKeyHash, NOT display
concat [ display m ++ " " ++ packageKeyHash p'
++ ":" ++ display m' ++ "\n"
| (m, (p', m')) <- sortBy (comparing fst) holes] ++
concat [ packageKeyHash d ++ "\n"
| d <- sortBy (comparing packageKeyHash) deps]
mkPackageKey False pid _ _ = OldPackageKey pid
concat [ display dep ++ "\n" | dep <- sort deps ]
mkPackageKey False pid _ = OldPackageKey pid
-- The base-62 code is based off of 'locators'
-- ((c) Operational Dynamics Consulting, BSD3 licensed)
......@@ -269,14 +230,18 @@ readBase62Fingerprint s = Fingerprint w1 w2
w1 = fromBase62 s1
w2 = fromBase62 (take word64Base62Len s2)
-- | Compute the hash (without a prefix) of a package key. In GHC 7.12
-- this is equivalent to display.
packageKeyHash :: PackageKey -> String
packageKeyHash (PackageKey _ w1 w2) = toBase62 w1 ++ toBase62 w2
packageKeyHash (OldPackageKey pid) = display pid
packageKeyLibraryName :: PackageId -> PackageKey -> String
-- | Legacy function for GHC 7.10 to compute a LibraryName based on
-- the package key.
packageKeyLibraryName :: PackageId -> PackageKey -> LibraryName
packageKeyLibraryName pid (PackageKey _ w1 w2) =
display pid ++ "-" ++ toBase62 w1 ++ toBase62 w2
packageKeyLibraryName _ (OldPackageKey pid) = display pid
LibraryName (display pid ++ "-" ++ toBase62 w1 ++ toBase62 w2)
packageKeyLibraryName _ (OldPackageKey pid) = LibraryName (display pid)
instance Text PackageKey where
disp (PackageKey mb_prefix w1 w2)
......@@ -302,6 +267,38 @@ instance NFData PackageKey where
rnf (PackageKey mb _ _) = rnf mb
rnf (OldPackageKey pid) = rnf pid
-- ------------------------------------------------------------
-- * Library names
-- ------------------------------------------------------------
-- | A library name consists of not only a source package
-- id ('PackageId') but also the library names of all textual
-- dependencies; thus, a library name uniquely identifies an
-- installed packages up to the dependency resolution done by Cabal.
-- Create using 'packageKeyLibraryName'. Library names are opaque,
-- Cabal defined strings.
newtype LibraryName
= LibraryName String
deriving (Generic, Read, Show, Eq, Ord, Typeable, Data)
instance Binary LibraryName
-- | Default library name for when it is not known.
emptyLibraryName :: LibraryName
emptyLibraryName = LibraryName ""
-- | Returns library name prefixed with HS, suitable for filenames
getHSLibraryName :: LibraryName -> String
getHSLibraryName (LibraryName s) = "HS" ++ s
instance Text LibraryName where
disp (LibraryName s) = Disp.text s
parse = LibraryName `fmap` Parse.munch1 hash_char
where hash_char c = Char.isAlphaNum c || c `elem` "-_."
instance NFData LibraryName where
rnf (LibraryName s) = rnf s
-- ------------------------------------------------------------
-- * Package source dependencies
-- ------------------------------------------------------------
......
......@@ -24,7 +24,7 @@ import Distribution.Simple.InstallDirs
( fromPathTemplate, initialPathTemplateEnv, PathTemplateVariable(..)
, substPathTemplate , toPathTemplate, PathTemplate )
import qualified Distribution.Simple.LocalBuildInfo as LBI
( LocalBuildInfo(..) )
( LocalBuildInfo(..), localLibraryName )
import Distribution.Simple.Setup ( BenchmarkFlags(..), fromFlag )
import Distribution.Simple.UserHooks ( Args )
import Distribution.Simple.Utils ( die, notice, rawSystemExitCode )
......@@ -123,6 +123,6 @@ benchOption pkg_descr lbi bm template =
fromPathTemplate $ substPathTemplate env template
where
env = initialPathTemplateEnv
(PD.package pkg_descr) (LBI.pkgKey lbi)
(PD.package pkg_descr) (LBI.localLibraryName lbi)
(compilerInfo $ LBI.compiler lbi) (LBI.hostPlatform lbi) ++
[(BenchmarkNameVar, toPathTemplate $ PD.benchmarkName bm)]
......@@ -35,10 +35,11 @@ import qualified Distribution.Simple.Build.PathsModule as Build.PathsModule
import Distribution.Package
( Package(..), PackageName(..), PackageIdentifier(..)
, Dependency(..), thisPackageVersion, mkPackageKey, packageName )
, Dependency(..), thisPackageVersion, PackageKey(..), packageName
, LibraryName(..) )
import Distribution.Simple.Compiler
( Compiler, CompilerFlavor(..), compilerFlavor
, PackageDB(..), PackageDBStack, packageKeySupported )
, PackageDB(..), PackageDBStack )
import Distribution.PackageDescription
( PackageDescription(..), BuildInfo(..), Library(..), Executable(..)
, TestSuite(..), TestSuiteInterface(..), Benchmark(..)
......@@ -54,13 +55,13 @@ import Distribution.Simple.BuildTarget
import Distribution.Simple.PreProcess
( preprocessComponent, preprocessExtras, PPSuffixHandler )
import Distribution.Simple.LocalBuildInfo
( LocalBuildInfo(compiler, buildDir, withPackageDB, withPrograms, pkgKey)
( LocalBuildInfo(compiler, buildDir, withPackageDB, withPrograms)
, Component(..), componentName, getComponent, componentBuildInfo
, ComponentLocalBuildInfo(..), pkgEnabledComponents
, withComponentsInBuildOrder, componentsInBuildOrder
, ComponentName(..), showComponentName
, ComponentDisabledReason(..), componentDisabledReason
, inplacePackageId, LibraryName(..) )
, inplacePackageId )
import Distribution.Simple.Program.Types
import Distribution.Simple.Program.Db
import qualified Distribution.Simple.Program.HcPkg as HcPkg
......@@ -392,7 +393,7 @@ testSuiteLibV09AsLibAndExe :: PackageDescription
testSuiteLibV09AsLibAndExe pkg_descr
test@TestSuite { testInterface = TestSuiteLibV09 _ m }
clbi lbi distPref pwd =
(pkg, lib, libClbi, lbi', ipi, exe, exeClbi)
(pkg, lib, libClbi, lbi, ipi, exe, exeClbi)
where
bi = testBuildInfo test
lib = Library {
......@@ -406,8 +407,9 @@ testSuiteLibV09AsLibAndExe pkg_descr
libClbi = LibComponentLocalBuildInfo
{ componentPackageDeps = componentPackageDeps clbi
, componentPackageRenaming = componentPackageRenaming clbi
, componentLibraries = [LibraryName (testName test)]
, componentLibraryName = LibraryName "test"
, componentExposedModules = [IPI.ExposedModule m Nothing Nothing]
, componentPackageKey = OldPackageKey (PackageIdentifier (PackageName (testName test)) (pkgVersion (package pkg_descr)))
}
pkg = pkg_descr {
package = (package pkg_descr) {
......@@ -418,16 +420,8 @@ testSuiteLibV09AsLibAndExe pkg_descr
, testSuites = []
, library = Just lib
}
-- Hack to make the library compile with the right package key.
-- Probably the "right" way to do this is move this information to
-- the ComponentLocalBuildInfo, but it seems odd that a single package
-- can define multiple actual packages.
lbi' = lbi {
pkgKey = mkPackageKey (packageKeySupported (compiler lbi))
(package pkg) [] []
}
ipkgid = inplacePackageId (packageId pkg)
ipi = inplaceInstalledPackageInfo pwd distPref pkg ipkgid lib lbi' libClbi
ipi = inplaceInstalledPackageInfo pwd distPref pkg ipkgid lib lbi libClbi
testDir = buildDir lbi </> stubName test
</> stubName test ++ "-tmp"
testLibDep = thisPackageVersion $ package pkg
......
......@@ -33,7 +33,7 @@ import Distribution.PackageDescription
import Distribution.Simple.Compiler
( packageKeySupported )
import Distribution.Simple.LocalBuildInfo
( LocalBuildInfo(compiler, pkgKey, withPrograms), externalPackageDeps )
( LocalBuildInfo(compiler, withPrograms), externalPackageDeps, localPackageKey )
import Distribution.Simple.Program.Db
( configuredPrograms )
import Distribution.Simple.Program.Types
......@@ -97,11 +97,12 @@ generateMacros prefix name version =
(major1:major2:minor:_) = map show (versionBranch version ++ repeat 0)
-- | Generate the @CURRENT_PACKAGE_KEY@ definition for the package key
-- of the current package, if supported by the compiler
-- of the current package, if supported by the compiler.
-- NB: this only makes sense for definite packages.
generatePackageKeyMacro :: LocalBuildInfo -> String
generatePackageKeyMacro lbi
| packageKeySupported (compiler lbi) =
"#define CURRENT_PACKAGE_KEY \"" ++ display (pkgKey lbi) ++ "\"\n\n"
"#define CURRENT_PACKAGE_KEY \"" ++ display (localPackageKey lbi) ++ "\"\n\n"
| otherwise = ""
fixchar :: Char -> Char
......
......@@ -34,14 +34,14 @@ module Distribution.Simple.BuildPaths (
import System.FilePath ((</>), (<.>))
import Distribution.Package
( packageName )
( packageName, LibraryName, getHSLibraryName )
import Distribution.ModuleName (ModuleName)
import qualified Distribution.ModuleName as ModuleName
import Distribution.Compiler
( CompilerId(..) )
import Distribution.PackageDescription (PackageDescription)
import Distribution.Simple.LocalBuildInfo
( LocalBuildInfo(buildDir), LibraryName(..) )
( LocalBuildInfo(buildDir) )
import Distribution.Simple.Setup (defaultDistPref)
import Distribution.Text
( display )
......@@ -82,17 +82,17 @@ haddockName pkg_descr = display (packageName pkg_descr) <.> "haddock"
-- Library file names
mkLibName :: LibraryName -> String
mkLibName (LibraryName lib) = "lib" ++ lib <.> "a"
mkLibName lib = "lib" ++ getHSLibraryName lib <.> "a"
mkProfLibName :: LibraryName -> String
mkProfLibName (LibraryName lib) = "lib" ++ lib ++ "_p" <.> "a"
mkProfLibName lib = "lib" ++ getHSLibraryName lib ++ "_p" <.> "a"
-- Implement proper name mangling for dynamical shared objects
-- libHS<packagename>-<compilerFlavour><compilerVersion>
-- e.g. libHSbase-2.1-ghc6.6.1.so
mkSharedLibName :: CompilerId -> LibraryName -> String
mkSharedLibName (CompilerId compilerFlavor compilerVersion) (LibraryName lib)
= "lib" ++ lib ++ "-" ++ comp <.> dllExtension
mkSharedLibName (CompilerId compilerFlavor compilerVersion) lib
= "lib" ++ getHSLibraryName lib ++ "-" ++ comp <.> dllExtension
where comp = display compilerFlavor ++ display compilerVersion
-- ------------------------------------------------------------
......
......@@ -62,7 +62,7 @@ import Distribution.Package
, packageName, packageVersion, Package(..)
, Dependency(Dependency), simplifyDependency
, InstalledPackageId(..), thisPackageVersion
, mkPackageKey, PackageKey(..), packageKeyLibraryName )
, mkPackageKey, packageKeyLibraryName )
import qualified Distribution.InstalledPackageInfo as Installed
import Distribution.InstalledPackageInfo (InstalledPackageInfo, emptyInstalledPackageInfo)
import qualified Distribution.Simple.PackageIndex as PackageIndex
......@@ -94,7 +94,6 @@ import Distribution.Simple.InstallDirs
( InstallDirs(..), defaultInstallDirs, combineInstallDirs )
import Distribution.Simple.LocalBuildInfo
( LocalBuildInfo(..), Component(..), ComponentLocalBuildInfo(..)
, LibraryName(..)
, absoluteInstallDirs, prefixRelativeInstallDirs, inplacePackageId
, ComponentName(..), showComponentName, pkgEnabledComponents
, componentBuildInfo, componentName, checkComponentsCyclic )
......@@ -564,27 +563,6 @@ configure (pkg_descr0, pbi) cfg
| (name, uses) <- inconsistencies
, (pkg, ver) <- uses ]
-- Calculate the package key. We're going to store it in LocalBuildInfo
-- canonically, but ComponentsLocalBuildInfo also needs to know about it
-- XXX Do we need the internal deps?
-- NB: does *not* include holeDeps!
let pkg_key = mkPackageKey (packageKeySupported comp)
(package pkg_descr)
(map Installed.packageKey externalPkgDeps)
(map (\(k,(p,m)) -> (k,(Installed.packageKey p,m))) hole_insts)
-- internal component graph
buildComponents <-
case mkComponentsGraph pkg_descr internalPkgDeps of
Left componentCycle -> reportComponentCycle componentCycle
Right components ->
case mkComponentsLocalBuildInfo packageDependsIndex pkg_descr
internalPkgDeps externalPkgDeps holeDeps
(Map.fromList hole_insts)
pkg_key components of
Left problems -> reportModuleReexportProblems problems
Right components' -> return components'
-- installation directories
defaultDirs <- defaultInstallDirs flavor userInstall (hasLibs pkg_descr)
let installDirs = combineInstallDirs fromFlagOrDefault
......@@ -629,6 +607,16 @@ configure (pkg_descr0, pbi) cfg
(pkg_descr', programsConfig''') <-
configurePkgconfigPackages verbosity pkg_descr programsConfig''
-- internal component graph
buildComponents <-
case mkComponentsGraph pkg_descr internalPkgDeps of
Left componentCycle -> reportComponentCycle componentCycle
Right components ->
mkComponentsLocalBuildInfo comp packageDependsIndex pkg_descr
internalPkgDeps externalPkgDeps holeDeps
(Map.fromList hole_insts)
components
split_objs <-
if not (fromFlag $ configSplitObjs cfg)
then return False
......@@ -726,7 +714,6 @@ configure (pkg_descr0, pbi) cfg
installedPkgs = packageDependsIndex,
pkgDescrFile = Nothing,
localPkgDescr = pkg_descr',
pkgKey = pkg_key,
instantiatedWith = hole_insts,
withPrograms = programsConfig''',
withVanillaLib = fromFlag $ configVanillaLib cfg,
......@@ -1299,20 +1286,19 @@ reportComponentCycle cnames =
[ "'" ++ showComponentName cname ++ "'"
| cname <- cnames ++ [head cnames] ]
mkComponentsLocalBuildInfo :: InstalledPackageIndex
mkComponentsLocalBuildInfo :: Compiler
-> InstalledPackageIndex
-> PackageDescription
-> [PackageId] -- internal package deps
-> [InstalledPackageInfo] -- external package deps
-> [InstalledPackageInfo] -- hole package deps
-> Map ModuleName (InstalledPackageInfo, ModuleName)
-> PackageKey
-> [(Component, [ComponentName])]
-> Either [(ModuleReexport, String)] -- errors
[(ComponentName, ComponentLocalBuildInfo,
[ComponentName])] -- ok
mkComponentsLocalBuildInfo installedPackages pkg_descr
-> IO [(ComponentName, ComponentLocalBuildInfo,
[ComponentName])]
mkComponentsLocalBuildInfo comp installedPackages pkg_descr
internalPkgDeps externalPkgDeps holePkgDeps hole_insts
pkg_key graph =
graph =
sequence
[ do clbi <- componentLocalBuildInfo c
return (componentName c, clbi, cdeps)
......@@ -1333,12 +1319,24 @@ mkComponentsLocalBuildInfo installedPackages pkg_descr
(Installed.installedPackageId pkg) m)
(Map.lookup n hole_insts)))
(PD.exposedSignatures lib)
reexports <- resolveModuleReexports installedPackages
(packageId pkg_descr)
externalPkgDeps lib
let mb_reexports = resolveModuleReexports installedPackages
(packageId pkg_descr)
externalPkgDeps lib
reexports <- case mb_reexports of
Left problems -> reportModuleReexportProblems problems
Right r -> return r
-- Calculate the version hash and package key.
let externalPkgs = selectSubset bi externalPkgDeps
pkg_key = mkPackageKey (packageKeySupported comp)
(package pkg_descr)
(map Installed.libraryName externalPkgs)
version_hash = packageKeyLibraryName (package pkg_descr) pkg_key
return LibComponentLocalBuildInfo {
componentPackageDeps = cpds,
componentLibraries = [ LibraryName ("HS" ++ packageKeyLibraryName (package pkg_descr) pkg_key) ],
componentPackageKey = pkg_key,
componentLibraryName = version_hash,
componentPackageRenaming = cprns,
componentExposedModules = exports ++ reexports ++ esigs
}
......@@ -1366,8 +1364,6 @@ mkComponentsLocalBuildInfo installedPackages pkg_descr
| pkg <- selectSubset bi externalPkgDeps ]
++ [ (inplacePackageId pkgid, pkgid)
| pkgid <- selectSubset bi internalPkgDeps ]
++ [ (Installed.installedPackageId pkg, packageId pkg)
| pkg <- holePkgDeps ]
else [ (Installed.installedPackageId pkg, packageId pkg)
| pkg <- externalPkgDeps ]
cprns = if newPackageDepsBehaviour pkg_descr
......
......@@ -413,12 +413,8 @@ buildOrReplLib :: Bool -> Verbosity -> Cabal.Flag (Maybe Int)
-> PackageDescription -> LocalBuildInfo
-> Library -> ComponentLocalBuildInfo -> IO ()
buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
libName <- case componentLibraries clbi of
[libName] -> return libName
[] -> die "No library name found when building library"
_ -> die "Multiple library names found when building library"
let libTargetDir = buildDir lbi
let libName = componentLibraryName clbi
libTargetDir = buildDir lbi
whenVanillaLib forceVanilla =
when (forceVanilla || withVanillaLib lbi)
whenProfLib = when (withProfLib lbi)
......@@ -430,8 +426,6 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
ghcVersion = compilerVersion comp
implInfo = getImplInfo comp
(Platform _hostArch hostOS) = hostPlatform lbi
hole_insts = map (\(k,(p,n)) -> (k, (InstalledPackageInfo.packageKey p,n)))
(instantiatedWith lbi)
(ghcProg, _) <- requireProgram verbosity ghcProgram (withPrograms lbi)
let runGhcProg = runGHC verbosity ghcProg comp
......@@ -465,8 +459,6 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
vanillaOpts = baseOpts `mappend` mempty {
ghcOptMode = toFlag GhcModeMake,
ghcOptNumJobs = numJobs,
ghcOptPackageKey = toFlag (pkgKey lbi),
ghcOptSigOf = hole_insts,
ghcOptInputModules = toNubListR $ libModules lib,
ghcOptHPCDir = hpcdir Hpc.Vanilla
}
......@@ -658,7 +650,6 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
&& ghcVersion < Version [7,8] [])
then toFlag sharedLibInstallPath
else mempty,
ghcOptPackageKey = toFlag (pkgKey lbi),
ghcOptNoAutoLinkPackages = toFlag True,
ghcOptPackageDBs = withPackageDB lbi,
ghcOptPackages = toNubListR $
......@@ -969,7 +960,6 @@ libAbiHash verbosity _pkg_descr lbi lib clbi = do
(componentGhcOptions verbosity lbi libBi clbi (buildDir lbi))
`mappend` mempty {
ghcOptMode = toFlag GhcModeAbiHash,
ghcOptPackageKey = toFlag (pkgKey lbi),
ghcOptInputModules = toNubListR $ exposedModules lib
}
sharedArgs = vanillaArgs `mappend` mempty {
......@@ -1056,10 +1046,10 @@ installLib verbosity lbi targetDir dynlibTargetDir builtDir _pkg lib clbi = do
whenShared $ copyModuleFiles "dyn_hi"
-- copy the built library files over:
whenVanilla $ mapM_ (installOrdinary builtDir targetDir) vanillaLibNames
whenProf $ mapM_ (installOrdinary builtDir targetDir) profileLibNames
whenGHCi $ mapM_ (installOrdinary builtDir targetDir) ghciLibNames
whenShared $ mapM_ (installShared builtDir dynlibTargetDir) sharedLibNames
whenVanilla $ installOrdinary builtDir targetDir vanillaLibName
whenProf $ installOrdinary builtDir targetDir profileLibName
whenGHCi $ installOrdinary builtDir targetDir ghciLibName
whenShared $ installShared builtDir dynlibTargetDir sharedLibName
where
install isShared srcDir dstDir name = do
......@@ -1080,11 +1070,11 @@ installLib verbosity lbi targetDir dynlibTargetDir builtDir _pkg lib clbi = do
>>= installOrdinaryFiles verbosity targetDir
cid = compilerId (compiler lbi)
libNames = componentLibraries clbi
vanillaLibNames = map mkLibName libNames
profileLibNames = map mkProfLibName libNames
ghciLibNames = map Internal.mkGHCiLibName libNames
sharedLibNames = map (mkSharedLibName cid) libNames
libName = componentLibraryName clbi
vanillaLibName = mkLibName libName
profileLibName = mkProfLibName libName
ghciLibName = Internal.mkGHCiLibName libName
sharedLibName = (mkSharedLibName cid) libName
hasLib = not $ null (libModules lib)
&& null (cSources (libBuildInfo lib))
......
......@@ -31,7 +31,8 @@ module Distribution.Simple.GHC.Internal (
import Distribution.Simple.GHC.ImplInfo ( GhcImplInfo (..) )
import Distribution.Package
( InstalledPackageId, PackageId )
( InstalledPackageId, PackageId, LibraryName
, getHSLibraryName )
import Distribution.InstalledPackageInfo
( InstalledPackageInfo )
import qualified Distribution.InstalledPackageInfo as InstalledPackageInfo
......@@ -56,8 +57,7 @@ import Distribution.Simple.Program
, getProgramOutput )
import Distribution.Simple.Program.Types ( suppressOverrideArgs )
import Distribution.Simple.LocalBuildInfo
( LocalBuildInfo(..), ComponentLocalBuildInfo(..)
, LibraryName(..) )
( LocalBuildInfo(..), ComponentLocalBuildInfo(..) )
import Distribution.Simple.Utils
import Distribution.Simple.BuildPaths
import Distribution.System ( buildOS, OS(..), Platform, platformFromTriple )
......@@ -374,6 +374,10 @@ componentGhcOptions verbosity lbi bi clbi odir =
ghcOptVerbosity = toFlag verbosity,
ghcOptHideAllPackages = toFlag True,
ghcOptCabal = toFlag True,