diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2021-06-21 16:00:40 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-06-25 15:41:58 -0400 |
commit | 6cc8076684db27e9bb3e320421e844a7cbcb2545 (patch) | |
tree | a7c0585e9e235bcc4f63c4b8a19520ffd21fc011 /compiler/GHC/Unit | |
parent | 0bb78838e213467b9b5bd2b38767b39b46a294c5 (diff) | |
download | haskell-6cc8076684db27e9bb3e320421e844a7cbcb2545.tar.gz |
driver: Add implicit package dependencies for template-haskell package
When TemplateHaskellQuotes is enabled, we also generate programs which
mention symbols from the template-haskell module. So that package is
added conditionally if the extension is turned on.
We should really do the same for other wired-in packages:
* base
* ghc-bignum
* ghc-prim
* rts
When we link an executable, we must also link against these
libraries. In accordance with every other package, these dependencies
should be added into the direct dependencies for a module automatically
and end up in the interface file to record the fact the object file was
created by linking against these packages.
Unfortunately it is not so easy to work out when symbols from each of
these libraries ends up in the generated program. You might think that
`base` would always be used but the `ghc-prim` package doesn't depend
on `base`, so you have to be a bit careful and this futher enhancement
is left to a future patch.
Diffstat (limited to 'compiler/GHC/Unit')
-rw-r--r-- | compiler/GHC/Unit/State.hs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/compiler/GHC/Unit/State.hs b/compiler/GHC/Unit/State.hs index f3fb9d7645..32e35161b2 100644 --- a/compiler/GHC/Unit/State.hs +++ b/compiler/GHC/Unit/State.hs @@ -65,8 +65,8 @@ module GHC.Unit.State ( pprWithUnitState, -- * Utils - unwireUnit - ) + unwireUnit, + implicitPackageDeps) where import GHC.Prelude @@ -113,6 +113,7 @@ import qualified Data.Semigroup as Semigroup import qualified Data.Map as Map import qualified Data.Map.Strict as MapStrict import qualified Data.Set as Set +import GHC.LanguageExtensions -- --------------------------------------------------------------------------- -- The Unit state @@ -2153,3 +2154,11 @@ pprWithUnitState :: UnitState -> SDoc -> SDoc pprWithUnitState state = updSDocContext (\ctx -> ctx { sdocUnitIdForUser = \fs -> pprUnitIdForUser state (UnitId fs) }) + +-- | Add package dependencies on the wired-in packages we use +implicitPackageDeps :: DynFlags -> [UnitId] +implicitPackageDeps dflags + = [thUnitId | xopt TemplateHaskellQuotes dflags] + -- TODO: Should also include `base` and `ghc-prim` if we use those implicitly, but + -- it is possible to not depend on base (for example, see `ghc-prim`) + |