How do you build base with your own compiler?

Christopher Done chrisdone at gmail.com
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-4.9.1.0 -hide-all-packages -i
-ilibraries/base/. -ilibraries/base/dist-install/build
-ilibraries/base/dist-install/build/autogen
-Ilibraries/base/dist-install/build
-Ilibraries/base/dist-install/build/autogen -Ilibraries/base/include
-optP-DOPTIMISE_INTEGER_GCD_LCM -optP-include
-optPlibraries/base/dist-install/build/autogen/cabal_macros.h
-package-id ghc-prim-0.5.0.0 -package-id integer-gmp-1.0.0.1
-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:

https://gist.github.com/chrisdone/3ca64592aed2053606d8814f2fa5d772

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
that?

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

Cheers


More information about the ghc-devs mailing list