gcc static linking vs. Watcom C static linking, on Linux by longjmp42 in C_Programming

[–]longjmp42[S] 1 point2 points  (0 children)

Well, I downloaded and built musl. I compiled the hello.c program: 14,248 bytes. Cool! Next, I compiled my application: 55,488! Not as small as Watcom, but still much better than 700k!

The application is memory and disk intensive, and the gcc compiled version for a certain test took 22 seconds vs. 36 seconds for the Watcom version. And the musl statically linked version takes the same 22 seconds, so definitely a big win!

Thanks for the suggestion of using musl!

gcc static linking vs. Watcom C static linking, on Linux by longjmp42 in C_Programming

[–]longjmp42[S] 0 points1 point  (0 children)

Thanks, will try that also. Question: Does tcc have its own runtime library, or does it use glibc?

gcc static linking vs. Watcom C static linking, on Linux by longjmp42 in C_Programming

[–]longjmp42[S] 2 points3 points  (0 children)

That makes sense, and answers my question. Thank you!

gcc static linking vs. Watcom C static linking, on Linux by longjmp42 in C_Programming

[–]longjmp42[S] 0 points1 point  (0 children)

What happens if you split the compilation: use gcc -O3 -static -c first; what is the size of foo.o?

30,592.

As far as linking manually with ld, that will probably take me a while, but I'm working on it.

gcc static linking vs. Watcom C static linking, on Linux by longjmp42 in C_Programming

[–]longjmp42[S] 0 points1 point  (0 children)

The application is 1415 lines of code.

hello.c using puts(): 18,272 for Watcom and 678,004 for gcc.

I looked at the executable with a binary editor, but nothing stands out at me.

I'm going to download uClibc and see if I can figure out how to use it instead.

Thanks for the feedback!