ghc-9.6.4: The GHC API
Safe HaskellSafe-Inferred
LanguageHaskell2010

GHC.Driver.Pipeline

Synopsis

Run a series of compilation steps in a pipeline, for a

Interfaces for the compilation manager (interpreted/batch-mode)

preprocess Source #

Arguments

:: HscEnv 
-> FilePath

input filename

-> Maybe InputFileBuffer

optional buffer to use instead of reading the input file

-> Maybe Phase

starting phase

-> IO (Either DriverMessages (DynFlags, FilePath)) 

Just preprocess a file, put the result in a temp. file (used by the compilation manager during the summary phase).

We return the augmented DynFlags, because they contain the result of slurping in the OPTIONS pragmas

compileOne Source #

Arguments

:: HscEnv 
-> ModSummary

summary for module being compiled

-> Int

module N ...

-> Int

... of M

-> Maybe ModIface

old interface, if we have one

-> HomeModLinkable

old linkable, if we have one

-> IO HomeModInfo

the complete HomeModInfo, if successful

Compile

Compile a single module, under the control of the compilation manager.

This is the interface between the compilation manager and the compiler proper (hsc), where we deal with tedious details like reading the OPTIONS pragma from the source file, converting the C or assembly that GHC produces into an object file, and compiling FFI stub files.

NB. No old interface can also mean that the source has changed.

compileOne' Source #

Arguments

:: Maybe Messager 
-> HscEnv 
-> ModSummary

summary for module being compiled

-> Int

module N ...

-> Int

... of M

-> Maybe ModIface

old interface, if we have one

-> HomeModLinkable 
-> IO HomeModInfo

the complete HomeModInfo, if successful

Linking

link Source #

Arguments

:: GhcLink

interactive or batch

-> Logger

Logger

-> TmpFs 
-> Hooks 
-> DynFlags

dynamic flags

-> UnitEnv

unit environment

-> Bool

attempt linking in batch mode?

-> Maybe (RecompileRequired -> IO ()) 
-> HomePackageTable

what to link

-> IO SuccessFlag 

PipeEnv

data PipeEnv Source #

Constructors

PipeEnv 

Fields

phaseOutputFilenameNew Source #

Arguments

:: Phase

The next phase

-> PipeEnv 
-> HscEnv 
-> Maybe ModLocation

A ModLocation, if we are compiling a Haskell source file

-> IO FilePath 

Running individual phases

data TPhase res where Source #

Constructors

T_Unlit :: PipeEnv -> HscEnv -> FilePath -> TPhase FilePath 
T_FileArgs :: HscEnv -> FilePath -> TPhase (DynFlags, Messages PsMessage, [Warn]) 
T_Cpp :: PipeEnv -> HscEnv -> FilePath -> TPhase FilePath 
T_HsPp :: PipeEnv -> HscEnv -> FilePath -> FilePath -> TPhase FilePath 
T_HscRecomp :: PipeEnv -> HscEnv -> FilePath -> HscSource -> TPhase (HscEnv, ModSummary, HscRecompStatus) 
T_Hsc :: HscEnv -> ModSummary -> TPhase (FrontendResult, Messages GhcMessage) 
T_HscPostTc :: HscEnv -> ModSummary -> FrontendResult -> Messages GhcMessage -> Maybe Fingerprint -> TPhase HscBackendAction 
T_HscBackend :: PipeEnv -> HscEnv -> ModuleName -> HscSource -> ModLocation -> HscBackendAction -> TPhase ([FilePath], ModIface, HomeModLinkable, FilePath) 
T_CmmCpp :: PipeEnv -> HscEnv -> FilePath -> TPhase FilePath 
T_Cmm :: PipeEnv -> HscEnv -> FilePath -> TPhase ([FilePath], FilePath) 
T_Cc :: Phase -> PipeEnv -> HscEnv -> Maybe ModLocation -> FilePath -> TPhase FilePath 
T_As :: Bool -> PipeEnv -> HscEnv -> Maybe ModLocation -> FilePath -> TPhase FilePath 
T_Js :: PipeEnv -> HscEnv -> Maybe ModLocation -> FilePath -> TPhase FilePath 
T_ForeignJs :: PipeEnv -> HscEnv -> Maybe ModLocation -> FilePath -> TPhase FilePath 
T_LlvmOpt :: PipeEnv -> HscEnv -> FilePath -> TPhase FilePath 
T_LlvmLlc :: PipeEnv -> HscEnv -> FilePath -> TPhase FilePath 
T_LlvmMangle :: PipeEnv -> HscEnv -> FilePath -> TPhase FilePath 
T_MergeForeign :: PipeEnv -> HscEnv -> FilePath -> [FilePath] -> TPhase FilePath 

Instances

Instances details
MonadUse TPhase HookedUse Source # 
Instance details

Defined in GHC.Driver.Pipeline.Execute

Methods

use :: TPhase a -> HookedUse a Source #

runPhase :: TPhase out -> IO out Source #

Default interpretation of each phase, in terms of IO.

hscPostBackendPhase :: HscSource -> Backend -> Phase Source #

What phase to run after one of the backend code generators has run

Constructing Pipelines

type TPipelineClass (f :: Type -> Type) (m :: Type -> Type) = (Functor m, MonadIO m, Applicative m, Monad m, MonadUse f m) Source #

class MonadUse f m where Source #

Lift a f action into an m action.

Methods

use :: f a -> m a Source #

Instances

Instances details
MonadUse TPhase HookedUse Source # 
Instance details

Defined in GHC.Driver.Pipeline.Execute

Methods

use :: TPhase a -> HookedUse a Source #

preprocessPipeline :: P m => PipeEnv -> HscEnv -> FilePath -> m (DynFlags, FilePath) Source #

The preprocessor pipeline

fullPipeline :: P m => PipeEnv -> HscEnv -> FilePath -> HscSource -> m (ModIface, HomeModLinkable) Source #

The complete compilation pipeline, from start to finish

hscPipeline :: P m => PipeEnv -> (HscEnv, ModSummary, HscRecompStatus) -> m (ModIface, HomeModLinkable) Source #

Everything after preprocess

Default method of running a pipeline

runPipeline :: Hooks -> HookedUse a -> IO a Source #

The default mechanism to run a pipeline, see Note [The Pipeline Monad]