Thanks for this. It's amazing how much of OSv's kernel size was actually
crap that we never noticed :-)

I think the solution not to "whole-archive" libgcc.a is the correct one:

Basically, the application - a shard library - can only rely on OSv
providing what on a normal Linux system is provided by other shared
libraries. So OSv provides libstdc++.so (by whole-archive of libstdc++.a)
and it provides libgcc_s.so. But it does NOT need to provide stuff in some
static library like libgcc.a, because a shared object cannot assume such a
thing anyway! Rather, if code in a shared object wants to use stuff from
libgcc.a, it is *linked* with libgcc.a, which would cause code from
libgcc.a to be included *in* the object.

So I think not whole-archive'ing libgcc.a isn't just a good "I hope it
works" space-saving measure, I think it's actually the right thing to do.
And we should include the full and much smaller libgcc_s.so in the image -
as we already do.

--
Nadav Har'El
n...@scylladb.com





On Sat, Oct 13, 2018 at 7:26 AM Waldemar Kozaczuk <jwkozac...@gmail.com>
wrote:

> This patch disables linking libgcc.a library with
> --whole-archive in order to make resulting loader-stripped.elf
> 2.5 MB smaller. The libgcc.a contains number of functions and huge tables
> of numbers that are part of Decimal Float Library
> (
> https://gcc.gnu.org/onlinedocs/gccint/Decimal-float-library-routines.html#Decimal-float-library-routines
> ),
> which are not used by OSv kernel.
>
> Any potential side-effects caused by this patch have been
> tested against almost 20 different apps including
> java, python, golang, rust, MySQL and redis and no
> issues have been found.
>
> Size of kernel (ROFS version) before this patch:
> 9.2M    loader-stripped.elf
> 6.2M    lzloader.elf (33% reduction)
>
> Size of kernel (ROFS version) after this patch:
> 6.7M    loader-stripped.elf
> 3.9M    lzloader.elf (42% reduction)
>
> These are related patches:
> c9e61d4a45d88d8c8e79cd52fbcd38b91b291d5e
> be565320c082c00069614c850d29b42831b3dea6
>
> Signed-off-by: Waldemar Kozaczuk <jwkozac...@gmail.com>
> ---
>  Makefile | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 44a86c01..2270206b 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1869,9 +1869,9 @@ $(out)/loader.elf: $(stage1_targets)
> arch/$(arch)/loader.ld $(out)/bootfs.o
>                 -Bdynamic --export-dynamic --eh-frame-hdr
> --enable-new-dtags \
>             $(^:%.ld=-T %.ld) \
>             --whole-archive \
> -             $(libstdc++.a) $(libgcc.a) $(libgcc_eh.a) \
> +             $(libstdc++.a) $(libgcc_eh.a) \
>               $(boost-libs) \
> -           --no-whole-archive, \
> +           --no-whole-archive $(libgcc.a), \
>                 LINK loader.elf)
>         @# Build libosv.so matching this loader.elf. This is not a separate
>         @# rule because that caused bug #545.
> --
> 2.17.1
>
> --
> You received this message because you are subscribed to the Google Groups
> "OSv Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to osv-dev+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to