[Haskell-beginners] Haskell exectuable size

Dmitry Vyal akamaus at gmail.com
Tue Sep 3 13:53:12 CEST 2013


On 09/03/2013 02:45 PM, Nathan Hüsken wrote:
 > I have written a small wxHaskell application. Since wxWidgets seems 
to be required to be linked dynamicly, I have to add the wxWidgets dlls. 
Those make a total of about 25MB, wow.
 >
 > Now the compiled exe (compiled with ghc -O2) has size 15MB.
 > In total I am at about 50Mb, which is just to much.
 >
 > Why is the exe so big?
 > Has anyone a suggestion on how to reduce the total size?
Bindings for large C libraries contain a great number of Haskell wrapper 
functions for C functions.  Looks like GHC is not terribly efficient in 
terms of size of generated code. Your tiny application gets statically 
linked with a huge haskell library which in turn dynamically linked with 
C library doing the actual work.

In case you're having multiply haskell binaries using wxWidgets you can 
use GHC's dynamic linking feature. 
http://www.haskell.org/ghc/docs/7.6.3/html/users_guide/using-shared-libs.html. 
This way actual binaries would be small but would have an additional 
run-time dependency.

And my question. Does GHC try to exclude unused symbols from Haskell 
libraries it links to application code?

Best wishes,
Dmitry




More information about the Beginners mailing list