[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250629170732.16817-1-w@1wt.eu>
Date: Sun, 29 Jun 2025 19:07:30 +0200
From: Willy Tarreau <w@....eu>
To: Thomas Weißschuh <thomas.weissschuh@...utronix.de>
Cc: linux-kernel@...r.kernel.org, Arnd Bergmann <arnd@...db.de>,
Willy Tarreau <w@....eu>
Subject: [RFC PATCH v2 0/2] tools/nolibc: install unified multi-arch headers
While the in-tree nolibc directory supports arch auto-detection,
installing it is only performed for a single architecture at once,
requiring as many sysroots as desired architectures. It is not
convenient because external tools rarely expect to change their
include path based on the target.
Furthermore, when installing it along with the UAPI headers for
use with the nolibc toolchains, the issue is reinforced as UAPI
may only be installed for a single architecture, and in this case
we cannot even count on the headers that would have been packaged
along with the compiler and its accompanying libc.
This patchset proposes a convenient approach to satisfy all this.
First, it updates nolibc's "headers" target so that it will install
the headers for all supported archs, so that they appear just like
in the original source tree, meaning that when uapi headers are
available (e.g. provided with the toolchain), the build will succeed
for any supported archs from a single installation directory.
Second, a new "install_all_archs" target iterates over all supported
archs to install the corresponding UAPI headers, and moves each
arch-specific "asm/" subdir to "asm-arch-$arch", then automatically
recreates the files under asm/ to include the corresponding files based
on the detected architecture. This results in a unified sysroot that
can be used by any of the supported architectures without changing the
include path.
I finally didn't use Arnd's proposal to try to build up the include
file name based on the architecture because I realized that it wouldn't
work for programs that include asm/foo first (or we'd have to go back
through a #include nolibc.h which is outside the scope of this change
that tries to remain libc-agnostic). Instead a template file containing
the #ifdefs for all archs is used for each file. It results in a slightly
larger set of asm/ files than the first version which only contained the
ifdefs for supported archs for each file, but compared to the unified
UAPI size the difference remains pretty small.
I'm marking this as RFC because the operations are entirely performed
inside the nolibc Makefile, and I'm wondering whether there could be
any interest in generalizing the principle and moving it to the
generic uapi installation itself. However I don't see how this could
be easily done in this case, because here we have no other option but
iterate over all supported architectures, and iterating over multiple
archs is not something standard in the kbuild system. But we could also
imagine having a script under scripts/ to install UAPI headers for all
archs at once for example, so ideas are welcome. Of course if there's
no perceived interest in generalizing this to uapi then it can stay
in nolibc where the maintenance cost should remain quite low anyway.
Changes in v2:
- merge of x86_64 and i386 extracted from the series
- dropped the aarch64->arm64 mapping since already handled separately
by Thomas
- made the "headers" target install headers for all archs as suggested
by Thomas.
- dropped the #ifdef generation from the makefile and run sed over
a template instead.
Thanks for any comments!
---
Willy Tarreau (2):
tools/nolibc: make the "headers" target install all supported archs
tools/nolibc: add a new "install_all_archs" target
tools/include/nolibc/Makefile | 50 ++++++++++++++++++++++-------
tools/include/nolibc/asm-template.h | 25 +++++++++++++++
2 files changed, 63 insertions(+), 12 deletions(-)
create mode 100644 tools/include/nolibc/asm-template.h
--
2.17.5
Powered by blists - more mailing lists