wiki:Commentary/Compiler/API

Version 4 (modified by simonmar, 8 years ago) (diff)

--

GHC Commentary: The GHC API

This section of the commentary describes everything between HscMain and the front-end; that is, the parts of GHC that coordinate the compilation of multiple modules.

Orgainsation of the top of GHC

The GHC API is the interface exported by compiler/main/GHC.hs. To compile a Haskell module that uses the GHC API, use the flag -package ghc (in GHC 6.6 and later). GHC itself contains a few front-ends:

  • The "one-shot" mode, where GHC compiles each file on the command line separately (eg. ghc -c Foo.hs). This mode 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.

Note that since GHC is packaged as a single binary, all of these front-ends are present, and there is a single command-line API. Everything goes via the main function in compiler/main/Main.hs.

Attachments (1)

Download all attachments as: .zip