Conversation

You know how I always say picolibc isn't a Linux C library because it doesn't do all of the fancy Linux stuff? Well, it turns out you don't need much to get a semi-functioning system.

$ size test-hello-picolibc test-hello-glibc
text data bss dec hex filename
3632 144 4656 8432 20f0 test-hello-picolibc
645697 23704 22576 691977 a8f09 test-hello-glibc

I blame Kees Cook for nerd-sniping me on this one.

https://github.com/picolibc/picolibc/tree/native-linux

3
5
1

@keithp With musl, gcc -Os -static hello.c, on stock Alpine x86_64:

text data bss dec hex filename
3893 344 1744 5981 175d a.out

1
0
0

@dalias @keithp

Fuzix (standard C library, 8085 CPU, not even a fancy optimizing compiler)

base text data bss size hex filename
100 10c5 5c 318 5177 1439 a.out

gcc on 6809 or HC11 is way way smaller but it turns out gcc seems to know to swap the printf call magically for something else in this case.

1
0
1

@etchedpixels @dalias yeah, gcc converts printf("hello world\n") into puts("hello world");

That's one of the numerous optimizations present in "hosted" mode, which is why I always tell people to get rid of -ffreestanding when building with a full C library.

Btw, on armhf, hello world is way smaller than on x86_64:

$ size test-hello-armhf
text data bss dec hex filename
1520 76 4624 6220 184c test-hello-armhf

0
0
1
@keithp Then Linux-kernel tools/include/nolibc will provide you with even more irritation!!! ;-)
1
0
0
@keithp Impressive. Reminds me about those Rust binaries...
0
0
0
@keithp Right you are and I am glad that you also appreciate it!
0
0
1