All of lore.kernel.org
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: enh <enh@google.com>, Arnd Bergmann <arnd@arndb.de>,
	LKML <linux-kernel@vger.kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	libc-alpha@sourceware.org, linux-arch@vger.kernel.org
Subject: Re: Metalanguage for the Linux UAPI
Date: Fri, 16 May 2025 05:42:32 +0200	[thread overview]
Message-ID: <20250516034232.GA12472@1wt.eu> (raw)
In-Reply-To: <e4d114e3-984a-482d-a162-03f896cd2053@zytor.com>

On Thu, May 15, 2025 at 02:24:29PM -0700, H. Peter Anvin wrote:
> On 5/15/25 13:26, enh wrote:
> > On Thu, May 15, 2025 at 4:05 PM H. Peter Anvin <hpa@zytor.com> wrote:
> > > 
> > > OK, so this is something I have been thinking about for quite a while.
> > > It would be a quite large project, so I would like to hear people's
> > > opinions on it before even starting.
> > > 
> > > We have finally succeeded in divorcing the Linux UAPI from the general
> > > kernel headers, but even so, there are a lot of things in the UAPI that
> > > means it is not possible for an arbitrary libc to use it directly; for
> > > example "struct termios" is not the glibc "struct termios", but
> > > redefining it breaks the ioctl numbering unless the ioctl headers are
> > > changed as well, and so on. However, other libcs want to use the struct
> > > termios as defined in the kernel, or, more likely, struct termios2.
> > 
> > bionic is a ("the only"?) libc that tries to not duplicate _anything_
> > and always defer to the uapi headers. we have quite an extensive list
> > of hacks we need to apply to rewrite the uapi headers into something
> > directly usable (and a lot of awful python to apply those hacks):
> > 
> > https://cs.android.com/android/platform/superproject/main/+/main:bionic/libc/kernel/tools/defaults.py
> > 
> 
> Not "the only".

Indeed, nolibc (/tools/include/nolibc) directly includes uapi as well, and
since nolibc doesn't compile anything but only exposes include files, these
appear as-is in the application. So far the headers look clean enough for
our use cases and have not caused problems. But admittedly, applications
are small and limited (selftests and init code).

One thing we've been considering which we would find convenient there
would be to generate an indirection layer for all files that would include
the right one depending on the detected arch so as to ease compilation for
any arch with all the uapi files available, as it seems totally feasible
right now (i.e. each .h file would just have "#if defined(__arch_xxx__)
#include <arch_xxx/foo.h>" etc). We could imagine having a
"make install-all-headers" target to produce that thing for example. I'm
sharing this so that you can also have this in mind to consider whether or
not your chosen approach would break that possibility.

Just my two cents,
Willy

  reply	other threads:[~2025-05-16  3:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-15 20:04 Metalanguage for the Linux UAPI H. Peter Anvin
2025-05-15 20:26 ` enh
2025-05-15 21:24   ` H. Peter Anvin
2025-05-16  3:42     ` Willy Tarreau [this message]
2025-05-16  4:17       ` H. Peter Anvin
2025-05-16  4:22         ` Willy Tarreau
2025-05-16  4:35           ` H. Peter Anvin
2025-05-16 17:27     ` enh
2025-05-15 21:20 ` Linus Torvalds
2025-05-15 21:42   ` H. Peter Anvin
2025-05-15 22:06     ` Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250516034232.GA12472@1wt.eu \
    --to=w@1wt.eu \
    --cc=arnd@arndb.de \
    --cc=enh@google.com \
    --cc=hpa@zytor.com \
    --cc=libc-alpha@sourceware.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.