3 ms·
In 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, cha
by andoma 6y ago
In 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.