Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools/nolibc: add target to check header usability

Each nolibc header should be valid for inclusion irrespective of any
special ordering requirements.

Add a new make target, based on the old kbuild "make header_check" target
to validate this requirement.

For now the check fails, but the following commits will fix the issues.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250424-nolibc-header-check-v1-1-011576b6ed6f@linutronix.de

authored by

Thomas Weißschuh and committed by
Thomas Weißschuh
a6a054c8 e90ce42e

+9
+9
tools/include/nolibc/Makefile
··· 101 101 $(Q)$(MAKE) -C $(srctree) headers 102 102 $(Q)$(MAKE) -C $(srctree) headers_install INSTALL_HDR_PATH=$(OUTPUT)sysroot 103 103 104 + # GCC uses "s390", clang "systemz" 105 + CLANG_CROSS_FLAGS := $(subst --target=s390-linux,--target=systemz-linux,$(CLANG_CROSS_FLAGS)) 106 + 107 + headers_check: headers_standalone 108 + for header in $(filter-out crt.h std.h,$(all_files)); do \ 109 + $(CC) $(CLANG_CROSS_FLAGS) -Wall -Werror -nostdinc -fsyntax-only -x c /dev/null \ 110 + -I$(or $(objtree),$(srctree))/usr/include -include $$header -include $$header || exit 1; \ 111 + done 112 + 104 113 clean: 105 114 $(call QUIET_CLEAN, nolibc) rm -rf "$(OUTPUT)sysroot"