[Haifux] Huge file with static linking
Hello all. For my own peculiar reasons, I need to compile something statically. This might appear to be a trivial question, but after quite a few trials it seems like I can't find the right words to ask google with. So I ask you. Here is my program. I hope you can inderstand what it does, despite lack of comments... ;) #include stdio.h int main() { puts(Hello, world\n); } And here's my little session: [EMAIL PROTECTED] helloworld]$ gcc -static -o hello hello.c [EMAIL PROTECTED] helloworld]$ ls -l hello -rwxrwxr-x1 eli eli441940 Mar 6 21:05 hello* [EMAIL PROTECTED] helloworld]$ As you can see, this little program takes 440 kB. Hmmm. Why does this look too much to me? I mean, even without glibc and other wonders, surely one could implement puts with less? Any suggestions of how to shrink this down to some normal size? Thanks in advance, Eli -- Haifa Linux Club Mailing List (http://www.haifux.org) To unsub send an empty message to [EMAIL PROTECTED]
Re: [Haifux] Huge file with static linking
On Thu, Mar 06, 2003 at 09:22:46PM +0200, Eli Billauer wrote: And here's my little session: [EMAIL PROTECTED] helloworld]$ gcc -static -o hello hello.c You forgot -O2, and you forgot to give your machine a name! [EMAIL PROTECTED] helloworld]$ ls -l hello -rwxrwxr-x1 eli eli441940 Mar 6 21:05 hello* [EMAIL PROTECTED] helloworld]$ You forgot to run strip(1). Any suggestions of how to shrink this down to some normal size? strip(1). Anything beyond that requires assembly and careful massaging. Thanks in advance, We aim to please. -- Muli Ben-Yehuda http://www.mulix.org pgp0.pgp Description: PGP signature
Re: [Haifux] Huge file with static linking
Muli Ben-Yehuda wrote: You forgot -O2, and you forgot to give your machine a name! Actually, neither. I figured out that -O2 didn't help. As for my machine's name, it's like getting a dog who already responds to a name. You don't change it. ;) You forgot to run strip(1). Hmmm. I forgot to mention that I already tried that. [EMAIL PROTECTED] helloworld]$ gcc -O2 -static -o hello hello.c [EMAIL PROTECTED] helloworld]$ ls -l hello -rwxrwxr-x??? 1 eli? eli??? 441940 Mar? 6 21:27 hello* [EMAIL PROTECTED] helloworld]$ strip -s hello [EMAIL PROTECTED] helloworld]$ ls -l hello -rwxrwxr-x??? 1 eli? eli??? 373248 Mar? 6 21:27 hello* Any suggestions of how to shrink this down to some normal size? strip(1). Anything beyond that requires assembly and careful massaging. Really? This is the end of it? How come /sbin/insmod.static is so small? What do "they" know that I don't? ? ? Eli
Re: [Haifux] Huge file with static linking
On Thu, Mar 06, 2003 at 09:45:36PM +0200, Eli Billauer wrote: strip(1). Anything beyond that requires assembly and careful massaging. Really? This is the end of it? How come /sbin/insmod.static is so small? What do they know that I don't? Do you know for a fact that insmod.statis was compiled with -static? I was under the impression that strip does a good job even when using -static. Apparently, it doesn't. I'll think about it, and if anyone knows how to get the binary's size down after strip is done with it, do tell. -- Muli Ben-Yehuda http://www.mulix.org pgp0.pgp Description: PGP signature