Compiling code with GHC

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Compiling code with GHC

Rafael Gustavo da Cunha Pereira Pinto-2
I noticed that GHC generates huge executables.

module Main(main) where
    main = do putStr("Hello World!")

is almost 600kB after compiled!

Is there any way to make it smaller?

Best regards,


--
Rafael Gustavo da Cunha Pereira Pinto
Electronic Engineer, MSc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20080717/a59f959d/attachment.htm
Reply | Threaded
Open this post in threaded view
|

Compiling code with GHC

John Dorsey-2
> 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.

John

Reply | Threaded
Open this post in threaded view
|

Compiling code with GHC

Chad Wilson
The exe's on Windows also seem to be huge.  Is there a Windows version of strip?

-w