RE: Very slow clang kernel config ..

From: David Laight
Date: Sun May 02 2021 - 07:35:25 EST


From: Adrian Bunk
> Sent: 02 May 2021 10:31
>
> On Sat, May 01, 2021 at 09:32:25AM -0700, Linus Torvalds wrote:
> >...
> > Yes, it can save on disk use, but unless it's some very core library
> > used by a lot of things (ie particularly things like GUI libraries
> > like gnome or Qt or similar), the disk savings are often not all that
> > big - and disk is cheap. And the memory savings are often actually
> > negative (again, unless it's some big library that is typically used
> > by lots of different programs at the same time).
> >...
> > I think people have this incorrect picture that "shared libraries are
> > inherently good". They really really aren't. They cause a lot of
> > problems, and the advantage really should always be weighed against
> > those (big) disadvantages.
> >...
>
> Disk and memory usage is not the biggest advantage.
>
> The biggest advantage of shared libraries is that they enable
> distributions to provide security fixes.
>
> Distributions try hard to have only one place to patch and one package
> to rebuild when a CVE has to be fixed.
>
> It is not feasible to rebuild all users of a library in a
> distribution every time a CVE gets published for a library.

Absolutely.
You'd also need to rebuild every application that might include
the static version of the broken function.
Good luck finding all those on a big install.

OTOH just splitting a compiler into multiple shared objects
that have no other use is, as Linus said, stupid.

Building shared libraries requires the same control as building
the kernel.
The user interface mustn't change.
You can add new functions, but not change any existing ones.
This is easy in C, difficult in C++.

Since PLT lookups can only handle code, you really don't want
data areas shared between the program and library.
If the size ever changes 'horrid things (tm)' happen.

We compile any shared libraries with -fvisibility=hidden and
mark any entry points with __attribute__((visibility("protected"))).
This means that calls with a library are simple PC-relative
and only the entry points are visible outside.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)