6 ms·
$ musl-gcc test.c -O2 $ ls -laB a.out .rwxr-xr-x 15,776 roblabla 15 Feb 16:49 a.out $ musl-gcc test.c -O2 -ffunction-sections -fdata-sections -Wl,--
by roblabla 8y ago
$ musl-gcc test.c -O2
$ ls -laB a.out
.rwxr-xr-x 15,776 roblabla 15 Feb 16:49 a.out
$ musl-gcc test.c -O2 -ffunction-sections -fdata-sections -Wl,--gc-sections -static
$ ls -laB a.out
.rwxr-xr-x 17,864 roblabla 15 Feb 16:48 a.out
Static linking with MUSL added 2088 bytes of overhead. Likely only the code that was needed.
It's true that without proper care, you might end up importing a whole lot of useless stuff though.
- tom_mellior 8y agoThat's great, but can you now demonstrate the same with Qt and KDE, as you claimed above? FWIW, I believe (but could very well be wrong) the reason that this works this well with MUSL is that every function is defined in its own translation unit. I doubt that Qt and KDE do that.
- nwmcsween 8y agoThe library/project has to be designed right. Musl has dummy references that make static linking work without pulling in a bunch of junk. This is very much a language/project issue and I wish more languages actually looked at the huge mess of dep graphs that are needed for simple programs.