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

Pass -this-component-id to GHC when necessary.



Previously GHC inferred it off of -this-unit-id but we've
modified things so that GHC makes no assumptions about the
format of instantiated unit ids. In that case, pass it in
explicitly!
Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
parent 6dea5762
......@@ -736,6 +736,13 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
LibComponentLocalBuildInfo { componentCompatPackageKey = pk }
-> toFlag pk
_ -> mempty,
ghcOptThisComponentId = case clbi of
LibComponentLocalBuildInfo { componentUnitId = lib_uid
, componentInstantiatedWith = insts } ->
if null insts
then mempty
else toFlag (unitIdComponentId lib_uid)
_ -> mempty,
ghcOptInstantiatedWith = case clbi of
LibComponentLocalBuildInfo { componentInstantiatedWith = insts }
-> insts
......
......@@ -289,6 +289,13 @@ componentGhcOptions verbosity lbi bi clbi odir =
LibComponentLocalBuildInfo { componentCompatPackageKey = pk }
-> toFlag pk
_ -> mempty,
ghcOptThisComponentId = case clbi of
LibComponentLocalBuildInfo { componentUnitId = uid
, componentInstantiatedWith = insts } ->
if null insts
then mempty
else toFlag (unitIdComponentId uid)
_ -> mempty,
ghcOptInstantiatedWith = case clbi of
LibComponentLocalBuildInfo { componentInstantiatedWith = insts }
-> insts
......
......@@ -19,6 +19,7 @@ module Distribution.Simple.Program.GHC (
import Prelude ()
import Distribution.Compat.Prelude
import Distribution.Package
import Distribution.Backpack
import Distribution.Simple.GHC.ImplInfo
import Distribution.PackageDescription hiding (Flag)
......@@ -83,6 +84,12 @@ data GhcOptions = GhcOptions {
-- (we need to handle backwards compatibility.)
ghcOptThisUnitId :: Flag String,
-- | GHC doesn't make any assumptions about the format of
-- definite unit ids, so when we are instantiating a package it
-- needs to be told explicitly what the component being instantiated
-- is. This only gets set when 'ghcOptInstantiatedWith' is non-empty
ghcOptThisComponentId :: Flag ComponentId,
ghcOptInstantiatedWith :: [(ModuleName, OpenModule)],
-- | No code? (But we turn on interface writing
......@@ -403,6 +410,9 @@ renderGhcOptions comp _platform@(Platform _arch os) opts
, this_arg ]
| this_arg <- flag ghcOptThisUnitId ]
, concat [ ["-this-component-id", display this_cid ]
| this_cid <- flag ghcOptThisComponentId ]
, if null (ghcOptInstantiatedWith opts)
then []
else "-instantiated-with"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment