| From: philip at imageviewer.co.uk
| Date: Wed, 25 May 2005 20:19:58 +0100
|
| Does any one remember Coral? [ ... ]
yes. didn't use it, tho.
anyone remember BLISS? another systems programming language
some DEC O/Ses were written in. only language I know where
there is an operator to make a reference an L-value (or was
it an R-value, I don't recall now! ;-( ).
| It takes compiled 'C' 65K to print "Hello World". [ ... ]
twaddle!
the Unix 7th Edition kernel needed < 128KiB, and
a typical “Hello world” still, today, needs < 200
_bytes_. not KiB, just bytes. (evidence below.)
the size bloat Philip is hinting at (which does
exist — see below) is, AFAIK, mostly due to NLS.
=====(cut here and below)=====(results of test script below)=====
+ gcc -O2 h.c
Hello, world!
text data bss dec hex filename
944 256 4 1204 4b4 ./a.out
linux-gate.so.1 => (0xffffe000)
libc.so.6 => /lib/tls/libc.so.6 (0x4003b000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
+ gcc -O2 -static h.c
Hello, world!
text data bss dec hex filename
373104 3152 4448 380704 5cf20 ./a.out
not a dynamic executable
+ diet gcc -O2 -nostdinc h.c
Hello, world!
text data bss dec hex filename
159 0 12 171 ab ./a.out
not a dynamic executable
+ diet gcc -O2 -nostdinc -static h.c
Hello, world!
text data bss dec hex filename
159 0 12 171 ab ./a.out
not a dynamic executable
+ /opt/i386-linux-uclibc/usr/bin/gcc -O2 h.c
Hello, world!
text data bss dec hex filename
729 200 4 933 3a5 ./a.out
libc.so.0 => /opt/i386-linux-uclibc//lib/libc.so.0 (0x40007000)
ld-uClibc.so.0 => /opt/i386-linux-uclibc//lib/ld-uClibc.so.0 (0x40000000)
+ /opt/i386-linux-uclibc/usr/bin/gcc -O2 -static h.c
Hello, world!
text data bss dec hex filename
842 108 32 982 3d6 ./a.out
not a dynamic executable
=====(cut here and above)=====(results of test script below)=====
dietlibc is the clear winner, requiring only 171
bytes (decimal).
=====(cut here and below)=====(test size of hello world in C)=====
#!/bin/bash
rm -f h.c
cat >h.c <<\EOF
#include <unistd.h>
int
main(void) {
static const char hi[] = "Hello, world!\n";
return (write(1, hi, sizeof(hi)-1) != sizeof(hi)-1);
}
EOF
Try() {
echo -E "+ $*"
rm -f a.out
"$@" && ./a.out && size ./a.out && ldd ./a.out
}
Try gcc -O2 h.c
Try gcc -O2 -static h.c
Try diet gcc -O2 -nostdinc h.c
Try diet gcc -O2 -nostdinc -static h.c
Try /opt/i386-linux-uclibc/usr/bin/gcc -O2 h.c
Try /opt/i386-linux-uclibc/usr/bin/gcc -O2 -static h.c
=====(cut here and above)=====(test size of hello world in C)=====
offhand, I don't know how to not pick up
the NLS stuff when using GNU glibc, but I
_think_ it is possible? (the main reason
for thinking the bloat is mostly due to
NLS is by looking at the symbol table.)
cheers!
-blf-
--
Experienced (20+ yrs) kernel/software Eng: | Brian Foster Montpellier,
• Unix, embedded, &tc; • Linux; • doc; | blf at utvinternet.ie FRANCE
• IDL, automated testing, process, &tc. | Stop E$$o (ExxonMobile)!
Résumé (CV) http://www.blf.utvinternet.ie | http://www.stopesso.com
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!