RE: Very slow clang kernel config ..

From: David Laight
Date: Wed May 05 2021 - 10:13:21 EST


From: Miguel Ojeda
> Sent: 05 May 2021 14:54
>
> On Wed, May 5, 2021 at 1:06 PM David Laight <David.Laight@xxxxxxxxxx> wrote:
> >
> > The problem isn't the packages that come with the distribution.
>
> My question was in the context of Adrian's emails who were mentioning
> issues for Linux distribution etc.
>
> > The problem is 3rd party programs supplied as binaries.
> > They have 2 big requirements:
> > 1) The same binary will run on all distributions (newer than some cutoff).
>
> This is fine with the "everything statically linked" model.

No it isn't.
It may work for simple library calls (like string functions)
that you can write yourself, and things that are direct system calls.
But it falls fowl of anything complicated that has to interact
with the rest of the system.

> > 2) Any serious bug fixes in system libraries get picked up when the
> > distribution updates the library.
>
> For 3rd party software, this is usually done through an auto-update
> mechanism of some kind.

I can already see a held of pigs flying...

> And since the vendor typically provides
> everything, including dependencies (even libc in some cases!), they
> can afford to statically link the world.

That might work if they are supplying all the applications that run
of a given system - and probably including the kernel as well.

> That model, of course, has issues -- the vendor may go out of
> business, may be slow with security updates, etc.

Many years ago the company I worked for found that the unix 'utmpx'
file was getting corrupted (due to incorrect locking).
The functions had been places in an archive part of libc (for
various reasons).
Getting the fix onto the customers machine (we were the OS vendor)
involved determining which applications from 3rd (4th?) parties
had been linked with the broken code and then applying enough
'gentle persuasion' to get them to relink the offending programs.
Even this can be problematic because the source control systems
of some companies isn't great (it is probably better these days).
But getting the 'previous version' rebuilt with a new libc.a
can be very problematic.

> But this is all orthogonal to Rust -- I replied mainly because it was
> mentioned that Rust brought new issues to the table, which isn't true.
>
> > There is also the possibility that the implementation of some
> > function differs between distributions.
> > So you absolutely need to use the version from the installed system
> > not whatever was in some static library on the actual build machine.
> >
> > Both of these need stable ABI and shared libraries.
>
> Not really. If you go for the "statically linked" model for your
> application, you only need to care about the syscall layer (or
> equivalent higher-level layers in e.g. Windows/macOS).

No because there are messages sent to system daemons and file
formats that can be system dependant.
Not everything is a system call.

>
> If you trust vendors a bit, you can instead go for "statically linked
> except for major system libraries" (like libc or libm in Linux). This
> is what Rust does by default for the glibc x86_64 target.
>
> Given that nowadays statically linking is convenient, affordable and
> improves performance, it seems like the right decision.
>
> > Remember, as far as userspace is concerned, foo.h is the definition
> > for 'foo' and foo.so is the current implementation.
> > (yes, I know a little bit of info is taken from foo.so on the build
> > system - but that ought to be absolutely minimal.)
>
> No, that is only the C model for shared libraries.
>
> C++ has had templates for decades now and no "C++ ABI" so far covers
> them. Thus, if you want to provide templates as a library, they cannot
> be "pre-compiled" and so the implementation is kept in the header.
>
> This actually turned out to be quite convenient and nowadays many
> libraries are developed as "header-only", in fact. Moreover, recently
> the C++ standard introduced new features that simplify taking this
> approach, e.g. C++17 `inline` variables.

Remind be to request our management to let me remove all the C++
from most of our programs.
None of them actually need it, the reasons for C++ aren't technical.

if you want to see something really horrid look at the inline
destructor code for iostringstream.

And don't let me look at the code for CString either.

> Rust has the same issue with generics, but improves the situation a
> bit: there is no need to reparse everything, every time, from scratch,
> for each translation unit that uses a library with templates (which is
> quite an issue for C++, with big projects going out of their way to
> reduce the trees of includes).

That sounds like it has all the same problems as pre-compiled headers.

David

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