import Class ( Class, classSelIds, classTyCon )
import TyCon ( TyCon, tyConSelIds, tyConDataCons )
import DataCon ( dataConImplicitIds )
-import Packages ( PackageIdH, PackageId, PackageConfig )
+import Packages ( PackageIdH, PackageId, PackageConfig, HomeModules )
import DynFlags ( DynFlags(..), isOneShot )
import DriverPhases ( HscSource(..), isHsBoot, hscSourceString, Phase )
import BasicTypes ( Version, initialVersion, IPName,
import CoreSyn ( CoreRule )
import Maybes ( orElse, fromJust, expectJust )
import Outputable
-import SrcLoc ( SrcSpan )
+import SrcLoc ( SrcSpan, Located )
import UniqSupply ( UniqSupply )
import FastString ( FastString )
-- the old linkable because it was out of date.
-- after a complete compilation (GHC.load), all hm_linkable
-- fields in the HPT will be Just.
+ --
+ -- When re-linking a module (hscNoRecomp), we construct
+ -- the HomModInfo by building a new ModDetails from the
+ -- old ModIface (only).
\end{code}
Simple lookups in the symbol table.
-- (We need the source file to figure out the
-- top-level environment, if we didn't compile this module
-- from source then this field contains Nothing).
+ --
+ -- Strictly speaking this field should live in the
+ -- HomeModInfo, but that leads to more plumbing.
-- Instance declarations and rules
mi_insts :: [IfaceInst], -- Sorted
mg_boot :: IsBootInterface, -- Whether it's an hs-boot module
mg_exports :: !NameSet, -- What it exports
mg_deps :: !Dependencies, -- What is below it, directly or otherwise
+ mg_home_mods :: !HomeModules, -- For calling isHomeModule etc.
mg_dir_imps :: ![Module], -- Directly-imported modules; used to
-- generate initialisation code
mg_usages :: ![Usage], -- Version info for what it needed
= CgGuts {
cg_module :: !Module,
- cg_tycons :: [TyCon], -- Algebraic data types (including ones that started life
- -- as classes); generate constructors and info tables
- -- Includes newtypes, just for the benefit of External Core
+ cg_tycons :: [TyCon],
+ -- Algebraic data types (including ones that started
+ -- life as classes); generate constructors and info
+ -- tables Includes newtypes, just for the benefit of
+ -- External Core
- cg_binds :: [CoreBind], -- The tidied main bindings, including previously-implicit
- -- bindings for record and class selectors, and
- -- data construtor wrappers.
- -- But *not* data constructor workers; reason: we
- -- we regard them as part of the code-gen of tycons
+ cg_binds :: [CoreBind],
+ -- The tidied main bindings, including
+ -- previously-implicit bindings for record and class
+ -- selectors, and data construtor wrappers. But *not*
+ -- data constructor workers; reason: we we regard them
+ -- as part of the code-gen of tycons
- cg_dir_imps :: ![Module], -- Directly-imported modules; used to generate
- -- initialisation code
+ cg_dir_imps :: ![Module],
+ -- Directly-imported modules; used to generate
+ -- initialisation code
cg_foreign :: !ForeignStubs,
+ cg_home_mods :: !HomeModules, -- for calling isHomeModule etc.
cg_dep_pkgs :: ![PackageId] -- Used to generate #includes for C code gen
}
-- time round, but if someone has added a new rule you might need it this time
-- The export list field is (Just v) if we depend on the export list:
- -- i.e. we imported the module without saying exactly what we imported
- -- We need to recompile if the module exports changes, because we might
- -- now have a name clash in the importing module.
+ -- i.e. we imported the module directly, whether or not we
+ -- enumerated the things we imported, or just imported everything
+ -- We need to recompile if M's exports change, because
+ -- if the import was import M, we might now have a name clash in the
+ -- importing module.
+ -- if the import was import M(x) M might no longer export x
+ -- The only way we don't depend on the export list is if we have
+ -- import M()
+ -- And of course, for modules that aren't imported directly we don't
+ -- depend on their export lists
\end{code}
ms_location :: ModLocation, -- Location
ms_hs_date :: ClockTime, -- Timestamp of source file
ms_obj_date :: Maybe ClockTime, -- Timestamp of object, maybe
- ms_srcimps :: [Module], -- Source imports
- ms_imps :: [Module], -- Non-source imports
+ ms_srcimps :: [Located Module], -- Source imports
+ ms_imps :: [Located Module], -- Non-source imports
ms_hspp_file :: Maybe FilePath, -- Filename of preprocessed source,
-- once we have preprocessed it.
ms_hspp_buf :: Maybe StringBuffer -- The actual preprocessed source, maybe.
}
isObjectLinkable :: Linkable -> Bool
-isObjectLinkable l = all isObject (linkableUnlinked l)
+isObjectLinkable l = not (null unlinked) && all isObject unlinked
+ where unlinked = linkableUnlinked l
+ -- A linkable with no Unlinked's is treated as a BCO. We can
+ -- generate a linkable with no Unlinked's as a result of
+ -- compiling a module in HscNothing mode, and this choice
+ -- happens to work well with checkStability in module GHC.
instance Outputable Linkable where
ppr (LM when_made mod unlinkeds)