[Haskell-cafe] GHC RTS question

Ben Millwood haskell at benmachine.co.uk
Sun Feb 21 17:21:11 EST 2010

On Sun, Feb 21, 2010 at 7:10 PM, Max Bolingbroke
<batterseapower at hotmail.com> wrote:
> You might be able to get somewhere by writing a custom "main" function
> in C and linking it in. According to
> http://haskell.org/ghc/docs/latest/html/users_guide/options-phases.html
> if a lib specified with the -l option during compilation contains a
> "main", that will be used in preference to the one from HSrts.

I think the neater way of doing this would be to use the FFI, with a
foreign export declaration making your haskell main available to a
wrapper C file, which would then initialise the RTS with a
slightly-modified argc and argv.
See http://www.haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html
for details on how to do that.

I also think it's strange, though, that adding RTS hooks is not
optional. GHC should support some method of disabling them, in my

More information about the Haskell-Cafe mailing list