Commit 20800b9a authored by Sylvain Henry's avatar Sylvain Henry Committed by Marge Bot

Split GHC.Iface.Utils module

* GHC.Iface.Recomp: recompilation avoidance stuff
* GHC.Iface.Make: mkIface*

Moved `writeIfaceFile` into GHC.Iface.Load alongside `readIface` and
renamed it `writeIface` for consistency.
parent bb586f89
Pipeline #16589 passed with stages
in 481 minutes and 19 seconds
......@@ -1276,7 +1276,7 @@ has two major consequences
In contrast, orphans are all fingerprinted together in the
mi_orph_hash field of the ModIface.
See GHC.Iface.Utils.addFingerprints.
See GHC.Iface.Recomp.addFingerprints.
Orphan-hood is computed
* For class instances:
......@@ -1284,8 +1284,8 @@ Orphan-hood is computed
(because it is needed during instance lookup)
* For rules and family instances:
when we generate an IfaceRule (GHC.Iface.Utils.coreRuleToIfaceRule)
or IfaceFamInst (GHC.Iface.Utils.instanceToIfaceInst)
when we generate an IfaceRule (GHC.Iface.Make.coreRuleToIfaceRule)
or IfaceFamInst (GHC.Iface.Make.instanceToIfaceInst)
-}
{-
......
......@@ -26,7 +26,7 @@ import GHC.Iface.Syntax ( ShowSub(..), ShowHowMuch(..), AltPpr(..)
, showToHeader, pprIfaceDecl )
import CoAxiom ( coAxiomTyCon )
import GHC.Driver.Types( tyThingParent_maybe )
import GHC.Iface.Utils ( tyThingToIfaceDecl )
import GHC.Iface.Make ( tyThingToIfaceDecl )
import FamInstEnv( FamInst(..), FamFlavor(..) )
import TyCoPpr ( pprUserForAll, pprTypeApp, pprSigmaType )
import Name
......@@ -72,7 +72,7 @@ Why do this?
* Interface files contains fast-strings, not uniques, so the very same
tidying must take place when we convert to IfaceDecl. E.g.
GHC.Iface.Utils.tyThingToIfaceDecl which converts a TyThing (i.e. TyCon,
GHC.Iface.Make.tyThingToIfaceDecl which converts a TyThing (i.e. TyCon,
Class etc) to an IfaceDecl.
Bottom line: IfaceDecls are already 'tidy', so it's straightforward
......
......@@ -44,7 +44,7 @@ import UniqDFM
import Outputable
import Maybes
import HeaderInfo
import GHC.Iface.Utils
import GHC.Iface.Recomp
import GHC.Driver.Make
import UniqDSet
import PrelNames
......
......@@ -116,11 +116,12 @@ import GHC.IfaceToCore ( typecheckIface )
import TcRnMonad
import TcHsSyn ( ZonkFlexi (DefaultFlexi) )
import NameCache ( initNameCache )
import GHC.Iface.Load ( ifaceStats, initExternalPackageState )
import PrelInfo
import GHC.Iface.Utils
import GHC.HsToCore
import SimplCore
import GHC.HsToCore
import GHC.Iface.Load ( ifaceStats, initExternalPackageState, writeIface )
import GHC.Iface.Make
import GHC.Iface.Recomp
import GHC.Iface.Tidy
import GHC.CoreToStg.Prep
import GHC.CoreToStg ( coreToStg )
......@@ -1370,7 +1371,7 @@ hscWriteIface dflags iface no_change mod_location = do
unless no_change $
let ifaceFile = buildIfName ifaceBaseFile (hiSuf dflags)
in {-# SCC "writeIface" #-}
writeIfaceFile dflags ifaceFile iface
writeIface dflags ifaceFile iface
whenGeneratingDynamicToo dflags $ do
-- TODO: We should do a no_change check for the dynamic
-- interface file too
......@@ -1379,7 +1380,7 @@ hscWriteIface dflags iface no_change mod_location = do
-- dynDflags will have set hiSuf correctly.
dynIfaceFile = buildIfName ifaceBaseFile (hiSuf dynDflags)
writeIfaceFile dynDflags dynIfaceFile iface
writeIface dynDflags dynIfaceFile iface
where
buildIfName :: String -> String -> String
buildIfName baseName suffix
......
......@@ -68,7 +68,7 @@ import FileCleanup
import Ar
import Bag ( unitBag )
import FastString ( mkFastString )
import GHC.Iface.Utils ( mkFullIface )
import GHC.Iface.Make ( mkFullIface )
import UpdateCafInfos ( updateModDetailsCafInfos )
import Exception
......
......@@ -2513,7 +2513,7 @@ data Dependencies
-- ^ All the plugins used while compiling this module.
}
deriving( Eq )
-- Equality used only for old/new comparison in GHC.Iface.Utils.addFingerprints
-- Equality used only for old/new comparison in GHC.Iface.Recomp.addFingerprints
-- See 'TcRnTypes.ImportAvails' for details on dependencies.
instance Binary Dependencies where
......
......@@ -5,7 +5,7 @@
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
module GHC.HsToCore.Usage (
-- * Dependency/fingerprinting code (used by GHC.Iface.Utils)
-- * Dependency/fingerprinting code (used by GHC.Iface.Make)
mkUsageInfo, mkUsedNames, mkDependencies
) where
......
......@@ -39,7 +39,7 @@ import Type ( mkVisFunTys, Type )
import TysWiredIn ( mkListTy, mkSumTy )
import Var ( Id, Var, setVarName, varName, varType )
import TcRnTypes
import GHC.Iface.Utils ( mkIfaceExports )
import GHC.Iface.Make ( mkIfaceExports )
import Panic
import Maybes
......
......@@ -22,7 +22,7 @@ module GHC.Iface.Load (
-- IfM functions
loadInterface,
loadSysInterface, loadUserInterface, loadPluginInterface,
findAndReadIface, readIface, -- Used when reading the module's old interface
findAndReadIface, readIface, writeIface,
loadDecls, -- Should move to GHC.IfaceToCore and be renamed
initExternalPackageState,
moduleFreeHolesPrecise,
......@@ -84,6 +84,7 @@ import Control.Monad
import Control.Exception
import Data.IORef
import System.FilePath
import System.Directory
{-
************************************************************************
......@@ -486,7 +487,6 @@ loadInterface doc_str mod from
-- Warn warn against an EPS-updating import
-- of one's own boot file! (one-shot only)
-- See Note [Loading your own hi-boot file]
-- in GHC.Iface.Utils.
; WARN( bad_boot, ppr mod )
updateEps_ $ \ eps ->
......@@ -536,7 +536,7 @@ loadInterface doc_str mod from
Generally speaking, when compiling module M, we should not
load M.hi boot into the EPS. After all, we are very shortly
going to have full information about M. Moreover, see
Note [Do not update EPS with your own hi-boot] in GHC.Iface.Utils.
Note [Do not update EPS with your own hi-boot] in GHC.Iface.Recomp.
But there is a HORRIBLE HACK here.
......@@ -974,8 +974,13 @@ findAndReadIface doc_str mod wanted_mod_with_insts hi_boot_file
liftIO $ writeIORef ref False
checkBuildDynamicToo _ = return ()
-- @readIface@ tries just the one file.
-- | Write interface file
writeIface :: DynFlags -> FilePath -> ModIface -> IO ()
writeIface dflags hi_file_path new_iface
= do createDirectoryIfMissing True (takeDirectory hi_file_path)
writeBinIface dflags hi_file_path new_iface
-- @readIface@ tries just the one file.
readIface :: Module -> FilePath
-> TcRnIf gbl lcl (MaybeErr MsgDoc ModIface)
-- Failed err <=> file not found, or unreadable, or illegible
......
This diff is collapsed.
......@@ -1417,7 +1417,7 @@ instance Outputable IfaceUnfolding where
* *
************************************************************************
This is used for dependency analysis in GHC.Iface.Utils, so that we
This is used for dependency analysis in GHC.Iface.Make, so that we
fingerprint a declaration before the things that depend on it. It
is specific to interface-file fingerprinting in the sense that we
don't collect *all* Names: for example, the DFun of an instance is
......
......@@ -356,7 +356,8 @@ Library
GHC.Iface.Type
GHC.CoreToIface
GHC.Iface.Load
GHC.Iface.Utils
GHC.Iface.Make
GHC.Iface.Recomp
GHC.IfaceToCore
FlagChecker
Annotations
......
......@@ -100,7 +100,7 @@ Note [About wired-in things]
checker sees if the Name is wired in before looking up the name in
the type environment.
* GHC.Iface.Utils prunes out wired-in things before putting them in an interface file.
* GHC.Iface.Make prunes out wired-in things before putting them in an interface file.
So interface files never contain wired-in things.
-}
......
......@@ -88,7 +88,7 @@ import FamInstEnv( FamInst, pprFamInst, famInstsRepTyCons
, famInstEnvElts, extendFamInstEnvList, normaliseType )
import TcAnnotations
import TcBinds
import GHC.Iface.Utils ( coAxiomToIfaceDecl )
import GHC.Iface.Make ( coAxiomToIfaceDecl )
import HeaderInfo ( mkPrelImports )
import TcDefaults
import TcEnv
......@@ -1837,7 +1837,7 @@ being called "Main.main". That's why root_main_id has a fixed module
":Main".)
This is unusual: it's a LocalId whose Name has a Module from another
module. Tiresomely, we must filter it out again in GHC.Iface.Utils, less we
module. Tiresomely, we must filter it out again in GHC.Iface.Make, less we
get two defns for 'main' in the interface file!
......
......@@ -384,7 +384,7 @@ data FrontendResult
--
-- - For any code involving Names, we want semantic modules.
-- See lookupIfaceTop in GHC.Iface.Env, mkIface and addFingerprints
-- in GHC.Iface.Utils, and tcLookupGlobal in TcEnv
-- in GHC.Iface.{Make,Recomp}, and tcLookupGlobal in TcEnv
--
-- - When reading interfaces, we want the identity module to
-- identify the specific interface we want (such interfaces
......@@ -664,7 +664,7 @@ We gather three sorts of usage information
Used (a) to report "defined but not used"
(see GHC.Rename.Names.reportUnusedNames)
(b) to generate version-tracking usage info in interface
files (see GHC.Iface.Utils.mkUsedNames)
files (see GHC.Iface.Make.mkUsedNames)
This usage info is mainly gathered by the renamer's
gathering of free-variables
......
......@@ -320,7 +320,7 @@ mkImportedInstance cls_nm mb_tcs dfun_name dfun oflag orphan
{-
Note [When exactly is an instance decl an orphan?]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(see GHC.Iface.Utils.instanceToIfaceInst, which implements this)
(see GHC.Iface.Make.instanceToIfaceInst, which implements this)
Roughly speaking, an instance is an orphan if its head (after the =>)
mentions nothing defined in this module.
......
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