5 ms·
Go executables are statically linked. It makes deployment a breeze. I think you overestimate how much saving you get from dynamically linking libc. Each exec
by jnwatson 6y ago
Go executables are statically linked. It makes deployment a breeze.
I think you overestimate how much saving you get from dynamically linking libc. Each executable uses only a small portion of libc, so the average savings is going to be in the handful of kilobytes per executable.
- glouwbug 6y agoTrue, but a couple github imports and 10 lines of code generates a 100mb binary. But, to be fair, I guess we're okay with shipping huge binaries now a days because we're literally shipping whole environments with docker anyway.
- yjftsjthsd-h 6y agoTo be fair, you're not really supposed to be shipping a full system in a docker image if you can help it; you're supposed to layer your application over the smallest base that will support it (whether that's scratch, distroless, alpine, or a minimal debian base). Of course, I'll be the first to agree that "supposed to" and reality have little in common; if I had a dollar for every time I've seen a final image that still included the whole compiler chain...
- majewsky 6y agoIn my experience, most who build fat images with the compiler chain and everything do so because they're simply not aware that multi-stage builds are a thing now.
- yjftsjthsd-h 6y agoYep. And just general awareness of how Docker works and how to best use it. And that's not a knock on them; it's a whole topic unto itself, and lots of these folks are developers who are just trying to get their stuff working without having to go off and learn all about Docker, and I have a hard time blaming them for that. Which, of course, is why they keep a handful of us sysadmin folks on staff to help tidy up;)
- andoma 6y agoIn theory yes. However, in practice static linking with glibc pulls in a lot of dead weight, musl comes to the rescue though: test.c: int main(int argc, char **argv) { printf("hello world\n"); return 0; } Dynamic linking (glibc): $ gcc -O2 -Wl,--strip-all test.c $ ls -sh a.out 8.0K a.out Static linking (glibc): $ gcc -O2 --static -Wl,--strip-all test.c $ ls -l a.out 760K a.out Static linking (musl): $ musl-gcc --static -O2 -Wl,--strip-all test.c $ ls -sh a.out 8.0K a.out
- jart 6y agoStatic linking (https://github.com/jart/cosmopolitan https://github.com/jart/cosmopolitan) jart@debian:~/cosmo$ make -j12 CPPFLAGS+=-DIM_FEELING_NAUGHTY MODE=tiny o/tiny/examples/hello.com jart@debian:~/cosmo$ ls -sh o/tiny/examples/hello.com 20K o/tiny/examples/hello.com Note: Output binary runs on Windows, Mac, and BSD too.
- saagarjha 6y agoI hope you can forgive me for asking, but what exactly is this (cosmopolitan)? It looks interesting but I can’t really tell what it’s trying to be.
- temac 6y ago> Go executables are statically linked. It makes deployment a breeze. But what are we comparing to what then ? A few custom Go applications, compared to whole classic Linux distros, on which deployment is both not really the same thing, but still a breeze ? So yeah, to different needs, different tools.