[Haskell-beginners] GHC-generated executables size

. ch.gosch at googlemail.com
Sat Oct 16 15:32:27 EDT 2010


On Sat, 2010-10-16 at 21:09 +0200, Daniel Fischer wrote:
> On Saturday 16 October 2010 15:03:52, . wrote:
> > Hi Daniel,
> > thanks for the explanations.
> > I have tried reinstalling with
> > cabal --reinstall gtk,
> > having set
> > split-objs: True
> > in ~/.cabal/config before.
> >
> > However, the compile yielded a single .o file again,
> 
> Yes, there's the single .o file for the package, the question is, what's in 
> the archive (libHSxxx.a). Rule of thumb, if it's more than twice as large 
> as the HSxxx.o, it contains the split object files (you can verify by 
> looking at it with nm).

Ah .. ok, stupid me ;)  the archive is more than twice the size, and ar
tells me about a lot of object files inside it. So compiling with
-split-objs appears to have worked out.
I have seen, however, that I have 2 versions of gtk (0.11.2 and 0.11.0)
on the system. I will try to find out which one was actually used when I
called "ghc --make guiMain"; how would I go about that?

> > and recompiling and re-linking my little program does not change
> > its size ...
> 
> Possibly the packages have been built with -spilt-objs originally, or your 
> GHC doesn't support split-objs, in either case, sorry for the inconvenience 
> :-/
> 
> gtk contains apparently hundreds of thousands of modules, so it may be the 
> module-initialisation functions. Quick test:
> 
> $ nm yourexecutable | grep stginit | wc -l

I tried that, there are almost 900 matches.

> > Any other idea what I might be doing wrong?
> 
> Nothing, probably.
> 
> What ghc version are you using, on which platform (OS, arch), which 
> packages does your executable need?

I am using Ubuntu 10.10, ghc 6.12.1, on a 4-core AMD Phenom.
The program I am compiling needs these packages:
 gtk, Text.Parsec, Time, Database.HDBC.Sqlite3, Locale,
Data.ByteString.Lazy.


--Christian



More information about the Beginners mailing list