How do you build base with your own compiler?

Christopher Done chrisdone at
Thu Jun 28 17:08:41 UTC 2018

I've built the GHC compiler along with libraries/base in the canonical way.

Now, I want to compile base with my own compiler frontend which will
do some analysis. Here's what I've done so far:

1) I've compiled my frontend with the ghc-stage2 compiler and
registered it. That works.
2) I've found the right GHC invocation which looks like this:

"inplace/bin/ghc-stage1" -hisuf hi -osuf  o -hcsuf hc -static  -O0
-H64m -Wall      -this-unit-id base- -hide-all-packages -i
-ilibraries/base/. -ilibraries/base/dist-install/build
-Ilibraries/base/dist-install/build/autogen -Ilibraries/base/include
-package-id ghc-prim- -package-id integer-gmp-
-package-id rts -this-unit-id base -XHaskell2010 -O0
-no-user-package-db -rtsopts -Wno-trustworthy-safe
-Wno-deprecated-flags     -Wnoncanonical-monad-instances  -odir
libraries/base/dist-install/build -hidir
libraries/base/dist-install/build -stubdir
libraries/base/dist-install/build   -dynamic-too $hsfile

So I

(1) changed stage1 to stage2, so that I could use plugins,
(2) simply added --frontend GhcFrontendPlugin -package frontend and
ran that on every file under base/ in a loop:

That seems to work. I basically have what I wanted.

But I'd rather be able to invoke make with e.g.
GHC_COMPILER=inplace/ghc/stage2 and EXTRA_HC_OPTS=" --frontend
GhcFrontendPlugin -package frontend". Is there an easy flag to do

If not, can someone point me where in the makefile I could tweak this?


More information about the ghc-devs mailing list