ghc-7.8.4: The GHC API

Safe Haskell | None
Language | Haskell98

DriverPipeline

Synopsis

- oneShot :: HscEnv -> Phase -> [(String, Maybe Phase)] -> IO ()
- compileFile :: HscEnv -> Phase -> (FilePath, Maybe Phase) -> IO FilePath
- linkBinary :: DynFlags -> [FilePath] -> [PackageId] -> IO ()
- preprocess :: HscEnv -> (FilePath, Maybe Phase) -> IO (DynFlags, FilePath)
- compileOne :: HscEnv -> ModSummary -> Int -> Int -> Maybe ModIface -> Maybe Linkable -> SourceModified -> IO HomeModInfo
- compileOne' :: Maybe TcGblEnv -> Maybe Messager -> HscEnv -> ModSummary -> Int -> Int -> Maybe ModIface -> Maybe Linkable -> SourceModified -> IO HomeModInfo
- link :: GhcLink -> DynFlags -> Bool -> HomePackageTable -> IO SuccessFlag
- data PhasePlus
  - = RealPhase Phase
  - | HscOut HscSource ModuleName HscStatus
- newtype CompPipeline a = P {
  - unP :: PipeEnv -> PipeState -> IO (PipeState, a)
  }
- data PipeEnv = PipeEnv {
  - pe_isHaskellishFile :: Bool
  - stop_phase :: Phase
  - src_filename :: String
  - src_basename :: String
  - src_suffix :: String
  - output_spec :: PipelineOutput
  }
- data PipeState = PipeState {
  - hsc_env :: HscEnv
  - maybe_loc :: Maybe ModLocation
  - maybe_stub_o :: Maybe FilePath
  }
- phaseOutputFilename :: Phase -> CompPipeline FilePath
- getPipeState :: CompPipeline PipeState
- getPipeEnv :: CompPipeline PipeEnv
- hscPostBackendPhase :: DynFlags -> HscSource -> HscTarget -> Phase
- getLocation :: HscSource -> ModuleName -> CompPipeline ModLocation
- setModLocation :: ModLocation -> CompPipeline ()
- setDynFlags :: DynFlags -> CompPipeline ()
- runPhase :: PhasePlus -> FilePath -> DynFlags -> CompPipeline (PhasePlus, FilePath)
- exeFileName :: Bool -> DynFlags -> FilePath
- mkExtraObjToLinkIntoBinary :: DynFlags -> IO FilePath
- mkNoteObjsToLinkIntoBinary :: DynFlags -> [PackageId] -> IO [FilePath]
- maybeCreateManifest :: DynFlags -> FilePath -> IO [FilePath]
- runPhase_MoveBinary :: DynFlags -> FilePath -> IO Bool
- linkingNeeded :: DynFlags -> Bool -> [Linkable] -> [PackageId] -> IO Bool
- checkLinkInfo :: DynFlags -> [PackageId] -> FilePath -> IO Bool

# Documentation

oneShot :: HscEnv -> Phase -> [(String, Maybe Phase)] -> IO ()

compileFile :: HscEnv -> Phase -> (FilePath, Maybe Phase) -> IO FilePath

linkBinary :: DynFlags -> [FilePath] -> [PackageId] -> IO ()

preprocess

Arguments

:: HscEnv |
-> (FilePath, Maybe Phase) | filename and starting phase
-> IO (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

Arguments

:: HscEnv |
-> ModSummary | summary for module being compiled
-> Int | module N ...
-> Int | ... of M
-> Maybe ModIface | old interface, if we have one
-> Maybe Linkable | old linkable, if we have one
-> SourceModified |
-> 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'

Arguments

:: Maybe TcGblEnv |
-> Maybe Messager |
-> HscEnv |
-> ModSummary | summary for module being compiled
-> Int | module N ...
-> Int | ... of M
-> Maybe ModIface | old interface, if we have one
-> Maybe Linkable | old linkable, if we have one
-> SourceModified |
-> IO HomeModInfo | the complete HomeModInfo, if successful

link :: GhcLink -> DynFlags -> Bool -> HomePackageTable -> IO SuccessFlag

data PhasePlus

Constructors

RealPhase Phase |
HscOut HscSource ModuleName HscStatus |

Instances

Outputable PhasePlus |

newtype CompPipeline a

Constructors

P |

Fields

unP :: PipeEnv -> PipeState -> IO (PipeState, a)

Instances

Monad CompPipeline |
Functor CompPipeline |
Applicative CompPipeline |
MonadIO CompPipeline |
HasDynFlags CompPipeline |

data PipeEnv

Constructors

PipeEnv |

Fields

pe_isHaskellishFile :: Bool
stop_phase :: Phase

  Stop just before this phase

src_filename :: String

  basename of original input source

src_basename :: String

  basename of original input source

src_suffix :: String

  its extension

output_spec :: PipelineOutput

  says where to put the pipeline output

data PipeState

Constructors

PipeState |

Fields

hsc_env :: HscEnv

  only the DynFlags change in the HscEnv. The DynFlags change at various points, for example when we read the OPTIONS_GHC pragmas in the Cpp phase.

maybe_loc :: Maybe ModLocation

  the ModLocation. This is discovered during compilation, in the Hsc phase where we read the module header.

maybe_stub_o :: Maybe FilePath

  the stub object. This is set by the Hsc phase if a stub object was created. The stub object will be joined with the main compilation object using "ld -r" at the end.

phaseOutputFilename :: Phase -> CompPipeline FilePath

getPipeState :: CompPipeline PipeState

getPipeEnv :: CompPipeline PipeEnv

hscPostBackendPhase :: DynFlags -> HscSource -> HscTarget -> Phase

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

getLocation :: HscSource -> ModuleName -> CompPipeline ModLocation

setModLocation :: ModLocation -> CompPipeline ()

setDynFlags :: DynFlags -> CompPipeline ()

runPhase

Arguments

:: PhasePlus | Run this phase
-> FilePath | name of the input file
-> DynFlags | for convenience, we pass the current dflags in
-> CompPipeline (PhasePlus, FilePath) |

Each phase in the pipeline returns the next phase to execute, and the name of the file in which the output was placed.

We must do things dynamically this way, because we often don't know what the rest of the phases will be until part-way through the compilation: for example, an {--} at the beginning of a source file can change the latter stages of the pipeline from taking the LLVM route to using the native code generator.

exeFileName :: Bool -> DynFlags -> FilePath

mkExtraObjToLinkIntoBinary :: DynFlags -> IO FilePath

mkNoteObjsToLinkIntoBinary :: DynFlags -> [PackageId] -> IO [FilePath]

maybeCreateManifest :: DynFlags -> FilePath -> IO [FilePath]

runPhase_MoveBinary :: DynFlags -> FilePath -> IO Bool

linkingNeeded :: DynFlags -> Bool -> [Linkable] -> [PackageId] -> IO Bool

checkLinkInfo :: DynFlags -> [PackageId] -> FilePath -> IO Bool