From d4b7080be277ca400b443ac211b79450f4befddc Mon Sep 17 00:00:00 2001 From: Thomas Weißschuh Date: Wed, 13 Aug 2025 08:16:56 +0200 Subject: kbuild: uapi: rerun header tests when headers_check.pl changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the checks change they need to be rerun. Add a Makefile dependency so this happens. Signed-off-by: Thomas Weißschuh Reviewed-by: Nicolas Schier Link: https://lore.kernel.org/r/20250813-kbuild-hdrtest-fixes-v2-1-8a7921ca3a03@linutronix.de Signed-off-by: Nathan Chancellor --- usr/include/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usr/include') diff --git a/usr/include/Makefile b/usr/include/Makefile index f02f41941b60..c7f164952b33 100644 --- a/usr/include/Makefile +++ b/usr/include/Makefile @@ -85,7 +85,7 @@ quiet_cmd_hdrtest = HDRTEST $< $(PERL) $(src)/headers_check.pl $(obj) $<; \ touch $@ -$(obj)/%.hdrtest: $(obj)/%.h FORCE +$(obj)/%.hdrtest: $(obj)/%.h $(src)/headers_check.pl FORCE $(call if_changed_dep,hdrtest) # Since GNU Make 4.3, $(patsubst $(obj)/%/,%,$(wildcard $(obj)/*/)) works. -- cgit v1.2.3 From 3788d69db18d310afa9892642520fb9b47edf829 Mon Sep 17 00:00:00 2001 From: Thomas Weißschuh Date: Wed, 13 Aug 2025 08:16:57 +0200 Subject: kbuild: uapi: fail header test on compiler warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Compiler warnings also indicate issues with the headers. Make sure they don't go unnoticed. Signed-off-by: Thomas Weißschuh Reviewed-by: Nicolas Schier Link: https://lore.kernel.org/r/20250813-kbuild-hdrtest-fixes-v2-2-8a7921ca3a03@linutronix.de Signed-off-by: Nathan Chancellor --- usr/include/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usr/include') diff --git a/usr/include/Makefile b/usr/include/Makefile index c7f164952b33..61a7dd4fc05f 100644 --- a/usr/include/Makefile +++ b/usr/include/Makefile @@ -80,7 +80,7 @@ always-y := $(patsubst $(obj)/%.h,%.hdrtest, $(shell find $(obj) -name '*.h' 2>/ # Include the header twice to detect missing include guard. quiet_cmd_hdrtest = HDRTEST $< cmd_hdrtest = \ - $(CC) $(c_flags) -fsyntax-only -x c /dev/null \ + $(CC) $(c_flags) -fsyntax-only -Werror -x c /dev/null \ $(if $(filter-out $(no-header-test), $*.h), -include $< -include $<); \ $(PERL) $(src)/headers_check.pl $(obj) $<; \ touch $@ -- cgit v1.2.3 From 24b1bd64ee4030a306f74811c346db4042f4c98a Mon Sep 17 00:00:00 2001 From: Thomas Weißschuh Date: Wed, 13 Aug 2025 08:16:58 +0200 Subject: kbuild: uapi: upgrade warning on asm/types.h inclusion to error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No usages of '#include in the UAPI headers exist anymore. Make sure it stays this way. Add a semicolon to the end of the previous printf call to keep the syntax valid. Signed-off-by: Thomas Weißschuh Reviewed-by: Nicolas Schier Link: https://lore.kernel.org/r/20250813-kbuild-hdrtest-fixes-v2-3-8a7921ca3a03@linutronix.de Signed-off-by: Nathan Chancellor --- usr/include/headers_check.pl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'usr/include') diff --git a/usr/include/headers_check.pl b/usr/include/headers_check.pl index 2b70bfa5558e..36307a137cc1 100755 --- a/usr/include/headers_check.pl +++ b/usr/include/headers_check.pl @@ -98,9 +98,8 @@ sub check_asm_types if ($line =~ m/^\s*#\s*include\s+/) { $linux_asm_types = 1; printf STDERR "$filename:$lineno: " . - "include of is preferred over \n" - # Warn until headers are all fixed - #$ret = 1; + "include of is preferred over \n"; + $ret = 1; } } -- cgit v1.2.3 From c3a9d74ee413bdb3007b39e62418f9757a0642e6 Mon Sep 17 00:00:00 2001 From: Thomas Weißschuh Date: Wed, 13 Aug 2025 08:16:59 +0200 Subject: kbuild: uapi: upgrade check_sizetypes() warning to error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No problematic type usages exist anymore. Make sure it stays this way. Signed-off-by: Thomas Weißschuh Reviewed-by: Nicolas Schier Link: https://lore.kernel.org/r/20250813-kbuild-hdrtest-fixes-v2-4-8a7921ca3a03@linutronix.de Signed-off-by: Nathan Chancellor --- usr/include/headers_check.pl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'usr/include') diff --git a/usr/include/headers_check.pl b/usr/include/headers_check.pl index 36307a137cc1..36349b21cef5 100755 --- a/usr/include/headers_check.pl +++ b/usr/include/headers_check.pl @@ -159,7 +159,6 @@ sub check_sizetypes "found __[us]{8,16,32,64} type " . "without #include \n"; $linux_types = 2; - # Warn until headers are all fixed - #$ret = 1; + $ret = 1; } } -- cgit v1.2.3 From b8d762c9830538c743066cbfb1f8c8a40f8e9d58 Mon Sep 17 00:00:00 2001 From: Thomas Weißschuh Date: Wed, 13 Aug 2025 08:17:00 +0200 Subject: kbuild: uapi: upgrade check_declarations() warning to error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No problematic declarations exist anymore. Make sure it stays this way. Signed-off-by: Thomas Weißschuh Reviewed-by: Nicolas Schier Link: https://lore.kernel.org/r/20250813-kbuild-hdrtest-fixes-v2-5-8a7921ca3a03@linutronix.de Signed-off-by: Nathan Chancellor --- usr/include/headers_check.pl | 1 + 1 file changed, 1 insertion(+) (limited to 'usr/include') diff --git a/usr/include/headers_check.pl b/usr/include/headers_check.pl index 36349b21cef5..21c2fb9520e6 100755 --- a/usr/include/headers_check.pl +++ b/usr/include/headers_check.pl @@ -74,6 +74,7 @@ sub check_declarations printf STDERR "$filename:$lineno: " . "userspace cannot reference function or " . "variable defined in the kernel\n"; + $ret = 1; } } -- cgit v1.2.3 From 66128f4287b04aef4d4db9bf5035985ab51487d5 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Mon, 6 Oct 2025 14:33:42 +0200 Subject: kbuild: uapi: Strip comments before size type check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On m68k, check_sizetypes in headers_check reports: ./usr/include/asm/bootinfo-amiga.h:17: found __[us]{8,16,32,64} type without #include This header file does not use any of the Linux-specific integer types, but merely refers to them from comments, so this is a false positive. As of commit c3a9d74ee413bdb3 ("kbuild: uapi: upgrade check_sizetypes() warning to error"), this check was promoted to an error, breaking m68k all{mod,yes}config builds. Fix this by stripping simple comments before looking for Linux-specific integer types. Signed-off-by: Geert Uytterhoeven Reviewed-by: Thomas Weißschuh Link: https://patch.msgid.link/949f096337e28d50510e970ae3ba3ec9c1342ec0.1759753998.git.geert@linux-m68k.org [nathan: Adjust comment and remove unnecessary escaping from slashes in regex] Signed-off-by: Nathan Chancellor --- usr/include/headers_check.pl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'usr/include') diff --git a/usr/include/headers_check.pl b/usr/include/headers_check.pl index 21c2fb9520e6..1fbc8785f96e 100755 --- a/usr/include/headers_check.pl +++ b/usr/include/headers_check.pl @@ -155,6 +155,8 @@ sub check_sizetypes if (my $included = ($line =~ /^\s*#\s*include\s+[<"](\S+)[>"]/)[0]) { check_include_typesh($included); } + # strip single-line comments, as types may be referenced within them + $line =~ s@/\*.*?\*/@@; if ($line =~ m/__[us](8|16|32|64)\b/) { printf STDERR "$filename:$lineno: " . "found __[us]{8,16,32,64} type " . -- cgit v1.2.3