
Willem Robert van Hage
[..] So I tried a simple hello world example exactly like the one I saw somewhere on the GHC pages that compiled to a binary of 6kb and I was surprised to see that even after stripping the binary it still takes up 140kb.
-rwxr-xr-x 1 willem users 201453 Sep 29 09:55 hello -rw-r--r-- 1 willem users 51 Sep 29 09:54 hello.hs -rw-r--r-- 1 willem users 1468 Sep 29 09:55 hello.o
It shows that source program takes 51 bytes, compiled object program - 1468 bytes. This is not mauch. Probably, the executable hello is 1000 times larger than object one because some piece of library (including binary code for outputting a string) is linked to it. In small user programs the library code is usually the larger part. In large user programs, it will be the smaller part. Regards, ----------------- Serge Mechveliani mechvel@botik.ru

-rwxr-xr-x 1 willem users 201453 Sep 29 09:55 hello -rw-r--r-- 1 willem users 51 Sep 29 09:54 hello.hs -rw-r--r-- 1 willem users 1468 Sep 29 09:55 hello.o
Probably, the executable hello is 1000 times larger than object one because some piece of library (including binary code for outputting a string) is linked to it. In small user programs the library code is usually the larger part. In large user programs, it will be the smaller part.
Serge Mechveliani
I think so too, but what I'm surprised about is that GHC apparently can't use printing functions and all those other things I saw in `strings hello`, for example things about sockets, forks and file IO, from a library instead of compiling it into the 'hello' binary. In the case of a 200k hello world file that isn't a big problem, but I want to do things with the gtk+hs toolkit and I've noticed that even the simplest programs take up 2Mb. 'strings' on an executable that uses gtk+hs show an endless list of unused functions. Things like functions for radiobuttons while the only thing I use is a label, a box and a window. I find that kind of strange. I'm using GHC on a laptop with not a very big harddisk. Doesn't GHC first check which functions actually get used and then only link those to the binary? Willem van Hage -- wrvh@xs4all.nl | http://www.xs4all.nl/~wrvh wrvhage@science.uva.nl | http://quest.sourceforge.net
participants (2)
-
S.D.Mechveliani
-
Willem Robert van Hage