Opened 12 years ago

Closed 11 years ago

Last modified 10 years ago

#1467 closed task (fixed)

GHC API: expose separate compilation stages

Reported by: simonmar Owned by: nominolo
Priority: normal Milestone: 6.10 branch
Component: GHC API Version: 6.9
Keywords: Cc: claus.reinke@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


The GHC API is currently hard to use for certain things: extracting the output from various compilation stages; or "hooking in" to the compilation pipeline. The checkModule function works for some uses, but it doesn't let you extract Core, for example, and it doesn't complete the compilation and inject the result into the Session, so the module still has to be compiled.

One way to solve this would be to abstract the compilation pipeline as a series of functions, so that the user could script the compiler. We haven't worked out the details, but in principle it should be possible to write a GHC API client that invokes the following steps:

  • parse a module
  • rename/typecheck
  • deSugar
  • optimise...
  • generate code

and can then inject the compilation results back into the Session for use by future compilations. Each individual stage should provide a result that can be inspected: get the renamed/typechecked code out, get the Core, and so on.

The current checkModule could be built on top of such an interface, but the interface would allow much more flexibility.

Change History (7)

comment:1 Changed 12 years ago by claus

Cc: claus.reinke@… added

don't forget the output stage(s):-) some people like core, others stg, and i'd like a version of outputable for source that doesn't ignore srclocs in Located.

comment:2 Changed 12 years ago by Isaac Dupree

see #1373 for an STG-output request

comment:3 Changed 11 years ago by nominolo

Owner: set to nominolo

comment:4 Changed 11 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:5 Changed 11 years ago by simonmar

Operating System: UnknownUnknown/Multiple

comment:6 Changed 11 years ago by nominolo

Resolution: fixed
Status: newclosed

We do have separate access to the front-end passes, now. It would be better to have a separate ticket for further access to compiler phases, or requests for improvements in the current implementation. Closing ticket.

comment:7 Changed 10 years ago by simonmar

difficulty: Moderate (1 day)Moderate (less than a day)
Note: See TracTickets for help on using tickets.