Providence Salumu Commentary/Compiler – GHC
wiki:Commentary/Compiler

GHC Commentary: The Compiler

The compiler itself is written entirely in Haskell, and lives in the many sub-directories of the compiler directory.

Case studies:

Overall Structure

Here is a block diagram of its top-level structure:

The part called HscMain deals with compiling a single module. On top of this is built the compilation manager (in blue) that manages the compilation of multiple modules. It exports an interface called the GHC API. On top of this API are four small front ends:

  • The "one-shot" mode, where GHC compiles each file on the command line separately (eg. ghc -c Foo.hs). This mode bypasses the GHC API, and is implemented directly on top of HscMain, since it compiles only one file at a time. In fact, this is all that GHC consisted of prior to version 5.00 when GHCi and --make were introduced.

GHC is packaged as a single binary in which all of these front-ends are present, selected by the command-line flags indicated above. There is a single command-line interface implemented in ghc/Main.hs.

In addition, GHC is compiled, without its front ends, as a library which can be imported by any Haskell program; see the GHC API.

Last modified 8 months ago Last modified on May 16, 2016 6:05:22 PM

Attachments (1)

Download all attachments as: .zip

Providence Salumu