ghc-9.10.3: The GHC API

Safe Haskell | None
Language | GHC2021

GHC.Iface.Recomp

Description

Module for detecting if recompilation is required

Synopsis

- checkOldIface :: HscEnv -> ModSummary -> Maybe ModIface -> IO (MaybeValidated ModIface)
- data RecompileRequired
  - = UpToDate
  - | NeedsRecompile !CompileReason
- needsRecompileBecause :: RecompReason -> RecompileRequired
- recompThen :: Monad m => m RecompileRequired -> m RecompileRequired -> m RecompileRequired
- data MaybeValidated a
  - = UpToDateItem a
  - | OutOfDateItem !CompileReason (Maybe a)
- outOfDateItemBecause :: RecompReason -> Maybe a -> MaybeValidated a
- data RecompReason
  - = UnitDepRemoved UnitId
  - | ModulePackageChanged FastString
  - | SourceFileChanged
  - | ThisUnitIdChanged
  - | ImpurePlugin
  - | PluginsChanged
  - | PluginFingerprintChanged
  - | ModuleInstChanged
  - | HieMissing
  - | HieOutdated
  - | SigsMergeChanged
  - | ModuleChanged ModuleName
  - | ModuleRemoved (UnitId, ModuleName)
  - | ModuleAdded (UnitId, ModuleName)
  - | ModuleChangedRaw ModuleName
  - | ModuleChangedIface ModuleName
  - | FileChanged FilePath
  - | CustomReason String
  - | FlagsChanged
  - | OptimFlagsChanged
  - | HpcFlagsChanged
  - | MissingBytecode
  - | MissingObjectFile
  - | MissingDynObjectFile
  - | MissingDynHiFile
  - | MismatchedDynHiFile
  - | ObjectsChanged
  - | LibraryChanged
  - | THWithJS
- data CompileReason
  - = MustCompile
  - | RecompBecause !RecompReason
- recompileRequired :: RecompileRequired -> Bool
- addFingerprints :: HscEnv -> PartialModIface -> IO ModIface

# Documentation

checkOldIface :: HscEnv -> ModSummary -> Maybe ModIface -> IO (MaybeValidated ModIface) Source #

Top level function to check if the version of an old interface file is equivalent to the current source file the user asked us to compile. If the same, we can avoid recompilation.

We return on the outside whether the interface file is up to date, providing evidence that is with a `ModIface`. In the case that it isn't, we may also return a found or provided `ModIface`. Why we don't always return the old one, if it exists, is unclear to me, except that I tried it and some tests failed (see #18205).

data RecompileRequired Source #

Constructors

UpToDate | everything is up to date, recompilation is not required
NeedsRecompile !CompileReason | Need to compile the module

#### Instances

Instances details

Outputable RecompileRequired Source # |
Instance details Defined in GHC.Iface.Recomp Methods ppr :: RecompileRequired -> SDoc Source #
Monoid RecompileRequired Source # |
Instance details Defined in GHC.Iface.Recomp Methods mempty :: RecompileRequired # mappend :: RecompileRequired -> RecompileRequired -> RecompileRequired # mconcat :: [RecompileRequired] -> RecompileRequired #
Semigroup RecompileRequired Source # |
Instance details Defined in GHC.Iface.Recomp Methods (<>) :: RecompileRequired -> RecompileRequired -> RecompileRequired # sconcat :: NonEmpty RecompileRequired -> RecompileRequired # stimes :: Integral b => b -> RecompileRequired -> RecompileRequired #
Eq RecompileRequired Source # |
Instance details Defined in GHC.Iface.Recomp Methods (==) :: RecompileRequired -> RecompileRequired -> Bool # (/=) :: RecompileRequired -> RecompileRequired -> Bool #

needsRecompileBecause :: RecompReason -> RecompileRequired Source #

recompThen :: Monad m => m RecompileRequired -> m RecompileRequired -> m RecompileRequired Source #

data MaybeValidated a Source #

Constructors

UpToDateItem a | The item contained is validated to be up to date
OutOfDateItem | The item is are absent altogether or out of date, for the reason given.

Fields

- !CompileReason

  the reason we need to recompile.

- (Maybe a)

  The old item, if it exists

#### Instances

Instances details

Functor MaybeValidated Source # |
Instance details Defined in GHC.Iface.Recomp Methods fmap :: (a -> b) -> MaybeValidated a -> MaybeValidated b # (<$) :: a -> MaybeValidated b -> MaybeValidated a #
Outputable a => Outputable (MaybeValidated a) Source # |
Instance details Defined in GHC.Iface.Recomp Methods ppr :: MaybeValidated a -> SDoc Source #

outOfDateItemBecause :: RecompReason -> Maybe a -> MaybeValidated a Source #

data RecompReason Source #

Constructors

UnitDepRemoved UnitId |
ModulePackageChanged FastString |
SourceFileChanged |
ThisUnitIdChanged |
ImpurePlugin |
PluginsChanged |
PluginFingerprintChanged |
ModuleInstChanged |
HieMissing |
HieOutdated |
SigsMergeChanged |
ModuleChanged ModuleName |
ModuleRemoved (UnitId, ModuleName) |
ModuleAdded (UnitId, ModuleName) |
ModuleChangedRaw ModuleName |
ModuleChangedIface ModuleName |
FileChanged FilePath |
CustomReason String |
FlagsChanged |
OptimFlagsChanged |
HpcFlagsChanged |
MissingBytecode |
MissingObjectFile |
MissingDynObjectFile |
MissingDynHiFile |
MismatchedDynHiFile |
ObjectsChanged |
LibraryChanged |
THWithJS |

#### Instances

Instances details

Outputable RecompReason Source # |
Instance details Defined in GHC.Iface.Recomp Methods ppr :: RecompReason -> SDoc Source #
Eq RecompReason Source # |
Instance details Defined in GHC.Iface.Recomp Methods (==) :: RecompReason -> RecompReason -> Bool # (/=) :: RecompReason -> RecompReason -> Bool #

data CompileReason Source #

Constructors

MustCompile | The .hs file has been touched, or the .o/.hi file does not exist
RecompBecause !RecompReason | The .o/.hi files are up to date, but something else has changed to force recompilation; the String says what (one-line summary)

#### Instances

Instances details

Outputable CompileReason Source # |
Instance details Defined in GHC.Iface.Recomp Methods ppr :: CompileReason -> SDoc Source #
Eq CompileReason Source # |
Instance details Defined in GHC.Iface.Recomp Methods (==) :: CompileReason -> CompileReason -> Bool # (/=) :: CompileReason -> CompileReason -> Bool #

recompileRequired :: RecompileRequired -> Bool Source #

addFingerprints :: HscEnv -> PartialModIface -> IO ModIface Source #

Add fingerprints for top-level declarations to a `ModIface`.

See Note [Fingerprinting IfaceDecls]