4 ms·
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 agai
by Spivak 7y ago
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.
- paulddraper 7y agoStatically linking libc is harder than dynamically linking it, but certainly easier than rewriting it.
- yencabulator 7y agoGood 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.
- saagarjha 7y agoWhy? I see no reason you couldn’t on platforms with a stable syscall ABI, other than the standard reasons against static linking.
- thu2111 7y agoIt 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.
- pjmlp 7y agoThe ISO C standard library has no such expectations regarding external files.
- deleted 7y ago[deleted]
- aratakareigen 7y agoStatically 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).