There are many sources on the web telling you how to write small C code. But different versions of gcc produce different code sizes. I made a small test with different gcc-versions:
With each gcc I built the dietlibc-0.30 with standard dietlibc options/flags and got the following file sizes of bin-i386/dietlibc.a:
Then I used each compiled dietlibc with each gcc to compile some small tools. The executables were stripped ("strip -s -R .note -R .comment"). The matrix values are the sums of the tools file sizes:
diet323 | diet333 | diet335 | diet336 | diet346 | diet410 | |
---|---|---|---|---|---|---|
gcc323 | 26300 | 24060 | 24140 | 24204 | 24172 | 26180 |
gcc333 | 24108 | 23816 | 23904 | 23816 | 23940 | 25896 |
gcc335 | 24120 | 23828 | 23916 | 23828 | 23952 | 25908 |
gcc336 | 24280 | 24016 | 24112 | 24016 | 24176 | 26124 |
gcc346 | 24172 | 23880 | 23968 | 23880 | 23972 | 25960 |
gcc410 | 24356 | 24064 | 24152 | 24064 | 24188 | 26144 |
Short note about the old-fashioned gcc-2.95.3: The file sizes I got with it are even inferior to gcc-3.2.3 and nearly bad as gcc-4.1.0.
A last test shows file sizes when compiling a tool with gcc-3.4.6:
diet -Os gcc -Os; strip | 3776 |
diet -Os gcc -Os | 7358 |
diet gcc -Os | 7418 |
diet gcc -O2 | 7578 |
gcc -Os | 7730 |
gcc -O2 | 7854 |
gcc -O2 -g | 13966 |
gcc -Os -static | 550334 |
Last note: With sstrip or elftrunc (dietlibc contrib) you can strip symbols and section headers from ELF executables to get smaller files.
http://www.tuxad.com/codesize.html 2009-05-16
Copyright © 2004-2024 Frank W. Bergmann
Alle Rechte vorbehalten.