Haskell exectuable size

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

Haskell exectuable size

Nathan Hüsken
Hey,

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?

Thanks!
Nathan



Reply | Threaded
Open this post in threaded view
|

Haskell exectuable size

Henk-Jan van Tuyl
On Tue, 03 Sep 2013 12:45:34 +0200, Nathan H?sken  
<nathan.huesken at posteo.de> wrote:

> Hey,
>
> 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?

The compiled wxcore library (the raw wxWidgets interface) is about 11 MB.  
You can reduce it by about 50%, by using the GHC option -optl-s (this  
passes the option -s to the linker) to remove the debug data from the  
executable. This works for all executables, not just wxHaskell users.

The size can further be reduced by running UPX[0], an executable  
compression utility. UPX can also be used to compress DLLs.

Regards,
Henk-Jan van Tuyl


[0] http://upx.sourceforge.net/


--
Folding at home
What if you could share your unused computer power to help find a cure? In  
just 5 minutes you can join the world's biggest networked computer and get  
us closer sooner. Watch the video.
http://folding.stanford.edu/


http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
Haskell programming
--



Reply | Threaded
Open this post in threaded view
|

Haskell exectuable size

Dmitry V'yal
In reply to this post by Nathan Hüsken
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



Reply | Threaded
Open this post in threaded view
|

Haskell exectuable size

Magnus Therning
On Tue, Sep 03, 2013 at 03:53:12PM +0400, Dmitry Vyal wrote:

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

I'm under the impresssion that '--enable-split-objs' enables the
linker to exclude unused symbols/functions when linking to application
code.  I may be completely wrong though.

/M

--
Magnus Therning                      OpenPGP: 0xAB4DFBA4
email: magnus at therning.org   jabber: magnus at therning.org
twitter: magthe               http://therning.org/magnus

I have steadily endeavored to keep my mind free, so as to give up any
hypothesis, however much beloved -- and I cannot resist forming one
on every subject -- as soon as facts are shown to be opposed to it.
     -- Charles Darwin (1809-1882)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130903/a727cf9e/attachment.pgp>

Reply | Threaded
Open this post in threaded view
|

Haskell exectuable size

Henk-Jan van Tuyl
In reply to this post by Henk-Jan van Tuyl
On Tue, 03 Sep 2013 13:48:17 +0200, Henk-Jan van Tuyl <hjgtuyl at chello.nl>  
wrote:

> The compiled wxcore library (the raw wxWidgets interface) is about 11  
> MB. You can reduce it by about 50%, by using the GHC option -optl-s  
> (this passes the option -s to the linker) to remove the debug data from  
> the executable. This works for all executables, not just wxHaskell users.
>
> The size can further be reduced by running UPX[0], an executable  
> compression utility. UPX can also be used to compress DLLs.

It is also possible to strip the debug data from executables and DLLs,  
using the strip command from MinGW (before running UPX).
For example:
   strip wxmsw295u_xrc_gcc_custom.dll
   upx --best wxmsw295u_xrc_gcc_custom.dll

Regards,
Henk-Jan van Tuyl


--
Folding at home
What if you could share your unused computer power to help find a cure? In  
just 5 minutes you can join the world's biggest networked computer and get  
us closer sooner. Watch the video.
http://folding.stanford.edu/


http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
Haskell programming
--