
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

On Tue, 03 Sep 2013 12:45:34 +0200, 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?
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@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 --

On Tue, 03 Sep 2013 13:48:17 +0200, Henk-Jan van Tuyl
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@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 --

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
On 09/03/2013 02:45 PM, Nathan Hüsken wrote: 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.htm.... 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

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.htm.... 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@therning.org jabber: magnus@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)
participants (4)
-
Dmitry Vyal
-
Henk-Jan van Tuyl
-
Magnus Therning
-
Nathan Hüsken