Fwd: Compiling Core Haskell using GHC API
Edward Z. Yang
ezyang at mit.edu
Thu Oct 8 17:02:17 UTC 2015
If we look at the source code for hscCompileCore, it would seem that it
creates a ModGuts with mkModGuts which has an empty mg_exports, which
means that in all cases there will be no exported items. So it's not
very useful! You should file a bug.
We should fix this, but in the mean time, you could simply copypaste the
definition of hscCompileCore, and modify it so that you do set up
the ModGuts correctly with a real mg_exports field.
Excerpts from Marek Wawrzos's message of 2015-10-08 07:22:01 -0700:
> I'm trying to compile some module with GHC API. I'm going to feed GHC with
> Core generated by me.
> So far is noticed, that function compileCoreToObj ends with an runtime
> error on each call. In spide of this function produces some *.o and *.hi
> files. However, produced interface file does not contain any item in
> exports field, what makes compiled module unusable.
> Because of this problem, I tried to achieve my goal by using steps
> described here: https://wiki.haskell.org/GHC/As_a_library (the second
> I was able to print out Core produced form file. If I'm not wrong,
> modifying structures passing on between sequent calls does not effect on
> produced *.hi and *.o files. Both files are generated by `load
> LoadAllTargets' call, and further calls (parseModule, loadModule, ...) does
> not effect on generated files.
> Could You give me any advices in that topic? Am I right about
> compileCoreToObj and functions mentioned above?
> Best Regards,
More information about the ghc-devs