News for hackers. Stuff that matters.
Re:Why are my Go executable files so large? by Spivak on Sunday December 29, 2019 @05:21PM (#21908989)
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.
Re:Why are my Go executable files so large? by paulddraper on Sunday December 29, 2019 @05:52PM (#21909172)
Statically linking libc is harder than dynamically linking it, but certainly easier than rewriting it.
Re:Why are my Go executable files so large? by yencabulator on Thursday January 02, 2020 @12:29PM (#21937466)
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.
Re:Why are my Go executable files so large? by aratakareigen on Monday December 30, 2019 @03:55PM (#21916646)
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).
Re:Why are my Go executable files so large? by saagarjha on Monday December 30, 2019 @02:54AM (#21911585)
Why? I see no reason you couldn’t on platforms with a stable syscall ABI, other than the standard reasons against static linking.
Re:Why are my Go executable files so large? by thu2111 on Monday December 30, 2019 @04:49AM (#21912192)
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.

Re:Why are my Go executable files so large? by pjmlp on Monday December 30, 2019 @08:02AM (#21913061)
The ISO C standard library has no such expectations regarding external files.