Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You could statically link in libc and get the same effect.


Statically linking libc is it’s own minefield. It can and is done but even if you statically link everything else you should almost always dynamically link against your platform’s libc.


Statically linking libc is harder than dynamically linking it, but certainly easier than rewriting it.


Good thing we don't want to use much of libc functionality from Go, so nobody needs to reimplement all of it. It's not like people would be begging to call strcpy. All that's needed is the syscalls.


Statically linking a libc seems equivalent to statically linking Go's standard library, but with a whole lot less effort (on the part of the Go developers, that is).


Why? I see no reason you couldn’t on platforms with a stable syscall ABI, other than the standard reasons against static linking.


It depends on the libc.

glibc doesn't really "want" to be statically linked. It can be done sometimes, depending on how it's used, the phase of the moon and so on, but breaks from time to time until it's repaired.

Some of the issues are fundamental. For instance the dynamic linker is a part of the C libraries. If you statically link libc and then dynamically load another shared library, you can end up with two copies of the C libraries loaded at once.

The C library expects various external files to be found on disk, in a format that isn't totally forwards/backwards compatible. That's reasonable when things are dynamically linked because the linker and C library abstract the developer from format changes. If you statically link you should really statically link the data files too, but the C toolchain has no provision for that.


The ISO C standard library has no such expectations regarding external files.


Except glibc does not really support static linking of you want network support.


glibc is just one possible ISO C implementation with lots of extra stuff on top.


Says someone who has never actually tried to do that. You can statically link with Musl. But you can't really statically link with Glibc.


Technically speaking OP only suggested statically linking (a) libc, not glibc specifically, and musl is a libc.


Not sure what’s up with the combative tone? FWIW, I work as an operating systems developer. We sell several products incorporating a few in house libc variants. They are most certainly statically linked.


You can, it just might do some strange things when dealing with iconv.


You'd still have to get a static libc (not usually preinstalled), possibly compile it for a different os/architecture..


An issue here is that statically linking against glibc is generally regarded as a poor idea and I’ve seen a couple non trivial programs that refuse to run with other libc’s.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: