gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gm2] Minimal libraries


From: Waldek Hebisch
Subject: Re: [Gm2] Minimal libraries
Date: Sat, 27 Jun 2009 16:25:52 +0200 (CEST)

Gaius Mulley wrote:
> address@hidden writes:
> 
> > Gnu C, Gnu C++, and Critical Mass Modula 3 all produce "hello world"
> > binaries of 6-8Kb stripped, where Gnu Modula 2 produces 110Kb stripped.
> > I doubt that the differences are due to lack of link time optimisations,
> > tho' they may be.  Anyway, thanks.
> >
> > Will
> 
> Hi,
> 
> C, C++ and gm2 all use the same middle and backend.  The difference is
> the way the libraries are organised.  For example glibc is composed of
> 6244 C files, most of which consist of one function per object, thus
> when linking against glibc.a the linker pulls in only an object
> matching a function, (hence a pretty minimal binary).

The last time I tried _statically_ linking with glibc gave me about
90 kb.  I think that days of 4kb static executables are gone, all
really small "hello world" programs from Gnu use dynamically
linked libraries.

It is possible to get some link optimizations with current compiler.
IIRC the '-ffunction-sections' option to the compiler marks function
boundaries in the object files, so that with proper linker option
one can link in only needed functions.  However, few years ago
(when I checked this) linker could do this only for completely
static build.  So the price was static linking to glibc, bringing
about 90 kb of routines from there and defeating the purpose.
New release of binutils was supposed to fix problem of mixing
per-function sections and shared libraries, so anybody interested
should probably re-check.

BTW: LTO is unlikely to help for library problems.  LTO can better
optimize programs and inline functions between files, but
unless _all_ needed functions are inlined (unlikely) core problem
will remain.

-- 
                              Waldek Hebisch
address@hidden 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]