On OpenBSD, there is a rule that you link with libc to interface with the kernel, because that’s where the syscall stubs live. This causes a great deal of consternation for partisans of other languages, because they don’t want to link “all of libc”. But when does anything link all of libc?
quick proof
$ ls -l /bin/ls /usr/lib/libc.a
-r-xr-xr-x 1 root bin 297448 Mar 20 2024 /bin/ls
-r--r--r-- 1 root bin 8347256 Mar 20 2024 /usr/lib/libc.a
ls is statically linked, yet clearly smaller than libc.a. It is not linked with all of libc. QED.
If you are statically linking with libc just to get open and mmap and related symbols, and somehow all of libc shows up in your program, that’s a deficiency of your dogshit linker.
ar
What’s in libc.a anyway? It’s an ar archive, which is conceptually not so different from tar I guess. It’s a big pile of object files collected together. Like tar, it has options
1 Comment
gnabgib
Discussion (19 points, 8 hours ago, 11 comments) https://news.ycombinator.com/item?id=43028877