lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250620103705.10208-4-w@1wt.eu>
Date: Fri, 20 Jun 2025 12:37:05 +0200
From: Willy Tarreau <w@....eu>
To: Thomas Weißschuh <thomas.weissschuh@...utronix.de>
Cc: linux-kernel@...r.kernel.org, Masahiro Yamada <masahiroy@...nel.org>,
        Arnd Bergmann <arnd@...db.de>, Willy Tarreau <w@....eu>
Subject: [RFC PATCH 3/3] tools/nolibc: add a new "install_all_archs" target

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 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 <w@....eu>
---
 tools/include/nolibc/Makefile | 39 +++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile
index 8de6ac5cec425..b6ed11d0b5419 100644
--- a/tools/include/nolibc/Makefile
+++ b/tools/include/nolibc/Makefile
@@ -88,6 +88,7 @@ help:
 	@echo "  headers_all_archs   prepare a multi-arch sysroot in \$${OUTPUT}sysroot"
 	@echo "  headers_standalone  like \"headers\", and also install kernel headers"
 	@echo "  help                this help"
+	@echo "  install_all_archs   install a multi-arch sysroot + kernel headers in \$${OUTPUT}sysroot"
 	@echo ""
 	@echo "These targets may also be called from tools as \"make nolibc_<target>\"."
 	@echo ""
@@ -120,6 +121,44 @@ headers_all_archs:
 	$(Q)cp --parents $(all_files) arch.h "$(OUTPUT)sysroot/include/"
 	$(Q)cp $(addsuffix .h,$(addprefix arch-,$(nolibc_supported_archs))) "$(OUTPUT)sysroot/include/"
 
+install_all_archs: headers_all_archs
+	@# install common headers for any arch, take them all. This will clear everything.
+	$(Q)$(MAKE) -C $(srctree) ARCH=x86 mrproper
+	$(Q)$(MAKE) -C $(srctree) ARCH=x86 headers_install no-export-headers= INSTALL_HDR_PATH="$(OUTPUT)sysroot"
+	@# remove the contents of the unused asm dir which we will rebuild from the 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 $(patsubst aarch64,arm64,$(nolibc_supported_archs)); do \
+		echo "# installing $$arch"; \
+		if ! [ -d $(OUTPUT)sysroot/include/asm-arch-$$arch ]; then \
+			$(MAKE) -C $(srctree) ARCH=$$arch mrproper; \
+			$(MAKE) -C $(srctree) ARCH=$$arch headers_install no-export-headers= \
+				INSTALL_HDR_PATH="$(OUTPUT)sysroot/include/$$arch" >/dev/null; \
+			mv "$(OUTPUT)sysroot/include/$$arch/include/asm" "$(OUTPUT)sysroot/include/asm-arch-$$arch"; \
+			rm -rf "$(OUTPUT)sysroot/include/$$arch"; \
+			case "$$arch" in \
+				arm)       cond="defined(__ARM_EABI__)" ;; \
+				arm64)     cond="defined(__aarch64__)" ;; \
+				loongarch) cond="defined(__loongarch__)" ;; \
+				m68k)      cond="defined(__m68k__)" ;; \
+				mips)      cond="defined(__mips__)" ;; \
+				powerpc)   cond="defined(__powerpc__)" ;; \
+				riscv)     cond="defined(__riscv__)" ;; \
+				s390)      cond="defined(__s390__) || defined(__s390x__)" ;; \
+				sparc)     cond="defined(__sparc__)" ;; \
+				x86)       cond="defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || defined(__x86_64__)";; \
+				*)         echo "Unsupported arch" >&2; exit 1;; \
+			esac;\
+			for file in "$(OUTPUT)sysroot/include/asm-arch-$$arch/"*.h; do \
+				base="$${file##*/}"; \
+				( echo "#if $$cond"; \
+				  echo "#include \"../asm-arch-$$arch/$$base\""; \
+				  echo "#endif" ) >> "$(OUTPUT)sysroot/include/asm/$$base"; \
+			done; \
+		fi;\
+	done
+
 # GCC uses "s390", clang "systemz"
 CLANG_CROSS_FLAGS := $(subst --target=s390-linux,--target=systemz-linux,$(CLANG_CROSS_FLAGS))
 
-- 
2.17.5


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