From nobody Wed Oct 8 10:58:50 2025 Received: from 1wt.eu (ded1.1wt.eu [163.172.96.212]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F19222F765 for ; Sun, 29 Jun 2025 17:07:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=163.172.96.212 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751216865; cv=none; b=eprsrVXXeiKO5lsBbTuBbPxSf8PSYLLf7TO3Kt6RKoQOI9KeOsnhJAAQCjdH5JoPyMCdbMWz0FQnCTXBYNTJ/dlrS5N+aBolzrsM9DRuQ61tzUsVaLFTBRio8DIFuoZaTEjljUsZ6VLPqAybepjcGsnh9jrUuHTPhVSFXVjTP2M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751216865; c=relaxed/simple; bh=Des8q0UDHaege6zmti1sR3Qz/HJBmgilCuYce6UhV1M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=KuCRD7cmju1euZU5bqhUt1zmQKiJ/0EceLL/zg9kgHEH6ftuI/05qOJ/IbCOXdZldhBCi0UmZl6Cr92NXdSeUPlNn50XuQRB64JsNlC+f5F6+zjIB2mAP7QXZnq6TmNBNTK68EDDfoqJiDV2XW2YEnk8Tm/VZ9IfPNlVLORngzQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=1wt.eu; spf=pass smtp.mailfrom=1wt.eu; arc=none smtp.client-ip=163.172.96.212 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=1wt.eu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=1wt.eu Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 55TH7dkj016862; Sun, 29 Jun 2025 19:07:39 +0200 From: Willy Tarreau To: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , Willy Tarreau Subject: [RFC PATCH v2 1/2] tools/nolibc: make the "headers" target install all supported archs Date: Sun, 29 Jun 2025 19:07:31 +0200 Message-Id: <20250629170732.16817-2-w@1wt.eu> X-Mailer: git-send-email 2.17.5 In-Reply-To: <20250629170732.16817-1-w@1wt.eu> References: <20250629170732.16817-1-w@1wt.eu> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The efforts we go through by installing a single arch are counter productive when the base directory already supports them all, and the arch-specific files are really small. Let's make the "headers" target simply install headers for all supported archs and stop trying to build a hybrid "arch.h" file on the fly, to instead keep the generic one. Signed-off-by: Willy Tarreau --- tools/include/nolibc/Makefile | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index c69d7bf60c71e..d5be3d213c885 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -24,6 +24,8 @@ Q=3D@ endif =20 arch_file :=3D arch-$(ARCH).h +nolibc_supported_archs :=3D arm64 arm loongarch m68k mips powerpc riscv s3= 90 sparc x86 + all_files :=3D \ compiler.h \ crt.h \ @@ -81,7 +83,7 @@ help: @echo "Supported targets under nolibc:" @echo " all call \"headers\"" @echo " clean clean the sysroot" - @echo " headers prepare a sysroot in \$${OUTPUT}sysroot" + @echo " headers prepare a multi-arch sysroot in \$${OUTPUT}s= ysroot" @echo " headers_standalone like \"headers\", and also install kernel he= aders" @echo " help this help" @echo "" @@ -92,18 +94,12 @@ help: @echo " OUTPUT =3D $(OUTPUT)" @echo "" =20 +# installs headers for all archs at once. headers: - $(Q)mkdir -p $(OUTPUT)sysroot - $(Q)mkdir -p $(OUTPUT)sysroot/include - $(Q)cp --parents $(all_files) $(OUTPUT)sysroot/include/ - $(Q)if [ "$(ARCH)" =3D "i386" -o "$(ARCH)" =3D "x86_64" ]; then \ - cat arch-x86.h; \ - elif [ -e "$(arch_file)" ]; then \ - cat $(arch_file); \ - else \ - echo "Fatal: architecture $(ARCH) not yet supported by nolibc." >&2; \ - exit 1; \ - fi > $(OUTPUT)sysroot/include/arch.h + $(Q)mkdir -p "$(OUTPUT)sysroot" + $(Q)mkdir -p "$(OUTPUT)sysroot/include" + $(Q)cp --parents $(all_files) arch.h "$(OUTPUT)sysroot/include/" + $(Q)cp $(addsuffix .h,$(addprefix arch-,$(nolibc_supported_archs))) "$(OU= TPUT)sysroot/include/" =20 headers_standalone: headers $(Q)$(MAKE) -C $(srctree) headers --=20 2.17.5 From nobody Wed Oct 8 10:58:50 2025 Received: from 1wt.eu (ded1.1wt.eu [163.172.96.212]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F1F422FF39 for ; Sun, 29 Jun 2025 17:07:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=163.172.96.212 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751216866; cv=none; b=ThhVed5FuBBn/XVsjtp1yJB98UZSxwLkoQo2ZdxceTP+KZlruAPFvu43KMXBpt7O5UamxwcDGIZG3hZC5Ei19hVx56BwLw3dwn57uw+u82NrllGgY36HLQ5OtSD+uEJGpuGcMEaEw7cVjmSYrGMC5ifmLO8D2W1GVzwhi2N55G8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751216866; c=relaxed/simple; bh=2jmnbI+oGmnBzC3CutU8HydjnbAM10mz6nlY1ZF8N64=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=oUDuwdMMd6T/Q7KRIQcBP/EtOSbsL193LttipY9QXwT+QfdIrozfRDuiblBfbzTT26xEGS3SgbGhEyQLLTQhBn+E5gT5KxJ+jQDD2bgll4AMdtPmeBNNrbsQf7e9CXbZZlSaG5g2/tEMlRMp1Kq4H0Yoomn8AnM2fD0u2LfUbaY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=1wt.eu; spf=pass smtp.mailfrom=1wt.eu; arc=none smtp.client-ip=163.172.96.212 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=1wt.eu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=1wt.eu Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 55TH7dAq016863; Sun, 29 Jun 2025 19:07:39 +0200 From: Willy Tarreau To: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , Willy Tarreau Subject: [RFC PATCH v2 2/2] tools/nolibc: add a new "install_all_archs" target Date: Sun, 29 Jun 2025 19:07:32 +0200 Message-Id: <20250629170732.16817-3-w@1wt.eu> X-Mailer: git-send-email 2.17.5 In-Reply-To: <20250629170732.16817-1-w@1wt.eu> References: <20250629170732.16817-1-w@1wt.eu> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This installs all supported archs together, both from nolibc and kernel headers. The arch-specific asm/ subdirs are renamed to asm-arch-$arch, and asm/ is rebuilt from all these files in order to include the right one depending on the build architecture. This is done by reusing a template file (asm-template.h) for each file found under asm-arch-*, and including the right sub-dir depending on the current arch. This allows to use a single unified sysroot for all archs, and to only change the compiler or the target architecture. This way, a complete sysroot is much easier to use (a single directory is needed) and much smaller. Signed-off-by: Willy Tarreau --- tools/include/nolibc/Makefile | 24 ++++++++++++++++++++++++ tools/include/nolibc/asm-template.h | 25 +++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 tools/include/nolibc/asm-template.h diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index d5be3d213c885..c47559a066f35 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -86,6 +86,7 @@ help: @echo " headers prepare a multi-arch sysroot in \$${OUTPUT}s= ysroot" @echo " headers_standalone like \"headers\", and also install kernel he= aders" @echo " help this help" + @echo " install_all_archs install a multi-arch sysroot + kernel header= s in \$${OUTPUT}sysroot" @echo "" @echo "These targets may also be called from tools as \"make nolibc_\"." @echo "" @@ -105,6 +106,29 @@ headers_standalone: headers $(Q)$(MAKE) -C $(srctree) headers $(Q)$(MAKE) -C $(srctree) headers_install INSTALL_HDR_PATH=3D$(OUTPUT)sys= root =20 +install_all_archs: headers + @# install common headers for any arch, take them all. This will clear ev= erything. + $(Q)$(MAKE) -C $(srctree) ARCH=3Dx86 mrproper + $(Q)$(MAKE) -C $(srctree) ARCH=3Dx86 headers_install no-export-headers=3D= INSTALL_HDR_PATH=3D"$(OUTPUT)sysroot" + @# remove the contents of the unused asm dir which we will rebuild from t= he arch ones + $(Q)rm -rf "$(OUTPUT)sysroot/include/asm" + $(Q)mkdir -p "$(OUTPUT)sysroot/include/asm" + @# Now install headers for all archs + $(Q)for arch in $(nolibc_supported_archs); do \ + echo "# installing $$arch"; \ + if ! [ -d $(OUTPUT)sysroot/include/asm-arch-$$arch ]; then \ + $(MAKE) -C $(srctree) ARCH=3D$$arch mrproper; \ + $(MAKE) -C $(srctree) ARCH=3D$$arch headers_install no-export-headers= =3D \ + INSTALL_HDR_PATH=3D"$(OUTPUT)sysroot/include/$$arch" >/dev/null; \ + mv "$(OUTPUT)sysroot/include/$$arch/include/asm" "$(OUTPUT)sysroot/incl= ude/asm-arch-$$arch"; \ + rm -rf "$(OUTPUT)sysroot/include/$$arch"; \ + fi;\ + done; \ + mkdir -p "$(OUTPUT)sysroot/include/asm"; \ + for file in $$(find "$(OUTPUT)sysroot/include/"asm-arch-* -maxdepth 1 -na= me '*.h' -printf '%P\n'); do \ + sed -e "s!_ASMFILE_!$$file!" asm-template.h > "$(OUTPUT)sysroot/include/= asm/$$file"; \ + done + # GCC uses "s390", clang "systemz" CLANG_CROSS_FLAGS :=3D $(subst --target=3Ds390-linux,--target=3Dsystemz-li= nux,$(CLANG_CROSS_FLAGS)) =20 diff --git a/tools/include/nolibc/asm-template.h b/tools/include/nolibc/asm= -template.h new file mode 100644 index 0000000000000..84930c4761d16 --- /dev/null +++ b/tools/include/nolibc/asm-template.h @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */ + +#if defined(__x86_64__) || defined(__i386__) || defined(__i486__) || defin= ed(__i586__) || defined(__i686__) +#include "../asm-arch-x86/_ASMFILE_" +#elif defined(__ARM_EABI__) +#include "../asm-arch-arm/_ASMFILE_" +#elif defined(__aarch64__) +#include "../asm-arch-arm64/_ASMFILE_" +#elif defined(__mips__) +#include "../asm-arch-mips/_ASMFILE_" +#elif defined(__powerpc__) +#include "../asm-arch-powerpc/_ASMFILE_" +#elif defined(__riscv) +#include "../asm-arch-riscv/_ASMFILE_" +#elif defined(__s390x__) || defined(__s390__) +#include "../asm-arch-s390/_ASMFILE_" +#elif defined(__loongarch__) +#include "../asm-arch-loongarch/_ASMFILE_" +#elif defined(__sparc__) +#include "../asm-arch-sparc/_ASMFILE_" +#elif defined(__m68k__) +#include "../asm-arch-m68k/_ASMFILE_" +#else +#error Unsupported Architecture +#endif --=20 2.17.5