Implementing a compilation server
facundo.dominguez at tweag.io
Thu May 5 00:05:18 UTC 2022
Dear ghc devs,
I'm using the ghc API to write a compilation server (a.k.a. persistent
worker). The idea is to serve requests to compile individual modules. In
this fashion, we can compile modules with different compilation flags and
yet pay only once for the startup overheads of the compiler.
One challenge of this approach is to reuse as much as possible from the ghc
API session/environment from one compilation request to the next, so we
save the trouble of reconstructing it each time. This message is to ask for
advise on how to better accomplish this reuse.
I tried reusing the whole environment for multiple requests, but I'm
conjecturing that this might cause troubles when the requests require
building modules with different values of -this-unit-id. Another problem
that streams from this is that recompiling a module which defines a type
class instance fails because it encounters in the environment the type
class instance from the
My work-in-progress implementation is here . There appears to be
multiple ways to compile a module in the API, so far I have been trying
My best lead right now is to look for inspiration in how GHCi implements
the load command, but this does a sort of --make compilation while I'm
going here for the one-shot style.
Thanks in advance,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ghc-devs