Oversized libraries

Audrius Šaikūnas tuxmarkv at gmail.com
Tue Dec 14 17:33:53 CET 2010


Hello,

I've noticed that libraries that are compiled even with -dynamic are
really huge:
libHScairo-0.12.0-ghc6.12.1.so - 1.4 M
libHSgio-0.12.0-ghc6.12.1.so - 1.6 M
libHSgtk-0.12.0-ghc6.12.1.so - 14 M

(ldd confirms that these libraries are really linked dynamically with
the rest of the world)

just to name a few. All of them are striped with "strip -s".
At this point *bindings* to C libraries are larger that the libraries
themselves, which I find unacceptable.

So I decided to dig a bit deeper and when examining cairo-0.12.0 I found
that Types.o object file consumes 1.5 MB. So I "cleaned" up Types.hs and
tried to compile it separately from the rest of the library:

 % ghc -c Types.hs && ls -lh | grep Types.o
-rw-r--r-- 1 angel angel  69K 2010-12-14 18:24 Types.o
 % rm Types.o
 % ghc -c Types.hs -O && ls -lh | grep Types.o
-rw-r--r-- 1 angel angel 1.1M 2010-12-14 18:25 Types.o

So adding -O when compiling Types.hs makes the size of object file jump
from 69K to 1.1M. Just think about it - the file contains *two* *enums*
and nothing more. And yet it twice as large as a full-blown application
like gedit.

So I would like to ask you whether such behavior is known and should
such this be considered as a bug?

I've attached the testcase. It also can be found here:
http://hpaste.org/42331/something

Btw, I'm using GHC 6.12.1, x86_64.

Best regards,
  Audrius


-------------- next part --------------
A non-text attachment was scrubbed...
Name: Types.hs
Type: text/x-haskell
Size: 9271 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20101214/a47c3824/attachment.hs>


More information about the Glasgow-haskell-users mailing list