Commit 240ddd7c authored by Edward Z. Yang's avatar Edward Z. Yang Committed by Ben Gamari

Switch from -this-package-key to -this-unit-id.

A small cosmetic change, but we have to do a bit of work to
actually support it:

    - Cabal submodule update, so that Cabal passes us
      -this-unit-id when we ask for it.  This includes
      a Cabal renaming to be consistent with Unit ID, which
      makes ghc-pkg a bit more scrutable.

    - Build system is updated to use -this-unit-id rather than
      -this-package-key, to avoid deprecation warnings.  Needs
      a version test so I resurrected the old test we had
      (sorry rwbarton!)

    - I've *undeprecated* -package-name, so that we are in the same
      state as GHC 7.10, since the "correct" flag will have only
      entered circulation in GHC 8.0.

    - I removed -package-key.  Since we didn't deprecate -package-id
      I think this should not cause any problems for users; they
      can just change their code to use -package-id.

    - The package database is indexed by UNIT IDs, not component IDs.
      I updated the naming here.

    - I dropped the signatures field from ExposedModule; nothing
      was using it, and instantiatedWith from the package database
      field.

    - ghc-pkg was updated to use unit ID nomenclature, I removed
      the -package-key flags but I decided not to add any new flags
      for now.
Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>

Test Plan: validate

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: 23Skidoo, thomie, erikd

