On Fri, Mar 07, 2003, Oron Peled wrote about "Re: [Haifux] Huge file with static 
linking":
> Yes, but that's what we have dietlibc for. Look:
> 
>       [EMAIL PROTECTED] ~/tmp]$ gcc -o t t.c
>       [EMAIL PROTECTED] ~/tmp]$ ls -l t
>       -rwxr-xr-x    1 oron     users       11348 Mar  7 09:01
>       [EMAIL PROTECTED] ~/tmp]$ diet gcc -o t t.c
>       [EMAIL PROTECTED] ~/tmp]$ ls -l t
>       -rwxr-xr-x    1 oron     users        1728 Mar  7 09:02

Neither of these look bloated at all - in fact they are rather tiny (and
that's even without you stripping them). A more meaningful comparison
would be with "-static".

> So most of the bloat is in glibc (it has to support a lot of
> optional code [e.g: nsswitch, resolving etc.])

When a code only uses puts() and stdout, the code doesn't strictly need to
support resolving, threading, and things like that. But the problem begins
when the same object-file that defines stdout also uses, say, malloc;
Malloc supports multithreading so it uses pthreads routines; These (or
other) routines can show message strings so they support locales and
printf, and the list grows and grows from here.

In the old days (say, 10 years ago), library designers tried very hard for
this not to happen. If you used only puts, "printf" would not get into your
code. If you used only stdout much of the stdio code (fopen, fclose, etc.)
would not get into your code.
Nowadays, people stopped caring about this issue. It's not because a 24-fold
increase in code size doesn't bother anybody (it surely does! 0.5 MB for a
"hello world" program is very large even at today's standards, and hence the
original poster's question) - it's because noadays people almost exclusively
use shared libraries, so this size increase does not happen.

I never tried the "diet libc" you mentioned. I assume, from its name, that
it indeed results in smaller code :)

-- 
Nadav Har'El                        |       Friday, Mar 7 2003, 3 Adar II 5763
[EMAIL PROTECTED]             |-----------------------------------------
Phone: +972-53-245868, ICQ 13349191 |I put a dollar in one of those change
http://nadav.harel.org.il           |machines. Nothing changed.

--------------------------------------------------------------------------
Haifa Linux Club Mailing List (http://www.haifux.org)
To unsub send an empty message to [EMAIL PROTECTED]


Reply via email to