[Haskell-cafe] Compiling to STG problem

Maarten Dungen maarten.dungen at gmail.com
Thu Nov 21 09:01:47 UTC 2013


Dear all,

While trying to retrieve the STG using ghc I bumped into the following
problem:

I try to compile the source file in a more or less standard way, found in
many examples on the web:

...

                       setTargets targets

                       _ <- load LoadAllTargets

                       mgraph <- depanal [] False

                       mapM_ (compileModSummary) mgraph

Then I compile the individual files through the following pipeline (also
more or less standard, I thought):

compileModSummary = do

...

     stg <- parseModule theMod

    >>= typecheckModule

    >>= desugarModule

    >>= liftIO . hscSimplify env . coreModule

    >>= liftIO . tidyProgram env

    >>= prepPgm env . fst

    >>= liftIO . coreToStg dynflags

   …

Then I do a dump to (just to check the results):

    writeFile “filename” (show . showOutputable $ stg)

The problem is, if I do a stg dump from the command line (like <compiler>
-ddump-stg --make Main.hs (where <compiler> is the intended compiler
program) the dump is different from the stg dump I do at writefile, to the
extent that functions are missing, which gives problems when linking the
results. They are numbered functions, like ‘value1’, etc. I’m not very much
into the ghcmake stuff, and I’m probably missing a lot, however I have been
struggling with this for a couple of days now, and it is not getting any
clearer.

I guess my question would be, why is there a difference, and how could I
avoid this? Any help or pointers appreciated.

kind regards,

Maarten

p.s. This is just pseudo code. I necessary, I could probably strip my
sources into a working example that displays the problem, if that would
help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20131121/4246cb44/attachment.html>


More information about the Haskell-Cafe mailing list