Compiling code with GHC

John Dorsey haskell at
Thu Jul 17 14:54:05 EDT 2008

> I noticed that GHC generates huge executables.

As I recall, GHC only uses shared libraries on OSX.  Your executable
probably has a lot compiled in statically.  Even though I'm pretty
sure GHC does what it can for dead code elimination, statically linked
executables tend to be largish.

A good bit of that executable size may be GHC's machinery, like the
garbage collector and thread manager.

If you haven't already, and if you're on a unix variant, then you can
probably save some space by stripping the executable:

$ ghc --make hello
$ strip hello

Is space usage critical for you?  Try different optimization levels.
Use compression.  Eliminate dependencies on large external libraries,
if possible.

I just got used to it.


More information about the Beginners mailing list