Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20201102153011.GT534@brightrain.aerifal.cx>
Date: Mon, 2 Nov 2020 10:30:11 -0500
From: Rich Felker <dalias@...c.org>
To: Chen Wang <unicorn_wang@...look.com>
Cc: musl <musl@...ts.openwall.com>
Subject: Re: Re: [Question] somequestions about kernel header files for musl?

On Mon, Nov 02, 2020 at 09:28:58PM +0800, Chen Wang wrote:
> Thank you, Szabolcs.
> 
> But as I understand, libc has dependency on os's api, and musl is
> designed target for linux, right? Why musl provide a set of header
> files without directly use user header files from linux?

The kernel headers are not safe to include from libc ones. They're not
namespace-safe, for example -- in other words they may and often do
use identifiers that are not reserved for the implementation. Also
they may define certain types that are suitable for the linkage
between userspace and kernel but not between the application and
standard library, for instance because the version of the type used in
the user-kernel linkage is not POSIX-conforming. For example struct
msghdr and cmsghdr have certain fields as long rather than int in the
kernel versions, and all the sysvipc types lack space for 64-bit
time_t on 32-bit archs.

Further, even if the kernel headers/types were all usable, using them
would require that users have present at build and run time the latest
version of the kernel headers. For example, a version of the syscall
list lacking the time64 syscalls would cause 32-bit musl 1.2.0+ to be
completely miscompiled. Note in particular that musl does *not* want
to know the set of syscalls, network features, etc. present on the
kernel you vaguely intend to be using at runtime, but rather the
*full* API/ABI it can potentially use on a new enough kernel (and it
handles presence or absence of that at runtime).

> I also wonder by current solution for musl, how to keep alignment
> with kernel, I mean if linux changes some in uapi, would musl have
> to make the corresponding changes to catch up with it?

It can't be changed because it's part of ABI. New types/interfaces can
be added but existing ones can't change.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.