Differential Revision: https://phabricator.haskell.org/D1780
parent b8abd852
......@@ -104,12 +104,15 @@ Library
Include-Dirs: . parser utils
if impl( ghc >= 7.9 )
-- We need to set the unit id to ghc (without a version number)
-- as it's magic. But we can't set it for old versions of GHC (e.g.
-- when bootstrapping) because those versions of GHC don't understand
-- that GHC is wired-in.
GHC-Options: -this-package-key ghc
-- We need to set the unit id to ghc (without a version number)
-- as it's magic. But we can't set it for old versions of GHC (e.g.
-- when bootstrapping) because those versions of GHC don't understand
-- that GHC is wired-in.
if impl ( ghc >= 7.11 )
GHC-Options: -this-unit-id ghc
else
if impl( ghc >= 7.9 )
GHC-Options: -this-package-key ghc
if flag(stage1)
Include-Dirs: stage1
......
......@@ -1133,8 +1133,7 @@ isNoLink _ = False
-- is used.
data PackageArg =
PackageArg String -- ^ @-package@, by 'PackageName'
| PackageIdArg String -- ^ @-package-id@, by 'SourcePackageId'
| UnitIdArg String -- ^ @-package-key@, by 'ComponentId'
| UnitIdArg String -- ^ @-package-id@, by 'UnitId'
deriving (Eq, Show)
-- | Represents the renaming that may be associated with an exposed
......@@ -1167,7 +1166,6 @@ data TrustFlag
-- | Flags for manipulating packages visibility.
data PackageFlag
= ExposePackage String PackageArg ModRenaming -- ^ @-package@, @-package-id@
-- and @-package-key@
| HidePackage String -- ^ @-hide-package@
deriving (Eq)
-- NB: equality instance is used by InteractiveUI to test if
......@@ -2774,15 +2772,21 @@ package_flags = [
(NoArg $ do removeUserPkgConf
deprecate "Use -no-user-package-db instead")
, defGhcFlag "package-name" (HasArg $ \name -> do
, defGhcFlag "package-name" (HasArg $ \name -> do
upd (setUnitId name))
-- TODO: Since we JUST deprecated
-- -this-package-key, let's keep this
-- undeprecated for another cycle.
-- Deprecate this eventually.
-- deprecate "Use -this-unit-id instead")
, defGhcFlag "this-package-key" (HasArg $ \name -> do
upd (setUnitId name)
deprecate "Use -this-package-key instead")
, defGhcFlag "this-package-key" (hasArg setUnitId)
, defFlag "package-id" (HasArg exposePackageId)
deprecate "Use -this-unit-id instead")
, defGhcFlag "this-unit-id" (hasArg setUnitId)
, defFlag "package" (HasArg exposePackage)
, defFlag "plugin-package-id" (HasArg exposePluginPackageId)
, defFlag "plugin-package" (HasArg exposePluginPackage)
, defFlag "package-key" (HasArg exposeUnitId)
, defFlag "package-id" (HasArg exposePackageId)
, defFlag "hide-package" (HasArg hidePackage)
, defFlag "hide-all-packages" (NoArg (setGeneralFlag Opt_HideAllPackages))
, defFlag "hide-all-plugin-packages" (NoArg (setGeneralFlag Opt_HideAllPluginPackages))
......@@ -3860,23 +3864,20 @@ parsePackageFlag flag constr str
return (orig, orig))
tok m = m >>= \x -> skipSpaces >> return x
exposePackage, exposePackageId, exposeUnitId, hidePackage,
exposePackage, exposePackageId, hidePackage,
exposePluginPackage, exposePluginPackageId,
ignorePackage,
trustPackage, distrustPackage :: String -> DynP ()
exposePackage p = upd (exposePackage' p)
exposePackageId p =
upd (\s -> s{ packageFlags =
parsePackageFlag "-package-id" PackageIdArg p : packageFlags s })
parsePackageFlag "-package-id" UnitIdArg p : packageFlags s })
exposePluginPackage p =
upd (\s -> s{ pluginPackageFlags =
parsePackageFlag "-plugin-package" PackageArg p : pluginPackageFlags s })
exposePluginPackageId p =
upd (\s -> s{ pluginPackageFlags =
parsePackageFlag "-plugin-package-id" PackageIdArg p : pluginPackageFlags s })
exposeUnitId p =
upd (\s -> s{ packageFlags =
parsePackageFlag "-package-key" UnitIdArg p : packageFlags s })
parsePackageFlag "-plugin-package-id" UnitIdArg p : pluginPackageFlags s })
hidePackage p =
upd (\s -> s{ packageFlags = HidePackage p : packageFlags s })
ignorePackage p =
......@@ -4285,18 +4286,34 @@ compilerInfo dflags
("Tables next to code", cGhcEnableTablesNextToCode),
("RTS ways", cGhcRTSWays),
("RTS expects libdw", showBool cGhcRtsWithLibdw),
-- Whether or not we support @-dynamic-too@
("Support dynamic-too", showBool $ not isWindows),
-- Whether or not we support the @-j@ flag with @--make@.
("Support parallel --make", "YES"),
-- Whether or not we support "Foo from foo-0.1-XXX:Foo" syntax in
-- installed package info.
("Support reexported-modules", "YES"),
-- Whether or not we support extended @-package foo (Foo)@ syntax.
("Support thinning and renaming package flags", "YES"),
-- If true, we require that the 'id' field in installed package info
-- match what is passed to the @-this-unit-id@ flag for modules
-- built in it
("Requires unified installed package IDs", "YES"),
-- Whether or not we support the @-this-package-key@ flag. Prefer
-- "Uses unit IDs" over it.
("Uses package keys", "YES"),
-- Whether or not we support the @-this-unit-id@ flag
("Uses unit IDs", "YES"),
-- Whether or not GHC compiles libraries as dynamic by default
("Dynamic by default", showBool $ dYNAMIC_BY_DEFAULT dflags),
-- Whether or not GHC was compiled using -dynamic
("GHC Dynamic", showBool dynamicGhc),
-- Whether or not GHC was compiled using -prof
("GHC Profiled", showBool rtsIsProfiled),
("Leading underscore", cLeadingUnderscore),
("Debug on", show debugIsOn),
("LibDir", topDir dflags),
-- The path of the global package database used by GHC
("Global Package DB", systemPackageConfig dflags)
]
where
......
......@@ -1229,7 +1229,7 @@ The details are a bit tricky though:
extend the HPT.
* The 'thisPackage' field of DynFlags is *not* set to 'interactive'.
It stays as 'main' (or whatever -this-package-key says), and is the
It stays as 'main' (or whatever -this-unit-id says), and is the
package to which :load'ed modules are added to.
* So how do we arrange that declarations at the command prompt get to
......@@ -1238,7 +1238,7 @@ The details are a bit tricky though:
call to initTc in initTcInteractive, which in turn get the module
from it 'icInteractiveModule' field of the interactive context.
The 'thisPackage' field stays as 'main' (or whatever -this-package-key says.
The 'thisPackage' field stays as 'main' (or whatever -this-unit-id says.
* The main trickiness is that the type environment (tcg_type_env) and
fixity envt (tcg_fix_env), now contain entities from all the
......
......@@ -20,7 +20,6 @@ module PackageConfig (
PackageName(..),
Version(..),
defaultPackageConfig,
componentIdString,
sourcePackageIdString,
packageNameString,
pprPackageConfig,
......@@ -41,7 +40,6 @@ import Unique
-- which is similar to a subset of the InstalledPackageInfo type from Cabal.
type PackageConfig = InstalledPackageInfo
ComponentId
SourcePackageId
PackageName
Module.UnitId
......@@ -88,14 +86,11 @@ instance Outputable PackageName where
-- | Pretty-print an 'ExposedModule' in the same format used by the textual
-- installed package database.
pprExposedModule :: (Outputable a, Outputable b) => ExposedModule a b -> SDoc
pprExposedModule (ExposedModule exposedName exposedReexport exposedSignature) =
pprExposedModule (ExposedModule exposedName exposedReexport) =
sep [ ppr exposedName
, case exposedReexport of
Just m -> sep [text "from", pprOriginalModule m]
Nothing -> empty
, case exposedSignature of
Just m -> sep [text "is", pprOriginalModule m]
Nothing -> empty
]
-- | Pretty-print an 'OriginalModule' in the same format used by the textual
......@@ -107,11 +102,6 @@ pprOriginalModule (OriginalModule originalPackageId originalModuleName) =
defaultPackageConfig :: PackageConfig
defaultPackageConfig = emptyInstalledPackageInfo
componentIdString :: PackageConfig -> String
componentIdString pkg = unpackFS str
where
ComponentId str = componentId pkg
sourcePackageIdString :: PackageConfig -> String
sourcePackageIdString pkg = unpackFS str
where
......@@ -127,7 +117,7 @@ pprPackageConfig InstalledPackageInfo {..} =
vcat [
field "name" (ppr packageName),
field "version" (text (showVersion packageVersion)),
field "id" (ppr componentId),
field "id" (ppr unitId),
field "exposed" (ppr exposed),
field "exposed-modules"
(if all isExposedModule exposedModules
......@@ -152,7 +142,7 @@ pprPackageConfig InstalledPackageInfo {..} =
]
where
field name body = text name <> colon <+> nest 4 body
isExposedModule (ExposedModule _ Nothing Nothing) = True
isExposedModule (ExposedModule _ Nothing) = True
isExposedModule _ = False
......@@ -163,7 +153,7 @@ pprPackageConfig InstalledPackageInfo {..} =
-- #package_naming#
-- Mostly the compiler deals in terms of 'UnitId's, which are md5 hashes
-- of a package ID, keys of its dependencies, and Cabal flags. You're expected
-- to pass in the unit id in the @-this-package-key@ flag. However, for
-- to pass in the unit id in the @-this-unit-id@ flag. However, for
-- wired-in packages like @base@ & @rts@, we don't necessarily know what the
-- version is, so these are handled specially; see #wired_in_packages#.
......
......@@ -602,15 +602,11 @@ matchingStr str p
|| str == packageNameString p
matchingId :: String -> PackageConfig -> Bool
matchingId str p = str == componentIdString p
matchingKey :: String -> PackageConfig -> Bool
matchingKey str p = str == unitIdString (packageConfigId p)
matchingId str p = str == unitIdString (packageConfigId p)
matching :: PackageArg -> PackageConfig -> Bool
matching (PackageArg str) = matchingStr str
matching (PackageIdArg str) = matchingId str
matching (UnitIdArg str) = matchingKey str
matching (UnitIdArg str) = matchingId str
sortByVersion :: [PackageConfig] -> [PackageConfig]
sortByVersion = sortBy (flip (comparing packageVersion))
......@@ -1159,8 +1155,7 @@ mkModuleToPkgConfAll dflags pkg_db vis_map =
es :: Bool -> [(ModuleName, Map Module ModuleOrigin)]
es e = do
-- TODO: signature support
ExposedModule m exposedReexport _exposedSignature <- exposed_mods
ExposedModule m exposedReexport <- exposed_mods
let (pk', m', pkg', origin') =
case exposedReexport of
Nothing -> (pk, m, pkg, fromExposedModules e)
......
......@@ -153,6 +153,11 @@ fi
GHC_PACKAGE_DB_FLAG=package-db
AC_SUBST(GHC_PACKAGE_DB_FLAG)
FP_COMPARE_VERSIONS([$GhcVersion],[-lt],[7.11],
SUPPORTS_THIS_UNIT_ID=NO,
SUPPORTS_THIS_UNIT_ID=YES)
AC_SUBST(SUPPORTS_THIS_UNIT_ID)
# GHC is passed to Cabal, so we need a native path
if test "${WithGhc}" != ""
then
......
......@@ -274,6 +274,14 @@ Compiler
expressivity may come with a high price in terms of compilation time and
memory consumption, it is turned off by default.
- :ghc-flag:`-this-package-key` has been renamed again (hopefully for the last time!)
to :ghc-flag:`-this-unit-id`. The renaming was motivated by the fact that
the identifier you pass to GHC here doesn't have much to do with packages:
you may provide different unit IDs for libraries which are in the same
package. :ghc-flag:`-this-package-key` is deprecated; you should use
:ghc-flag:`-this-unit-id` or, if you need compatibility over multiple
versions of GHC, :ghc-flag:`-package-name`.
GHCi
~~~~
......
......@@ -161,10 +161,12 @@ The GHC command line options that control packages are:
$ ghc -o myprog Foo.hs Main.hs -package network
.. ghc-flag:: -package-id ⟨pkg-id⟩
.. ghc-flag:: -package-id ⟨unit-id⟩
Exposes a package like :ghc-flag:`-package`, but the package is named by its
installed package ID rather than by name. This is a more robust way
unit ID (i.e. the value of ``id`` in its entry in the installed
package database, also previously known as an installed package ID)
rather than by name. This is a more robust way
to name packages, and can be used to select packages that would
otherwise be shadowed. Cabal passes ``-package-id`` flags to GHC.
``-package-id`` supports thinning and renaming described in
......@@ -208,11 +210,14 @@ The GHC command line options that control packages are:
By default, GHC will automatically link in the ``base`` and ``rts``
packages. This flag disables that behaviour.
.. ghc-flag:: -this-package-key pkg-key
.. ghc-flag:: -this-unit-id unit-id
Tells GHC the the module being compiled forms part of unit ID
pkg-key; internally, these keys are used to determine type equality
and linker symbols.
unit-id; internally, these keys are used to determine type equality
and linker symbols. As of GHC 8.0, unit IDs must consist solely
of alphanumeric characters, dashes, underscores and periods. GHC
reserves the right to interpret other characters in a special
way in later releases.
.. ghc-flag:: -library-name hash
......@@ -255,7 +260,7 @@ The ``main`` package
--------------------
Every complete Haskell program must define ``main`` in module ``Main``
in package ``main``. Omitting the :ghc-flag:`-this-package-key` flag compiles
in package ``main``. Omitting the :ghc-flag:`-this-unit-id` flag compiles
code for package ``main``. Failure to do so leads to a somewhat obscure
link-time error of the form:
......
Subproject commit a8a121ea4d78783dd303dd2992d8e73ef337e7ed
Subproject commit ecdf65a3c1e01b798e9d073258a6d1c8ff63a6d8
......@@ -362,4 +362,4 @@ Library
-- We need to set the unit id to base (without a version number)
-- as it's magic.
ghc-options: -this-package-key base
ghc-options: -this-unit-id base
......@@ -64,15 +64,14 @@ import System.Directory
-- | This is a subset of Cabal's 'InstalledPackageInfo', with just the bits
-- that GHC is interested in.
--
data InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename
data InstalledPackageInfo srcpkgid srcpkgname unitid modulename
= InstalledPackageInfo {
componentId :: instpkgid,
unitId :: unitid,
sourcePackageId :: srcpkgid,
packageName :: srcpkgname,
packageVersion :: Version,
unitId :: pkgkey,
abiHash :: String,
depends :: [pkgkey],
depends :: [unitid],
importDirs :: [FilePath],
hsLibraries :: [String],
extraLibraries :: [String],
......@@ -86,9 +85,8 @@ data InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename
includeDirs :: [FilePath],
haddockInterfaces :: [FilePath],
haddockHTMLs :: [FilePath],
exposedModules :: [ExposedModule pkgkey modulename],
exposedModules :: [ExposedModule unitid modulename],
hiddenModules :: [modulename],
instantiatedWith :: [(modulename,OriginalModule pkgkey modulename)],
exposed :: Bool,
trusted :: Bool
}
......@@ -98,40 +96,30 @@ data InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename
-- plus module name) representing where a module was *originally* defined
-- (i.e., the 'exposedReexport' field of the original ExposedModule entry should
-- be 'Nothing'). Invariant: an OriginalModule never points to a reexport.
data OriginalModule pkgkey modulename
data OriginalModule unitid modulename
= OriginalModule {
originalPackageId :: pkgkey,
originalPackageId :: unitid,
originalModuleName :: modulename
}
deriving (Eq, Show)
-- | Represents a module name which is exported by a package, stored in the
-- 'exposedModules' field. A module export may be a reexport (in which
-- case 'exposedReexport' is filled in with the original source of the module),
-- and may be a signature (in which case 'exposedSignature is filled in with
-- what the signature was compiled against). Thus:
-- 'exposedModules' field. A module export may be a reexport (in which case
-- 'exposedReexport' is filled in with the original source of the module).
-- Thus:
--
-- * @ExposedModule n Nothing Nothing@ represents an exposed module @n@ which
-- * @ExposedModule n Nothing@ represents an exposed module @n@ which
-- was defined in this package.
--
-- * @ExposedModule n (Just o) Nothing@ represents a reexported module @n@
-- * @ExposedModule n (Just o)@ represents a reexported module @n@
-- which was originally defined in @o@.
--
-- * @ExposedModule n Nothing (Just s)@ represents an exposed signature @n@
-- which was compiled against the implementation @s@.
--
-- * @ExposedModule n (Just o) (Just s)@ represents a reexported signature
-- which was originally defined in @o@ and was compiled against the
-- implementation @s@.
--
-- We use two 'Maybe' data types instead of an ADT with four branches or
-- four fields because this representation allows us to treat
-- reexports/signatures uniformly.
data ExposedModule pkgkey modulename
-- We use a 'Maybe' data types instead of an ADT with two branches because this
-- representation allows us to treat reexports uniformly.
data ExposedModule unitid modulename
= ExposedModule {
exposedName :: modulename,
exposedReexport :: Maybe (OriginalModule pkgkey modulename),
exposedSignature :: Maybe (OriginalModule pkgkey modulename)
exposedReexport :: Maybe (OriginalModule unitid modulename)
}
deriving (Eq, Show)
......@@ -140,15 +128,14 @@ class BinaryStringRep a where
toStringRep :: a -> BS.ByteString
emptyInstalledPackageInfo :: (BinaryStringRep a, BinaryStringRep b,
BinaryStringRep c, BinaryStringRep d)
=> InstalledPackageInfo a b c d e
BinaryStringRep c)
=> InstalledPackageInfo a b c d
emptyInstalledPackageInfo =
InstalledPackageInfo {
componentId = fromStringRep BS.empty,
unitId = fromStringRep BS.empty,
sourcePackageId = fromStringRep BS.empty,
packageName = fromStringRep BS.empty,
packageVersion = Version [] [],
unitId = fromStringRep BS.empty,
abiHash = "",
depends = [],
importDirs = [],
......@@ -166,7 +153,6 @@ emptyInstalledPackageInfo =
haddockHTMLs = [],
exposedModules = [],
hiddenModules = [],
instantiatedWith = [],
exposed = False,
trusted = False
}
......@@ -174,8 +160,8 @@ emptyInstalledPackageInfo =
-- | Read the part of the package DB that GHC is interested in.
--
readPackageDbForGhc :: (BinaryStringRep a, BinaryStringRep b, BinaryStringRep c,
BinaryStringRep d, BinaryStringRep e) =>
FilePath -> IO [InstalledPackageInfo a b c d e]
BinaryStringRep d) =>
FilePath -> IO [InstalledPackageInfo a b c d]
readPackageDbForGhc file =
decodeFromFile file getDbForGhc
where
......@@ -208,8 +194,8 @@ readPackageDbForGhcPkg file =
-- | Write the whole of the package DB, both parts.
--
writePackageDb :: (Binary pkgs, BinaryStringRep a, BinaryStringRep b,
BinaryStringRep c, BinaryStringRep d, BinaryStringRep e) =>
FilePath -> [InstalledPackageInfo a b c d e] -> pkgs -> IO ()
BinaryStringRep c, BinaryStringRep d) =>
FilePath -> [InstalledPackageInfo a b c d] -> pkgs -> IO ()
writePackageDb file ghcPkgs ghcPkgPart =
writeFileAtomic file (runPut putDbForGhcPkg)
where
......@@ -296,20 +282,19 @@ writeFileAtomic targetPath content = do
renameFile tmpPath targetPath)
instance (BinaryStringRep a, BinaryStringRep b, BinaryStringRep c,
BinaryStringRep d, BinaryStringRep e) =>
Binary (InstalledPackageInfo a b c d e) where
BinaryStringRep d) =>
Binary (InstalledPackageInfo a b c d) where
put (InstalledPackageInfo
componentId sourcePackageId
packageName packageVersion unitId
unitId sourcePackageId
packageName packageVersion
abiHash depends importDirs
hsLibraries extraLibraries extraGHCiLibraries libraryDirs
frameworks frameworkDirs
ldOptions ccOptions
includes includeDirs
haddockInterfaces haddockHTMLs
exposedModules hiddenModules instantiatedWith
exposedModules hiddenModules
exposed trusted) = do
put (toStringRep componentId)
put (toStringRep sourcePackageId)
put (toStringRep packageName)
put packageVersion
......@@ -331,12 +316,10 @@ instance (BinaryStringRep a, BinaryStringRep b, BinaryStringRep c,
put haddockHTMLs
put exposedModules
put (map toStringRep hiddenModules)
put (map (\(k,v) -> (toStringRep k, v)) instantiatedWith)
put exposed
put trusted
get = do
componentId <- get
sourcePackageId <- get
packageName <- get
packageVersion <- get
......@@ -358,14 +341,12 @@ instance (BinaryStringRep a, BinaryStringRep b, BinaryStringRep c,
haddockHTMLs <- get
exposedModules <- get
hiddenModules <- get
instantiatedWith <- get
exposed <- get
trusted <- get
return (InstalledPackageInfo
(fromStringRep componentId)
(fromStringRep unitId)
(fromStringRep sourcePackageId)
(fromStringRep packageName) packageVersion
(fromStringRep unitId)
abiHash
(map fromStringRep depends)
importDirs
......@@ -376,7 +357,6 @@ instance (BinaryStringRep a, BinaryStringRep b, BinaryStringRep c,
haddockInterfaces haddockHTMLs
exposedModules
(map fromStringRep hiddenModules)
(map (\(k,v) -> (fromStringRep k, v)) instantiatedWith)
exposed trusted)
instance (BinaryStringRep a, BinaryStringRep b) =>
......@@ -392,14 +372,11 @@ instance (BinaryStringRep a, BinaryStringRep b) =>
instance (BinaryStringRep a, BinaryStringRep b) =>
Binary (ExposedModule a b) where
put (ExposedModule exposedName exposedReexport exposedSignature) = do
put (ExposedModule exposedName exposedReexport) = do
put (toStringRep exposedName)
put exposedReexport
put exposedSignature
get = do
exposedName <- get
exposedReexport <- get
exposedSignature <- get
return (ExposedModule (fromStringRep exposedName)
exposedReexport
exposedSignature)
exposedReexport)
......@@ -68,4 +68,4 @@ Library
-- We need to set the unit ID to ghc-prim (without a version number)
-- as it's magic.
ghc-options: -this-package-key ghc-prim
ghc-options: -this-unit-id ghc-prim
......@@ -48,7 +48,7 @@ library
UnliftedFFITypes
build-depends: ghc-prim
hs-source-dirs: src/
ghc-options: -this-package-key integer-gmp -Wall
ghc-options: -this-unit-id integer-gmp -Wall
cc-options: -std=c99 -Wall
include-dirs: include
......
......@@ -26,6 +26,6 @@ Library
other-modules: GHC.Integer.Type
default-extensions: CPP, MagicHash, BangPatterns, UnboxedTuples,
UnliftedFFITypes, NoImplicitPrelude
-- We need to set the package name to integer-simple
-- We need to set the unit ID to integer-simple
-- (without a version number) as it's magic.
ghc-options: -this-package-key integer-simple -Wall
ghc-options: -this-unit-id integer-simple -Wall
......@@ -55,7 +55,10 @@ Library
-- version number) as it's magic.
ghc-options: -Wall
if impl( ghc >= 7.9 )
ghc-options: -this-package-key template-haskell
if impl( ghc >= 7.11 )
ghc-options: -this-unit-id template-haskell
else
ghc-options: -package-name template-haskell
if impl( ghc >= 7.9 )
ghc-options: -this-package-key template-haskell
else
ghc-options: -package-name template-haskell
......@@ -498,6 +498,8 @@ endif
GHC_PACKAGE_DB_FLAG = @GHC_PACKAGE_DB_FLAG@
SUPPORTS_THIS_UNIT_ID = @SUPPORTS_THIS_UNIT_ID@
#-----------------------------------------------------------------------------
# C compiler
#
......
......@@ -206,7 +206,7 @@ ifneq "$$(findstring dyn, $1)" ""
ifeq "$$(HostOS_CPP)" "mingw32"
$$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) rts/dist/libs.depend rts/dist/build/$$(LIBFFI_DLL)
"$$(RM)" $$(RM_OPTS) $$@
"$$(rts_dist_HC)" -this-package-key rts -shared -dynamic -dynload deploy \
"$$(rts_dist_HC)" -this-unit-id rts -shared -dynamic -dynload deploy \
-no-auto-link-packages -Lrts/dist/build -l$$(LIBFFI_NAME) \
`cat rts/dist/libs.depend` $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) \
$$(rts_dist_$1_GHC_LD_OPTS) \
......@@ -227,7 +227,7 @@ LIBFFI_LIBS =
endif
$$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) rts/dist/libs.depend $$(rts_dist_FFI_SO)
"$$(RM)" $$(RM_OPTS) $$@
"$$(rts_dist_HC)" -this-package-key rts -shared -dynamic -dynload deploy \
"$$(rts_dist_HC)" -this-unit-id rts -shared -dynamic -dynload deploy \
-no-auto-link-packages $$(LIBFFI_LIBS) `cat rts/dist/libs.depend` $$(rts_$1_OBJS) \
$$(rts_dist_$1_GHC_LD_OPTS) \
$$(rts_$1_DTRACE_OBJS) -o $$@
......@@ -301,7 +301,7 @@ STANDARD_OPTS += -DCOMPILING_RTS
rts_CC_OPTS += $(WARNING_OPTS)
rts_CC_OPTS += $(STANDARD_OPTS)
rts_HC_OPTS += $(STANDARD_OPTS) -this-package-key rts
rts_HC_OPTS += $(STANDARD_OPTS) -this-unit-id rts
ifneq "$(GhcWithSMP)" "YES"
rts_CC_OPTS += -DNOSMP
......
......@@ -96,9 +96,21 @@ define distdir-way-opts # args: $1 = dir, $2 = distdir, $3 = way, $4 = stage
# $1_$2_$3_MOST_HC_OPTS is also passed to C compilations when we use
# GHC as the C compiler.
ifeq "$(SUPPORTS_THIS_UNIT_ID)" "NO"
ifeq "$4" "0"
$4_USE_THIS_UNIT_ID=NO
endif
endif
$1_$2_$4_DEP_OPTS = \
$$(foreach pkg,$$($1_$2_DEP_IPIDS),-package-id $$(pkg))
ifeq "$($4_USE_THIS_UNIT_ID)" "NO"
$4_THIS_UNIT_ID = -this-package-key
else
$4_THIS_UNIT_ID = -this-unit-id
endif
$1_$2_$3_MOST_HC_OPTS = \
$$(WAY_$3_HC_OPTS) \
$$(CONF_HC_OPTS) \
......@@ -107,7 +119,7 @@ $1_$2_$3_MOST_HC_OPTS = \
$$($1_HC_OPTS) \
$$($1_$2_HC_PKGCONF) \
$$(if $$($1_$2_PROG),, \
$$(if $$($1_PACKAGE),-this-package-key $$($1_$2_COMPONENT_ID))) \
$$(if $$($1_PACKAGE),$$($4_THIS_UNIT_ID) $$($1_$2_COMPONENT_ID))) \
$$(if $$($1_PACKAGE),-hide-all-packages) \
-i $$(if $$($1_$2_HS_SRC_DIRS),$$(foreach dir,$$($1_$2_HS_SRC_DIRS),-i$1/$$(dir)),-i$1) \
-i$1/$2/build -i$1/$2/build/autogen \
......