4 ms·
I suppose there's no option to link statically against glibc because of the implications with LGPL (static linking triggers additional license clauses).
by tyingq 7y ago
I suppose there's no option to link statically against glibc because of the implications with LGPL (static linking triggers additional license clauses).
- richardwhiuk 7y agoI think it's mainly that glibc has poor support for statically linking.
- tyingq 7y agoAh, okay. Searched a bit, and it apparently requires you to find your own with dns client lookup library, avoid dlopen(), set GCONV_PATH, and so on.
- aidenn0 7y agoFor a long time glibc was maintained by someone who was of the opinion that if you wanted to statically link 3rd party libraries, then you shouldn't be allowed to build binaries.
- asveikau 7y agoIt's interesting because there is an opposite cult (I believe some prominent plan9 and go people are adherents) that believes dynamic linking should literally not be a thing. I even recall reading some essays that introduction of a dynamic linker was some kind of tragic downfall in Unix history. I think the truth is that both have costs and benefits. Dynamic linking is good for security patches, memory and disk usage. But it creates new opportunities for problems, for example ABI breakage becomes more significant of a problem and needs a lot of care to avoid. People distributing code, be it to end users or app stores or on servers with things like chroots, jails and containers, need to carry their dependencies anyway negating some of the benefits.
- loeg 7y agoIn general, do not expect dlopen() to work in statically linked programs (in any libc).
- deleted 7y ago[deleted]
- ashtonkem 7y agoAlso, it’s extremely common to leave libc dynamically linked for operational reasons. It’s my understanding that by default Go statically links everything but libc.
- tyingq 7y agoSure. Wasn't suggesting it as the default. Just curious why it wasn't an option.
- ashtonkem 7y agoI always assumed that that’s done for portability reasons, since libc deals with a lot of os specific details.
- loeg 7y agoSymbol versioning for backwards compatibility is only possible with dynamic libraries, for example. Static linking is of course always backwards compatible for a given binary artifact, but is significantly bloatier and makes it harder to apply security fixes.
- loeg 7y agoGo doesn't link libc at all, generally.
- asveikau 7y agoA key phrase I found googling "rust system allocator" is "provided by the operating system". On Unix, a dynamically linked libc would certainly fit the bill. On Windows the C runtime is technically provided by the compiler and its runtime, so even that would make sense why they use HeapAlloc from Win32. (It's also common on Windows for different DLLs in the same process to have separate, incompatible libc mallocs, so I guess it might solve that too.)