An interesting comparison.

[~/ellcc/test/source] main% cat printf.c
#include <stdio.h>
int main(int argc, char** argv)
{
     printf("printf with the string \"%s\"\n", "my string");
}
[~/ellcc/test/source] main% ~/ellcc/ellcc/x86-elf-ecc printf.c
[~/ellcc/test/source] main% ./a.out
printf with the string "my string"
[~/ellcc/test/source] main% size a.out
    text data bss dec hex filename
   56459 3032 52 59543 e897 a.out
[~/ellcc/test/source] main% gcc -static printf.c
[~/ellcc/test/source] main% ./a.out
printf with the string "my string"
[~/ellcc/test/source] main% size a.out
    text data bss dec hex filename
  558317 1928 6948 567193 8a799 a.out
[~/ellcc/test/source] main%

Both a.out files are statically linked.
x86-ecc uses a libc based on newlib, gcc uses glibc (of course).
Is glibc really that ... big?

-Rich

Hello Rich,

To answer your question: Yes.

To answer the question better: It depends somewhat on the dependencies that all get linked in by other dependencies. I'm inclined to think that NewLib, being designed for embedded controller use is quite compact compared to just about anything else.

Since most platforms implement the runtime library as a shared object or some equivalent, it doesn't matter much how big it is since it only loads into memory once regardless to how many times it is used. The moral of the story is: Statically link only if your platform doesn't support shared objects.

--Sam

From: Richard Pennington <rich@pennware.com>
To: LLVM Developers Mailing List <llvmdev@cs.uiuc.edu>
Sent: Sunday, August 9, 2009 8:39:08 AM
Subject: [LLVMdev] An interesting comparison.

-snip-