[Haskell-cafe] Compiling to STG problem

Thomas Schilling nominolo at googlemail.com
Wed Nov 27 09:46:48 UTC 2013


Renaming to "value1" is introduced by tidyProgram.  I don't think
-ddump-stg does that (but I haven't checked).

What are you trying to do?  The -ddump output is not really designed
to be parseable.  If you want to do something with STG you should
either work directly with the output of the GHC "API" calls, or take
that and serialise it to a format defined by you.

On 21 November 2013 10:01, Maarten Dungen <maarten.dungen at gmail.com> wrote:
> 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.
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list