3 ms·
I know the ability exists, but I'm pretty sure that it's not exactly easy to get it working. Last time I tried, it immediately failed because my distribution wa
by yjftsjthsd-h 7y ago
I know the ability exists, but I'm pretty sure that it's not exactly easy to get it working. Last time I tried, it immediately failed because my distribution wasn't shipping .a files (IIRC) for my installed libraries. There's a lot of little things that don't quite work because nobody's using them so they're harder to use so nobody uses them...
- alexeldeib 7y agoYep, exactly this. And quirks of glibc and friends make fully static compilation likely to produce odd failures, unfortunately.
- saagarjha 7y agoGlibc does not really support static linking.
- alexeldeib 7y agoKind of my point — so much software depends on it, it’s difficult to statically link more things.
- needs 7y agoMusl is a pretty good replacement, I have been using it for years without any troubles.
- alexeldeib 7y agoI like Musl, but it is a source of pain at times too: https://github.com/kubernetes/kubernetes/issues/64924 https://github.com/kubernetes/kubernetes/issues/64924 https://github.com/kubernetes/kubernetes/issues/33554 https://github.com/kubernetes/kubernetes/issues/33554 Admittedly you could put that on the Kubernetes folks, but the same problem doesn't exist with glibc.
- Hello71 7y agoI don't see how zig cc would help with that. Your distribution probably also doesn't ship all the source files for your packages either, and there's no other way to statically link.
- LessDmesg 7y agoGentoo does.
- Hello71 7y agoI've used Gentoo for almost a decade now, and no, that's not true. emerge doesn't just randomly keep source files on disk, and certainly not in a form easy to link to. In fact, Gentoo is worse than Debian for static linking, because not all packages have IUSE=static-libs. If it doesn't, you need to patch that ebuild and potentially many dependencies to support it. On the other hand, on Debian, the standard is for -dev packages to come with both headers and static libraries.
- Reelin 7y agoIt's easy to get working provided that you compile _everything_ from source. You can either omit glibc from this, or accept that it will still dynamically load some stuff at runtime even when "statically" linked, or switch to musl. A nice benefit is that LTO can then be applied to the entire program as a whole.