Support for compiler plugins in GHC HEAD

austin seipp as at hacks.yi.org
Fri Nov 19 21:46:49 EST 2010


Hello,

I've updated the patch with a few validate fixes (failings due to
-Werror) and a few other things.

I've instead uploaded the patch here (to avoid g-h-u and cvs-ghc from
blocking me due to a large message so people can see):

http://hacks.yi.org/~as/code/ghc/ghc_plugins_support_2010_11_19.dpatch

and updated it on the trac page. I'll continue updating the patch on
my server to reflect the most recent changes as they come in.

Original message below.

Regards,
Austin

On Fri, Nov 19, 2010 at 8:06 PM, austin seipp <as at hacks.yi.org> wrote:
> Hello everybody,
>
> (CC'ing max and cvs-ghc in case people lurk in different spots.)
>
> I have spent the past day and taken the liberty of updating Max
> Bolingbroke's original patches for supporting compiler plugins in GHC,
> and making
> them work with the latest version of GHC HEAD (7.1.x.)
>
> It is very sad IMO that this work went by so long without being merged
> mainline, but the CoreM and Annotations code was merged into mainline
> long
> long ago before the advent of dynamic linking (and many other things)
> in GHC. This part of the task floundered around and so I decided to do
> something about it.
>
> I would like to see this code merged mainline and supported in future
> major releases of GHC. I am willing to take responsibility for
> updating and maintaining it
> and bringing it up to the code quality standards the GHC team expects
> (which I'm sure which will be necessary.) It is early in the GHC 7.2
> development cycle, so ideally
> it could be merged soon so we have as long as possible to fix bugs and
> change things if necessary until the 7.2 release.
>
> Most of the code is written by Max originally and perhaps slightly
> modified by me to update it with changes to the simplifier and linker
> interface. Most of it was untouched, actually.
>
> It has been tested only on my linux machine (debian x86_64, kernel
> 2.6.34,) with GHC 7.1.x x86_64. I also have a macbook I can test the
> patches on (x86_64 darwin, snow leopard, i386 ghc 7.1.x) but I
> have yet to get around to it.
>
> The patch is quite small actually (smaller than max's original,
> although I intentionally left out things that were unnecessary or
> refactorings) so hopefully reviewing it is not much of a burden on you
> guys at
> GHC HQ.
>
> Caveat: I have not yet ported over Max's testsuite patches, which just
> build a plugin and expect some output when run. I'm getting around to
> it although I have to figure out the test suite infrastructure a
> little
> first I guess.
>
> ==============================================
> == Getting the patch and using it
>
> I have uploaded the patch onto the relevant trac ticket here:
> http://hackage.haskell.org/trac/ghc/ticket/3843
>
> It is also attached to this email. In the future I might put up a GHC
> repo on my webserver so you can just directly pull patches from it (I
> like this more than emailing patches around, personally) with darcs.
>
> After you download the patch and apply it with darcs, go ahead and
> build the regular stage2 compiler (do "perl boot; ./configure; make
> -j3" for dual core, etc.)
>
> Then, download this CSE plugin from github, load it and compile the
> example (again, originally written by Max and slightly modified to
> work by myself):
>
> https://github.com/thoughtpolice/cse-ghc-plugin
>
> Like so:
>
> $ pwd
> /home/a/
> $ cd src
> $ git clone git://github.com/thoughtpolice/cse-ghc-plugin.git
> $ cd cse-ghc-plugin
>
> # assumes your GHC build is in ~/src/ghc-head+plugins/
> $ cabal install -w ~/src/ghc-head+plugins/inplace/bin/ghc-stage2
> ...
>
> #plugin now installed, we can use it:
> $ cd tests
> $ pwd
> /home/a/src/cse-ghc-plugin/tests/
> $ ~/src/ghc-head+plugins/inplace/bin/ghc-stage2 -fforce-recomp
> -fno-cse Traced.hs
> [1 of 1] Compiling Main             ( Traced.hs, Traced.o )
> Linking Traced ...
> $ ./Traced
> The test is successful if the word 'Evaluated' appears only once below:
> Evaluated
> Evaluated
> # now do CSE through the plugin we installed
> $ ~/src/ghc-head+plugins/inplace/bin/ghc-stage2 -fforce-recomp
> -fno-cse Traced.hs -fplugin=CSE.Plugin
> [1 of 1] Compiling Main             ( Traced.hs, Traced.o )
> Loading package ghc-prim ... linking ... done.
> Loading package integer-gmp ... linking ... done.
> Loading package base ... linking ... done.
> Loading package ffi-1.0 ... linking ... done.
> Loading package array-0.3.0.2 ... linking ... done.
> Loading package containers-0.4.0.0 ... linking ... done.
> Loading package filepath-1.2.0.0 ... linking ... done.
> Loading package old-locale-1.0.0.2 ... linking ... done.
> Loading package old-time-1.0.0.6 ... linking ... done.
> Loading package unix-2.4.1.0 ... linking ... done.
> Loading package directory-1.1.0.0 ... linking ... done.
> Loading package pretty-1.0.1.2 ... linking ... done.
> Loading package process-1.0.1.4 ... linking ... done.
> Loading package Cabal-1.11.0 ... linking ... done.
> Loading package bytestring-0.9.1.8 ... linking ... done.
> Loading package binary-0.5.0.2 ... linking ... done.
> Loading package bin-package-db-0.0.0.0 ... linking ... done.
> Loading package hpc-0.5.0.6 ... linking ... done.
> Loading package template-haskell ... linking ... done.
> Loading package ghc-7.1.20101120 ... linking ... done.
> Loading package cse-plugin-1.0 ... linking ... done.
> Linking Traced ...
> $ ./Traced
> The test is successful if the word 'Evaluated' appears only once below:
> Evaluated
> $
>
> I'm currently validating my patch against the HEAD tree, but I
> speculate there won't be any problems (nothing huge has really changed
> honestly, and nothing happens when you don't invoke a plugin.)
>
> Max also wrote 2 other plugins, a strictifier (transforms haskell into
> a strict language) and a loop unroller, but I have yet to update them.
>
> All comments are welcome (here or in trac.)
>
> Regards,
> Austin
>


More information about the Glasgow-haskell-users mailing list