Summary: I've released
ghc-make, which is an alternative to
I've just released v0.2 of
ghc-make (on Hackage, on Github). This package provides an alternative to
ghc --make which supports parallel compilation of modules and runs faster when nothing needs compiling. To unpack that:
- Parallel compilation: Call
ghc-make -j4and your program will build by running up to four
ghc -cprograms simultaneously. You usually need at parallel factor of 2x-3x to match
ghc --makeon a single core, since
ghc --makedoes a lot of caching that is unavailable to
ghc-make. If you use
-j1, or omit a
-jflag, the compilation will be based on
ghc --makeand should take the same time to compile.
- Faster when nothing needs rebuilding: If
ghc --makeis slow when there is nothing to rebuild, and most of your executions do no rebuilding,
ghc-makewill make things go faster. On Windows I have one project where
ghc --maketakes 23 seconds and
ghc-maketakes 0.2 seconds (more than 100x faster). Particularly useful for scripts that do
ghc --make Main && ./Main.
See the README for full details.
How do I use it?
cabal update && cabal install ghc-make). Then replace your calls to
ghc my -arguments with
ghc-make my -arguments. Almost all arguments and flags supported by
ghc are supported by
ghc-make - it is intended as a drop-in replacement. Let me know about any bugs on the bug tracker.
ghc-make with Cabal, try
cabal build --with-ghc=ghc-make --ghc-options=-j4. (This technique is due to the
ghc-parmake project, which also does parallel
ghc --make compiles.)
How is it implemented?
This program uses the Shake library for dependency tracking and
ghc --make for building. The actual
ghc-make project itself only contains 4 modules, and the largest of those is the test suite.
To pass options to the underlying Shake build system prefix them with
--shake, for example
--shake--report=- will write a profile report to stdout and
--shake--help will list the available Shake options.