From 102d712ded3ef2ee5b38ee6afa686aff63afd444 Mon Sep 17 00:00:00 2001 From: Nicolas Schier Date: Fri, 20 Feb 2026 19:55:19 +0100 Subject: [PATCH 01/35] kconfig: Error out on duplicated kconfig inclusion Let kconfig exit with error on duplicated Kconfig file inclusion. Repeated inclusion of Kbuild files are considered bad-practise with regard to maintenance; and Kconfig language is rich enough that there should be no need for that. If repeated inclusion of Kconfig files is detected, error out with messages like: Kconfig.inc1:4: error: repeated inclusion of Kconfig.inc3 Kconfig.inc2:3: note: location of first inclusion of Kconfig.inc3 While commit f094f8a1b273 ("kconfig: allow multiple inclusion of the same file") introduced detection of recursive inclusions of Kconfig files, it explicitly allowed repeated inclusions, unfortunately w/o reasoning. Reported-by: Linus Torvalds Closes: https://lore.kernel.org/all/CAHk-=wj03hLzK2D=+OYmjgcmGM+XYymp8GyaEs=C0=rXG2nb7w@mail.gmail.com/ Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor Link: https://patch.msgid.link/20260220-kconfig-error-out-on-duplicated-inclusion-v1-1-be78aa241a53@kernel.org Signed-off-by: Nicolas Schier --- scripts/kconfig/lexer.l | 4 +-- scripts/kconfig/lkc.h | 3 +- .../kconfig/tests/err_repeated_inc/Kconfig | 3 ++ .../tests/err_repeated_inc/Kconfig.inc1 | 4 +++ .../tests/err_repeated_inc/Kconfig.inc2 | 3 ++ .../tests/err_repeated_inc/Kconfig.inc3 | 1 + .../tests/err_repeated_inc/__init__.py | 10 ++++++ .../tests/err_repeated_inc/expected_stderr | 2 ++ scripts/kconfig/util.c | 33 ++++++++++++++++--- 9 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 scripts/kconfig/tests/err_repeated_inc/Kconfig create mode 100644 scripts/kconfig/tests/err_repeated_inc/Kconfig.inc1 create mode 100644 scripts/kconfig/tests/err_repeated_inc/Kconfig.inc2 create mode 100644 scripts/kconfig/tests/err_repeated_inc/Kconfig.inc3 create mode 100644 scripts/kconfig/tests/err_repeated_inc/__init__.py create mode 100644 scripts/kconfig/tests/err_repeated_inc/expected_stderr diff --git a/scripts/kconfig/lexer.l b/scripts/kconfig/lexer.l index 6d2c92c6095d..a6155422b4a6 100644 --- a/scripts/kconfig/lexer.l +++ b/scripts/kconfig/lexer.l @@ -402,7 +402,7 @@ void zconf_initscan(const char *name) exit(1); } - cur_filename = file_lookup(name); + cur_filename = file_lookup(name, NULL, 0); yylineno = 1; } @@ -443,7 +443,7 @@ void zconf_nextfile(const char *name) } yylineno = 1; - cur_filename = file_lookup(name); + cur_filename = file_lookup(name, cur_filename, cur_lineno); } static void zconf_endfile(void) diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 798985961215..7e6f6ca299cf 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -51,7 +51,8 @@ static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out) } /* util.c */ -const char *file_lookup(const char *name); +const char *file_lookup(const char *name, + const char *parent_name, int parent_lineno); /* lexer.l */ int yylex(void); diff --git a/scripts/kconfig/tests/err_repeated_inc/Kconfig b/scripts/kconfig/tests/err_repeated_inc/Kconfig new file mode 100644 index 000000000000..09a88fd29cb5 --- /dev/null +++ b/scripts/kconfig/tests/err_repeated_inc/Kconfig @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-only + +source "Kconfig.inc1" diff --git a/scripts/kconfig/tests/err_repeated_inc/Kconfig.inc1 b/scripts/kconfig/tests/err_repeated_inc/Kconfig.inc1 new file mode 100644 index 000000000000..495dc38314a1 --- /dev/null +++ b/scripts/kconfig/tests/err_repeated_inc/Kconfig.inc1 @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0-only + +source "Kconfig.inc2" +source "Kconfig.inc3" diff --git a/scripts/kconfig/tests/err_repeated_inc/Kconfig.inc2 b/scripts/kconfig/tests/err_repeated_inc/Kconfig.inc2 new file mode 100644 index 000000000000..2b630eec2e99 --- /dev/null +++ b/scripts/kconfig/tests/err_repeated_inc/Kconfig.inc2 @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-only + +source "Kconfig.inc3" diff --git a/scripts/kconfig/tests/err_repeated_inc/Kconfig.inc3 b/scripts/kconfig/tests/err_repeated_inc/Kconfig.inc3 new file mode 100644 index 000000000000..a4e40e534e6a --- /dev/null +++ b/scripts/kconfig/tests/err_repeated_inc/Kconfig.inc3 @@ -0,0 +1 @@ +# SPDX-License-Identifier: GPL-2.0-only diff --git a/scripts/kconfig/tests/err_repeated_inc/__init__.py b/scripts/kconfig/tests/err_repeated_inc/__init__.py new file mode 100644 index 000000000000..129d740a874b --- /dev/null +++ b/scripts/kconfig/tests/err_repeated_inc/__init__.py @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: GPL-2.0 +""" +Detect repeated inclusion error. + +If repeated inclusion is detected, it should fail with error message. +""" + +def test(conf): + assert conf.oldaskconfig() != 0 + assert conf.stderr_contains('expected_stderr') diff --git a/scripts/kconfig/tests/err_repeated_inc/expected_stderr b/scripts/kconfig/tests/err_repeated_inc/expected_stderr new file mode 100644 index 000000000000..95d90d6a93c5 --- /dev/null +++ b/scripts/kconfig/tests/err_repeated_inc/expected_stderr @@ -0,0 +1,2 @@ +Kconfig.inc1:4: error: Repeated inclusion of Kconfig.inc3 +Kconfig.inc2:3: note: Location of first inclusion of Kconfig.inc3 diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c index 5cdcee144b58..0809aa061b6a 100644 --- a/scripts/kconfig/util.c +++ b/scripts/kconfig/util.c @@ -18,25 +18,50 @@ static HASHTABLE_DEFINE(file_hashtable, 1U << 11); struct file { struct hlist_node node; + struct { + const char *name; + int lineno; + } parent; char name[]; }; -/* file already present in list? If not add it */ -const char *file_lookup(const char *name) +static void die_duplicated_include(struct file *file, + const char *parent, int lineno) { + fprintf(stderr, + "%s:%d: error: repeated inclusion of %s\n" + "%s:%d: note: location of first inclusion of %s\n", + parent, lineno, file->name, + file->parent.name, file->parent.lineno, file->name); + exit(1); +} + +/* file already present in list? If not add it */ +const char *file_lookup(const char *name, + const char *parent_name, int parent_lineno) +{ + const char *parent = NULL; struct file *file; size_t len; int hash = hash_str(name); + if (parent_name) + parent = file_lookup(parent_name, NULL, 0); + hash_for_each_possible(file_hashtable, file, node, hash) - if (!strcmp(name, file->name)) - return file->name; + if (!strcmp(name, file->name)) { + if (!parent_name) + return file->name; + die_duplicated_include(file, parent, parent_lineno); + } len = strlen(name); file = xmalloc(sizeof(*file) + len + 1); memset(file, 0, sizeof(*file)); memcpy(file->name, name, len); file->name[len] = '\0'; + file->parent.name = parent; + file->parent.lineno = parent_lineno; hash_add(file_hashtable, &file->node, hash); From 8830b2e5907325bd80543bf6001f80819f5cbfc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Thu, 26 Feb 2026 22:23:57 +0100 Subject: [PATCH 02/35] Documentation/llvm: drop note about LLVM=0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since commit 502678b88cb3 ("kbuild: Reject unexpected values for LLVM=") LLVM=0 generates an error instead of silently behaving unexpectedly. Drop the now unnecessary note. Signed-off-by: Thomas Weißschuh Reviewed-by: Nicolas Schier Reviewed-by: Nathan Chancellor Link: https://patch.msgid.link/20260226-kbuild-llvm-followup-v1-1-201cc2a492d9@weissschuh.net Signed-off-by: Nicolas Schier --- Documentation/kbuild/llvm.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Documentation/kbuild/llvm.rst b/Documentation/kbuild/llvm.rst index bc8a283bc44b..441d8786fcbc 100644 --- a/Documentation/kbuild/llvm.rst +++ b/Documentation/kbuild/llvm.rst @@ -71,10 +71,6 @@ recommend:: PATH=/path/to/llvm/:$PATH make LLVM=-14 -``LLVM=0`` is not the same as omitting ``LLVM`` altogether, it will behave like -``LLVM=1``. If you only wish to use certain LLVM utilities, use their -respective make variables. - The same value used for ``LLVM=`` should be set for each invocation of ``make`` if configuring and building via distinct commands. ``LLVM=`` should also be set as an environment variable when running scripts that will eventually run From 7239ae5331ae077c2621740a5db89e65611182cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Thu, 26 Feb 2026 22:23:58 +0100 Subject: [PATCH 03/35] tools/build: Reject unexpected values for LLVM= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since commit 502678b88cb3 ("kbuild: Reject unexpected values for LLVM=") the regular kbuild rejects unexpected values of LLVM=1 instead of silently treating them as LLVM=1. Align the tools build to kbuild. Signed-off-by: Thomas Weißschuh Reviewed-by: Nicolas Schier Reviewed-by: Nathan Chancellor Link: https://patch.msgid.link/20260226-kbuild-llvm-followup-v1-2-201cc2a492d9@weissschuh.net Signed-off-by: Nicolas Schier --- tools/scripts/Makefile.include | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include index b5ecf137febc..41971a68972d 100644 --- a/tools/scripts/Makefile.include +++ b/tools/scripts/Makefile.include @@ -56,6 +56,8 @@ ifneq ($(filter %/,$(LLVM)),) LLVM_PREFIX := $(LLVM) else ifneq ($(filter -%,$(LLVM)),) LLVM_SUFFIX := $(LLVM) +else ifneq ($(LLVM),1) +$(error Invalid value for LLVM, see Documentation/kbuild/llvm.rst) endif $(call allow-override,CC,$(LLVM_PREFIX)clang$(LLVM_SUFFIX)) From 47bca1cbf692b89defbf4db27495813f82d5e3ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Fri, 27 Feb 2026 07:37:59 +0100 Subject: [PATCH 04/35] hexagon: uapi: Fix structure alignment attribute MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit __aligned() is a kernel macro, which is not available in UAPI headers. Use the compiler-provided alignment attribute directly. Signed-off-by: Thomas Weißschuh Acked-by: Arnd Bergmann Reviewed-by: Nathan Chancellor Reviewed-by: Nicolas Schier Tested-by: Nicolas Schier Link: https://patch.msgid.link/20260227-kbuild-uapi-libc-v1-1-c17de0d19776@weissschuh.net Signed-off-by: Nicolas Schier --- arch/hexagon/include/uapi/asm/sigcontext.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/hexagon/include/uapi/asm/sigcontext.h b/arch/hexagon/include/uapi/asm/sigcontext.h index 7171edb1b8b7..179a97041b59 100644 --- a/arch/hexagon/include/uapi/asm/sigcontext.h +++ b/arch/hexagon/include/uapi/asm/sigcontext.h @@ -29,6 +29,6 @@ */ struct sigcontext { struct user_regs_struct sc_regs; -} __aligned(8); +} __attribute__((aligned(8))); #endif From a8c9d3cc23b6564aa8898a9ba20b2abc7fc42eca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Fri, 27 Feb 2026 07:38:00 +0100 Subject: [PATCH 05/35] kbuild: uapi: test linux/bpf_perf_event.h on powerpc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This header works now, so test it. Signed-off-by: Thomas Weißschuh Reviewed-by: Nathan Chancellor Reviewed-by: Nicolas Schier Tested-by: Nicolas Schier Acked-by: Arnd Bergmann Link: https://patch.msgid.link/20260227-kbuild-uapi-libc-v1-2-c17de0d19776@weissschuh.net Signed-off-by: Nicolas Schier --- usr/include/Makefile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/usr/include/Makefile b/usr/include/Makefile index 6d86a53c6f0a..595996eefcc6 100644 --- a/usr/include/Makefile +++ b/usr/include/Makefile @@ -56,10 +56,6 @@ ifeq ($(SRCARCH),openrisc) no-header-test += linux/bpf_perf_event.h endif -ifeq ($(SRCARCH),powerpc) -no-header-test += linux/bpf_perf_event.h -endif - ifeq ($(SRCARCH),sparc) no-header-test += asm/uctx.h no-header-test += asm/fbio.h From 45bd8643c1a2e5e17e3436c4d8de2a67e16e64d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Fri, 27 Feb 2026 07:38:01 +0100 Subject: [PATCH 06/35] kbuild: uapi: deduplicate linux/bpf_perf_event.h exclusions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This header is excluded for multiple architectures. Use a single exclusion for all of them. Signed-off-by: Thomas Weißschuh Reviewed-by: Nathan Chancellor Reviewed-by: Nicolas Schier Tested-by: Nicolas Schier Acked-by: Arnd Bergmann Link: https://patch.msgid.link/20260227-kbuild-uapi-libc-v1-3-c17de0d19776@weissschuh.net Signed-off-by: Nicolas Schier --- usr/include/Makefile | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/usr/include/Makefile b/usr/include/Makefile index 595996eefcc6..ae365d32269a 100644 --- a/usr/include/Makefile +++ b/usr/include/Makefile @@ -48,11 +48,7 @@ no-header-test += xen/privcmd.h # More headers are broken in some architectures -ifeq ($(SRCARCH),arc) -no-header-test += linux/bpf_perf_event.h -endif - -ifeq ($(SRCARCH),openrisc) +ifneq ($(filter arc openrisc xtensa, $(SRCARCH)),) no-header-test += linux/bpf_perf_event.h endif @@ -61,10 +57,6 @@ no-header-test += asm/uctx.h no-header-test += asm/fbio.h endif -ifeq ($(SRCARCH),xtensa) -no-header-test += linux/bpf_perf_event.h -endif - # asm-generic/*.h is used by asm/*.h, and should not be included directly no-header-test += asm-generic/% From 60a16beedf37db82edf39346fdc9e3916ab41994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Fri, 27 Feb 2026 07:38:02 +0100 Subject: [PATCH 07/35] kbuild: uapi: completely exclude linux/bpf_perf_event.h on nios2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This header is actually not buildable on nios. As nobody built nios2 with CONFIG_CC_CAN_LINK=y so far, this produced no errors. Signed-off-by: Thomas Weißschuh Reviewed-by: Nathan Chancellor Reviewed-by: Nicolas Schier Tested-by: Nicolas Schier Acked-by: Arnd Bergmann Link: https://patch.msgid.link/20260227-kbuild-uapi-libc-v1-4-c17de0d19776@weissschuh.net Signed-off-by: Nicolas Schier --- usr/include/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/usr/include/Makefile b/usr/include/Makefile index ae365d32269a..a8619aa85c87 100644 --- a/usr/include/Makefile +++ b/usr/include/Makefile @@ -48,7 +48,7 @@ no-header-test += xen/privcmd.h # More headers are broken in some architectures -ifneq ($(filter arc openrisc xtensa, $(SRCARCH)),) +ifneq ($(filter arc openrisc xtensa nios2, $(SRCARCH)),) no-header-test += linux/bpf_perf_event.h endif @@ -128,7 +128,6 @@ endif ifeq ($(SRCARCH),nios2) uses-libc += asm/ptrace.h -uses-libc += linux/bpf_perf_event.h endif ifeq ($(SRCARCH),s390) From 0ef1b7a66b604593c62a6375e4b6afa0a5f2e04a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Fri, 27 Feb 2026 07:38:03 +0100 Subject: [PATCH 08/35] kbuild: uapi: only use dummy-include for headers which use libc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The headers which do not rely on libc are using built using -nostdinc. For them the dummy headers are pointless. Signed-off-by: Thomas Weißschuh Reviewed-by: Nathan Chancellor Reviewed-by: Nicolas Schier Tested-by: Nicolas Schier Acked-by: Arnd Bergmann Link: https://patch.msgid.link/20260227-kbuild-uapi-libc-v1-5-c17de0d19776@weissschuh.net Signed-off-by: Nicolas Schier --- usr/include/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr/include/Makefile b/usr/include/Makefile index a8619aa85c87..fdc79cffcc97 100644 --- a/usr/include/Makefile +++ b/usr/include/Makefile @@ -8,7 +8,7 @@ # We cannot go as far as adding -Wpedantic since it emits too many warnings. UAPI_CFLAGS := -std=c90 -Werror=implicit-function-declaration -override c_flags = $(KBUILD_USERCFLAGS) $(UAPI_CFLAGS) -Wp,-MMD,$(depfile) -I $(obj) -I $(srctree)/usr/dummy-include +override c_flags = $(KBUILD_USERCFLAGS) $(UAPI_CFLAGS) -Wp,-MMD,$(depfile) -I $(obj) # The following are excluded for now because they fail to build. # @@ -145,7 +145,7 @@ target-can-compile = $(and $(filter-out $(no-header-test), $*.h), \ quiet_cmd_hdrtest = HDRTEST $< cmd_hdrtest = \ $(CC) $(c_flags) -fsyntax-only -Werror -x c /dev/null \ - $(if $(target-no-libc), -nostdinc) \ + $(if $(target-no-libc), -nostdinc, -I $(srctree)/usr/dummy-include) \ $(if $(target-can-compile), -include $< -include $<); \ $(PERL) $(src)/headers_check.pl $(obj) $<; \ touch $@ From aad94ba683adc6ff7ff4e29ae48184b42782dd97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Fri, 27 Feb 2026 07:38:04 +0100 Subject: [PATCH 09/35] kbuild: uapi: provide stub includes for some libc headers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some UAPI headers incorrectly use libc headers. To compile-test these UAPI headers, their respective libc dependencies need to be present. Not all kernel toolchains provide these headers, reducing test coverage. Introduce some stub headers which provide just enough symbols to test all UAPI headers. Most headers are empty anyways, as their symbols are only used in macros which are not actually evaluated. As these headers are only ever used with newer kernel toolchains, they can defer to compiler builtins in many cases. As more UAPI headers are cleaned up to not require these stubs anymore, they can be removed again. Signed-off-by: Thomas Weißschuh Reviewed-by: Nathan Chancellor Reviewed-by: Nicolas Schier Tested-by: Nicolas Schier Acked-by: Arnd Bergmann Link: https://patch.msgid.link/20260227-kbuild-uapi-libc-v1-6-c17de0d19776@weissschuh.net Signed-off-by: Nicolas Schier --- usr/dummy-include/endian.h | 0 usr/dummy-include/limits.h | 8 ++++++++ usr/dummy-include/netinet/if_ether.h | 0 usr/dummy-include/netinet/in.h | 0 usr/dummy-include/stddef.h | 8 ++++++++ usr/dummy-include/stdint.h | 17 +++++++++++++++++ usr/dummy-include/string.h | 12 ++++++++++++ usr/dummy-include/sys/ioctl.h | 0 usr/dummy-include/sys/socket.h | 12 ++++++++++++ usr/dummy-include/sys/time.h | 3 +++ usr/dummy-include/sys/types.h | 0 usr/dummy-include/time.h | 0 usr/dummy-include/unistd.h | 0 13 files changed, 60 insertions(+) create mode 100644 usr/dummy-include/endian.h create mode 100644 usr/dummy-include/limits.h create mode 100644 usr/dummy-include/netinet/if_ether.h create mode 100644 usr/dummy-include/netinet/in.h create mode 100644 usr/dummy-include/stddef.h create mode 100644 usr/dummy-include/stdint.h create mode 100644 usr/dummy-include/string.h create mode 100644 usr/dummy-include/sys/ioctl.h create mode 100644 usr/dummy-include/sys/socket.h create mode 100644 usr/dummy-include/sys/time.h create mode 100644 usr/dummy-include/sys/types.h create mode 100644 usr/dummy-include/time.h create mode 100644 usr/dummy-include/unistd.h diff --git a/usr/dummy-include/endian.h b/usr/dummy-include/endian.h new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/usr/dummy-include/limits.h b/usr/dummy-include/limits.h new file mode 100644 index 000000000000..49b17c10c7b6 --- /dev/null +++ b/usr/dummy-include/limits.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _DUMMY_LIMITS_H +#define _DUMMY_LIMITS_H + +#define INT_MAX ((int)(~0U >> 1)) +#define INT_MIN (-INT_MAX - 1) + +#endif /* _DUMMY_LIMITS_H */ diff --git a/usr/dummy-include/netinet/if_ether.h b/usr/dummy-include/netinet/if_ether.h new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/usr/dummy-include/netinet/in.h b/usr/dummy-include/netinet/in.h new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/usr/dummy-include/stddef.h b/usr/dummy-include/stddef.h new file mode 100644 index 000000000000..a61703d1c896 --- /dev/null +++ b/usr/dummy-include/stddef.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _DUMMY_STDDEF_H +#define _DUMMY_STDDEF_H + +#define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER) +#define NULL ((void *)0) + +#endif /* _DUMMY_STDDEF_H */ diff --git a/usr/dummy-include/stdint.h b/usr/dummy-include/stdint.h new file mode 100644 index 000000000000..93b1962fd08c --- /dev/null +++ b/usr/dummy-include/stdint.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _DUMMY_STDINT_H +#define _DUMMY_STDINT_H + +#include + +typedef __u64 uint64_t; +typedef __u32 uint32_t; +typedef __u16 uint16_t; +typedef __u8 uint8_t; + +typedef __s64 int64_t; +typedef __s32 int32_t; +typedef __s16 int16_t; +typedef __s8 int8_t; + +#endif /* _DUMMY_STDINT_H */ diff --git a/usr/dummy-include/string.h b/usr/dummy-include/string.h new file mode 100644 index 000000000000..e059808d309a --- /dev/null +++ b/usr/dummy-include/string.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _DUMMY_STRING_H +#define _DUMMY_STRING_H + +#include + +#define memset(_s, _c, _n) __builtin_memset(_s, _c, _n) +#define memcpy(_dest, _src, _n) __builtin_memcpy(_dest, _src, _n) + +#define strlen(_s) __builtin_strlen(_s) + +#endif /* _DUMMY_STRING_H */ diff --git a/usr/dummy-include/sys/ioctl.h b/usr/dummy-include/sys/ioctl.h new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/usr/dummy-include/sys/socket.h b/usr/dummy-include/sys/socket.h new file mode 100644 index 000000000000..748751f9e53e --- /dev/null +++ b/usr/dummy-include/sys/socket.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _DUMMY_SYS_SOCKET_H +#define _DUMMY_SYS_SOCKET_H + +#include + +struct sockaddr { + __kernel_sa_family_t sa_family; /* address family, AF_xxx */ + char sa_data[14]; /* 14 bytes of protocol address */ +}; + +#endif /* _DUMMY_SYS_SOCKET_H */ diff --git a/usr/dummy-include/sys/time.h b/usr/dummy-include/sys/time.h new file mode 100644 index 000000000000..9817b8afb1a6 --- /dev/null +++ b/usr/dummy-include/sys/time.h @@ -0,0 +1,3 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include diff --git a/usr/dummy-include/sys/types.h b/usr/dummy-include/sys/types.h new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/usr/dummy-include/time.h b/usr/dummy-include/time.h new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/usr/dummy-include/unistd.h b/usr/dummy-include/unistd.h new file mode 100644 index 000000000000..e69de29bb2d1 From 579f103fb9c570e54c81866627efb1ea1e00a26b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Fri, 27 Feb 2026 07:38:05 +0100 Subject: [PATCH 10/35] kbuild: uapi: use custom stub headers instead of libc ones MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now that custom stub headers are provided for all libc headers used from the UAPI headers, the dependency on the toolchain libc can be dropped. Signed-off-by: Thomas Weißschuh Reviewed-by: Nathan Chancellor Reviewed-by: Nicolas Schier Tested-by: Nicolas Schier Acked-by: Arnd Bergmann Link: https://patch.msgid.link/20260227-kbuild-uapi-libc-v1-7-c17de0d19776@weissschuh.net Signed-off-by: Nicolas Schier --- usr/include/Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/usr/include/Makefile b/usr/include/Makefile index fdc79cffcc97..d352280b0e4a 100644 --- a/usr/include/Makefile +++ b/usr/include/Makefile @@ -138,14 +138,13 @@ endif always-y := $(patsubst $(obj)/%.h,%.hdrtest, $(shell find $(obj) -name '*.h' 2>/dev/null)) target-no-libc = $(filter-out $(uses-libc), $*.h) -target-can-compile = $(and $(filter-out $(no-header-test), $*.h), \ - $(or $(CONFIG_CC_CAN_LINK), $(target-no-libc))) +target-can-compile = $(filter-out $(no-header-test), $*.h) # Include the header twice to detect missing include guard. quiet_cmd_hdrtest = HDRTEST $< cmd_hdrtest = \ $(CC) $(c_flags) -fsyntax-only -Werror -x c /dev/null \ - $(if $(target-no-libc), -nostdinc, -I $(srctree)/usr/dummy-include) \ + -nostdinc $(if $(target-no-libc), , -I $(srctree)/usr/dummy-include) \ $(if $(target-can-compile), -include $< -include $<); \ $(PERL) $(src)/headers_check.pl $(obj) $<; \ touch $@ From 510c7a57362d4620f66cf8a083363b8e20bd9778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Fri, 27 Feb 2026 07:38:06 +0100 Subject: [PATCH 11/35] kbuild: uapi: simplify libc dependency logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The only left user of the condition inverts it. Invert the condition completely and simplify its user. Signed-off-by: Thomas Weißschuh Reviewed-by: Nathan Chancellor Reviewed-by: Nicolas Schier Tested-by: Nicolas Schier Acked-by: Arnd Bergmann Link: https://patch.msgid.link/20260227-kbuild-uapi-libc-v1-8-c17de0d19776@weissschuh.net Signed-off-by: Nicolas Schier --- usr/include/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr/include/Makefile b/usr/include/Makefile index d352280b0e4a..845d06b63c2b 100644 --- a/usr/include/Makefile +++ b/usr/include/Makefile @@ -137,14 +137,14 @@ endif always-y := $(patsubst $(obj)/%.h,%.hdrtest, $(shell find $(obj) -name '*.h' 2>/dev/null)) -target-no-libc = $(filter-out $(uses-libc), $*.h) +target-libc = $(filter $(uses-libc), $*.h) target-can-compile = $(filter-out $(no-header-test), $*.h) # Include the header twice to detect missing include guard. quiet_cmd_hdrtest = HDRTEST $< cmd_hdrtest = \ $(CC) $(c_flags) -fsyntax-only -Werror -x c /dev/null \ - -nostdinc $(if $(target-no-libc), , -I $(srctree)/usr/dummy-include) \ + -nostdinc $(if $(target-libc), -I $(srctree)/usr/dummy-include) \ $(if $(target-can-compile), -include $< -include $<); \ $(PERL) $(src)/headers_check.pl $(obj) $<; \ touch $@ From febb5c81fa8df999e24877f6226f8cba9f06ce6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Fri, 27 Feb 2026 07:38:07 +0100 Subject: [PATCH 12/35] kbuild: uapi: remove now unneeded guard headers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test compilation does not allow usage of the toolchain headers anymore, so these dummy headers are not needed anymore. Signed-off-by: Thomas Weißschuh Reviewed-by: Nathan Chancellor Reviewed-by: Nicolas Schier Tested-by: Nicolas Schier Acked-by: Arnd Bergmann Link: https://patch.msgid.link/20260227-kbuild-uapi-libc-v1-9-c17de0d19776@weissschuh.net Signed-off-by: Nicolas Schier --- usr/dummy-include/stdbool.h | 7 ------- usr/dummy-include/stdlib.h | 7 ------- 2 files changed, 14 deletions(-) delete mode 100644 usr/dummy-include/stdbool.h delete mode 100644 usr/dummy-include/stdlib.h diff --git a/usr/dummy-include/stdbool.h b/usr/dummy-include/stdbool.h deleted file mode 100644 index 54ff9e9c90ac..000000000000 --- a/usr/dummy-include/stdbool.h +++ /dev/null @@ -1,7 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -#ifndef _STDBOOL_H -#define _STDBOOL_H - -#error "Please do not include from exported headers" - -#endif /* _STDBOOL_H */ diff --git a/usr/dummy-include/stdlib.h b/usr/dummy-include/stdlib.h deleted file mode 100644 index e8c21888e371..000000000000 --- a/usr/dummy-include/stdlib.h +++ /dev/null @@ -1,7 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -#ifndef _STDLIB_H -#define _STDLIB_H - -#error "Please do not include from exported headers" - -#endif /* _STDLIB_H */ From ec4c28276c140a9338700041112f64f8d7ccc3e9 Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Mon, 23 Feb 2026 12:10:28 -0700 Subject: [PATCH 13/35] kbuild: Consolidate C dialect options Introduce CC_FLAGS_DIALECT to make it easier to update the various places in the tree that rely on the GNU C standard and Microsoft extensions flags atomically. All remaining uses of '-std=gnu11' and '-fms-extensions' are in the tools directory (which has its own build system) and other standalone Makefiles. This will allow the kernel to use a narrower option to enable the Microsoft anonymous tagged structure extension in a simpler manner. Place the CC_FLAGS_DIALECT block after the configuration include (so that a future change can move the selection of the flag to Kconfig) but before the arch/$(SRCARCH)/Makefile include (so that CC_FLAGS_DIALECT is available for use in those Makefiles). Signed-off-by: Nathan Chancellor Reviewed-by: Nicolas Schier Acked-by: Ard Biesheuvel Acked-by: Helge Deller # parisc Link: https://patch.msgid.link/20260223-fms-anonymous-structs-v1-1-8ee406d3c36c@kernel.org Signed-off-by: Nicolas Schier --- Makefile | 16 ++++++++++++---- arch/arm64/kernel/vdso32/Makefile | 3 +-- arch/loongarch/vdso/Makefile | 2 +- arch/parisc/boot/compressed/Makefile | 2 +- arch/powerpc/boot/Makefile | 3 +-- arch/s390/Makefile | 3 +-- arch/s390/purgatory/Makefile | 3 +-- arch/x86/Makefile | 6 +----- arch/x86/boot/compressed/Makefile | 6 +----- drivers/firmware/efi/libstub/Makefile | 3 +-- scripts/Makefile.warn | 5 ----- 11 files changed, 21 insertions(+), 31 deletions(-) diff --git a/Makefile b/Makefile index e944c6e71e81..06ff3032a6bc 100644 --- a/Makefile +++ b/Makefile @@ -587,7 +587,6 @@ LINUXINCLUDE := \ KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE KBUILD_CFLAGS := -KBUILD_CFLAGS += -std=gnu11 KBUILD_CFLAGS += -fshort-wchar KBUILD_CFLAGS += -funsigned-char KBUILD_CFLAGS += -fno-common @@ -790,6 +789,18 @@ ifdef need-config include $(objtree)/include/config/auto.conf endif +CC_FLAGS_DIALECT := -std=gnu11 +# Allow including a tagged struct or union anonymously in another struct/union. +CC_FLAGS_DIALECT += -fms-extensions +# Clang enables warnings about GNU and Microsoft extensions by default, disable +# them because this is expected with the above options. +ifdef CONFIG_CC_IS_CLANG +CC_FLAGS_DIALECT += -Wno-gnu +CC_FLAGS_DIALECT += -Wno-microsoft-anon-tag +endif +export CC_FLAGS_DIALECT +KBUILD_CFLAGS += $(CC_FLAGS_DIALECT) + ifeq ($(KBUILD_EXTMOD),) # Objects we will link into vmlinux / subdirs we need to visit core-y := @@ -1093,9 +1104,6 @@ NOSTDINC_FLAGS += -nostdinc # perform bounds checking. KBUILD_CFLAGS += $(call cc-option, -fstrict-flex-arrays=3) -# Allow including a tagged struct or union anonymously in another struct/union. -KBUILD_CFLAGS += -fms-extensions - # disable invalid "can't wrap" optimizations for signed / pointers KBUILD_CFLAGS += -fno-strict-overflow diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile index 9d0efed91414..bea3675fa668 100644 --- a/arch/arm64/kernel/vdso32/Makefile +++ b/arch/arm64/kernel/vdso32/Makefile @@ -63,7 +63,7 @@ VDSO_CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ $(filter -Werror,$(KBUILD_CPPFLAGS)) \ -Werror-implicit-function-declaration \ -Wno-format-security \ - -std=gnu11 -fms-extensions + $(CC_FLAGS_DIALECT) VDSO_CFLAGS += -O2 # Some useful compiler-dependent flags from top-level Makefile VDSO_CFLAGS += $(call cc32-option,-Wno-pointer-sign) @@ -71,7 +71,6 @@ VDSO_CFLAGS += -fno-strict-overflow VDSO_CFLAGS += $(call cc32-option,-Werror=strict-prototypes) VDSO_CFLAGS += -Werror=date-time VDSO_CFLAGS += $(call cc32-option,-Werror=incompatible-pointer-types) -VDSO_CFLAGS += $(if $(CONFIG_CC_IS_CLANG),-Wno-microsoft-anon-tag) # Compile as THUMB2 or ARM. Unwinding via frame-pointers in THUMB2 is # unreliable. diff --git a/arch/loongarch/vdso/Makefile b/arch/loongarch/vdso/Makefile index 520f1513f07d..904ef4a0d826 100644 --- a/arch/loongarch/vdso/Makefile +++ b/arch/loongarch/vdso/Makefile @@ -24,7 +24,7 @@ endif cflags-vdso := $(ccflags-vdso) \ -isystem $(shell $(CC) -print-file-name=include) \ $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \ - -std=gnu11 -fms-extensions -O2 -g -fno-strict-aliasing -fno-common -fno-builtin \ + $(CC_FLAGS_DIALECT) -O2 -g -fno-strict-aliasing -fno-common -fno-builtin \ -fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \ $(call cc-option, -fno-asynchronous-unwind-tables) \ $(call cc-option, -fno-stack-protector) diff --git a/arch/parisc/boot/compressed/Makefile b/arch/parisc/boot/compressed/Makefile index f8481e4e9d21..14eefb5ed5d1 100644 --- a/arch/parisc/boot/compressed/Makefile +++ b/arch/parisc/boot/compressed/Makefile @@ -18,7 +18,7 @@ KBUILD_CFLAGS += -fno-PIE -mno-space-regs -mdisable-fpregs -Os ifndef CONFIG_64BIT KBUILD_CFLAGS += -mfast-indirect-calls endif -KBUILD_CFLAGS += -std=gnu11 -fms-extensions +KBUILD_CFLAGS += $(CC_FLAGS_DIALECT) LDFLAGS_vmlinux := -X -e startup --as-needed -T $(obj)/vmlinux: $(obj)/vmlinux.lds $(addprefix $(obj)/, $(OBJECTS)) $(LIBGCC) FORCE diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile index f1a4761ebd44..7ee0fa2d3371 100644 --- a/arch/powerpc/boot/Makefile +++ b/arch/powerpc/boot/Makefile @@ -70,7 +70,7 @@ BOOTCPPFLAGS := -nostdinc $(LINUXINCLUDE) BOOTCPPFLAGS += -isystem $(shell $(BOOTCC) -print-file-name=include) BOOTCFLAGS := $(BOOTTARGETFLAGS) \ - -std=gnu11 -fms-extensions \ + $(CC_FLAGS_DIALECT) \ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ -fno-strict-aliasing -O2 \ -msoft-float -mno-altivec -mno-vsx \ @@ -86,7 +86,6 @@ BOOTARFLAGS := -crD ifdef CONFIG_CC_IS_CLANG BOOTCFLAGS += $(CLANG_FLAGS) -BOOTCFLAGS += -Wno-microsoft-anon-tag BOOTAFLAGS += $(CLANG_FLAGS) endif diff --git a/arch/s390/Makefile b/arch/s390/Makefile index d78ad6885ca2..c8d16aca1cdc 100644 --- a/arch/s390/Makefile +++ b/arch/s390/Makefile @@ -22,7 +22,7 @@ KBUILD_AFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -D__ASSEMBLY__ ifndef CONFIG_AS_IS_LLVM KBUILD_AFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),$(aflags_dwarf)) endif -KBUILD_CFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -O2 -mpacked-stack -std=gnu11 -fms-extensions +KBUILD_CFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -O2 -mpacked-stack $(CC_FLAGS_DIALECT) KBUILD_CFLAGS_DECOMPRESSOR += -DDISABLE_BRANCH_PROFILING -D__NO_FORTIFY KBUILD_CFLAGS_DECOMPRESSOR += -D__DECOMPRESSOR KBUILD_CFLAGS_DECOMPRESSOR += -Wno-pointer-sign @@ -35,7 +35,6 @@ KBUILD_CFLAGS_DECOMPRESSOR += $(call cc-disable-warning, address-of-packed-membe KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),-g) KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO_DWARF4), $(call cc-option, -gdwarf-4,)) KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_CC_NO_ARRAY_BOUNDS),-Wno-array-bounds) -KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_CC_IS_CLANG),-Wno-microsoft-anon-tag) UTS_MACHINE := s390x STACK_SIZE := $(if $(CONFIG_KASAN),65536,$(if $(CONFIG_KMSAN),65536,16384)) diff --git a/arch/s390/purgatory/Makefile b/arch/s390/purgatory/Makefile index 61d240a37633..95a8ac45b67e 100644 --- a/arch/s390/purgatory/Makefile +++ b/arch/s390/purgatory/Makefile @@ -13,7 +13,7 @@ CFLAGS_sha256.o := -D__NO_FORTIFY $(obj)/mem.o: $(srctree)/arch/s390/lib/mem.S FORCE $(call if_changed_rule,as_o_S) -KBUILD_CFLAGS := -std=gnu11 -fms-extensions -fno-strict-aliasing -Wall -Wstrict-prototypes +KBUILD_CFLAGS := $(CC_FLAGS_DIALECT) -fno-strict-aliasing -Wall -Wstrict-prototypes KBUILD_CFLAGS += -Wno-pointer-sign -Wno-sign-compare KBUILD_CFLAGS += -fno-zero-initialized-in-bss -fno-builtin -ffreestanding KBUILD_CFLAGS += -Os -m64 -msoft-float -fno-common @@ -21,7 +21,6 @@ KBUILD_CFLAGS += -fno-stack-protector KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING KBUILD_CFLAGS += -D__DISABLE_EXPORTS KBUILD_CFLAGS += $(CLANG_FLAGS) -KBUILD_CFLAGS += $(if $(CONFIG_CC_IS_CLANG),-Wno-microsoft-anon-tag) KBUILD_CFLAGS += $(call cc-option,-fno-PIE) KBUILD_CFLAGS += $(call cc-option, -Wno-default-const-init-unsafe) KBUILD_AFLAGS := $(filter-out -DCC_USING_EXPOLINE,$(KBUILD_AFLAGS)) diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 5f881460a8b5..46fec0b08487 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -48,7 +48,7 @@ endif # How to compile the 16-bit code. Note we always compile for -march=i386; # that way we can complain to the user if the CPU is insufficient. -REALMODE_CFLAGS := -std=gnu11 -fms-extensions -m16 -g -Os \ +REALMODE_CFLAGS := $(CC_FLAGS_DIALECT) -m16 -g -Os \ -DDISABLE_BRANCH_PROFILING -D__DISABLE_EXPORTS \ -Wall -Wstrict-prototypes -march=i386 -mregparm=3 \ -fno-strict-aliasing -fomit-frame-pointer -fno-pic \ @@ -59,10 +59,6 @@ REALMODE_CFLAGS += -fno-stack-protector REALMODE_CFLAGS += -Wno-address-of-packed-member REALMODE_CFLAGS += $(cc_stack_align4) REALMODE_CFLAGS += $(CLANG_FLAGS) -ifdef CONFIG_CC_IS_CLANG -REALMODE_CFLAGS += -Wno-gnu -REALMODE_CFLAGS += -Wno-microsoft-anon-tag -endif export REALMODE_CFLAGS # BITS is used as extension for files which are available in a 32 bit diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile index 68f9d7a1683b..8924196927bf 100644 --- a/arch/x86/boot/compressed/Makefile +++ b/arch/x86/boot/compressed/Makefile @@ -25,7 +25,7 @@ targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \ # avoid errors with '-march=i386', and future flags may depend on the target to # be valid. KBUILD_CFLAGS := -m$(BITS) -O2 $(CLANG_FLAGS) -KBUILD_CFLAGS += -std=gnu11 -fms-extensions +KBUILD_CFLAGS += $(CC_FLAGS_DIALECT) KBUILD_CFLAGS += -fno-strict-aliasing -fPIE KBUILD_CFLAGS += -Wundef KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING @@ -36,10 +36,6 @@ KBUILD_CFLAGS += -mno-mmx -mno-sse KBUILD_CFLAGS += -ffreestanding -fshort-wchar KBUILD_CFLAGS += -fno-stack-protector KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) -ifdef CONFIG_CC_IS_CLANG -KBUILD_CFLAGS += -Wno-gnu -KBUILD_CFLAGS += -Wno-microsoft-anon-tag -endif KBUILD_CFLAGS += -Wno-pointer-sign KBUILD_CFLAGS += -fno-asynchronous-unwind-tables KBUILD_CFLAGS += -D__DISABLE_EXPORTS diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile index e386ffd009b7..fbb8d4e33256 100644 --- a/drivers/firmware/efi/libstub/Makefile +++ b/drivers/firmware/efi/libstub/Makefile @@ -11,12 +11,11 @@ cflags-y := $(KBUILD_CFLAGS) cflags-$(CONFIG_X86_32) := -march=i386 cflags-$(CONFIG_X86_64) := -mcmodel=small -cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ -std=gnu11 -fms-extensions \ +cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ $(CC_FLAGS_DIALECT) \ -fPIC -fno-strict-aliasing -mno-red-zone \ -mno-mmx -mno-sse -fshort-wchar \ -Wno-pointer-sign \ $(call cc-disable-warning, address-of-packed-member) \ - $(if $(CONFIG_CC_IS_CLANG),-Wno-gnu -Wno-microsoft-anon-tag) \ -fno-asynchronous-unwind-tables \ $(CLANG_FLAGS) diff --git a/scripts/Makefile.warn b/scripts/Makefile.warn index 5567da6c7dfe..e77ca875aea4 100644 --- a/scripts/Makefile.warn +++ b/scripts/Makefile.warn @@ -28,11 +28,6 @@ endif KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds ifdef CONFIG_CC_IS_CLANG -# The kernel builds with '-std=gnu11' and '-fms-extensions' so use of GNU and -# Microsoft extensions is acceptable. -KBUILD_CFLAGS += -Wno-gnu -KBUILD_CFLAGS += -Wno-microsoft-anon-tag - # Clang checks for overflow/truncation with '%p', while GCC does not: # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111219 KBUILD_CFLAGS += $(call cc-option, -Wno-format-overflow-non-kprintf) From 0d3fccf68d9873a3c824fb70be0dbb2c4642aa90 Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Mon, 23 Feb 2026 12:10:29 -0700 Subject: [PATCH 14/35] kbuild: Use '-fms-anonymous-structs' if it is available Clang recently added '-fms-anonymous-structs' [1] to specifically enable the Microsoft tagged anonymous structure / union extension, for which the kernel added '-fms-extensions' in commit c4781dc3d1cf ("Kbuild: enable -fms-extensions"). Switch to this more narrow option if it is available, which would have helped avoid the issue addressed by commit a6773e6932cb ("jfs: Rename _inline to avoid conflict with clang's '-fms-extensions'"). GCC has talked about adding a similar flag [2] as well but potentially naming it differently. Move the selection of the flag to Kconfig to make it easier to use cc-option (as CC_FLAGS_DIALECT may be used in arch Makefiles, which may be too early for cc-option in Kbuild) and customize based on compiler flag names. Link: https://github.com/llvm/llvm-project/commit/c391efe6fb67329d8e2fd231692cc6b0ea902956 [1] Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123623 [2] Signed-off-by: Nathan Chancellor Reviewed-by: Nicolas Schier Reviewed-by: Kees Cook Acked-by: Ard Biesheuvel Acked-by: Helge Deller # parisc Link: https://patch.msgid.link/20260223-fms-anonymous-structs-v1-2-8ee406d3c36c@kernel.org Signed-off-by: Nicolas Schier --- Makefile | 2 +- init/Kconfig | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 06ff3032a6bc..1d5c0ab9ed5c 100644 --- a/Makefile +++ b/Makefile @@ -791,7 +791,7 @@ endif CC_FLAGS_DIALECT := -std=gnu11 # Allow including a tagged struct or union anonymously in another struct/union. -CC_FLAGS_DIALECT += -fms-extensions +CC_FLAGS_DIALECT += $(CONFIG_CC_MS_EXTENSIONS) # Clang enables warnings about GNU and Microsoft extensions by default, disable # them because this is expected with the above options. ifdef CONFIG_CC_IS_CLANG diff --git a/init/Kconfig b/init/Kconfig index c25869cf59c1..c4282d049463 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -960,6 +960,11 @@ config CC_IMPLICIT_FALLTHROUGH default "-Wimplicit-fallthrough=5" if CC_IS_GCC && $(cc-option,-Wimplicit-fallthrough=5) default "-Wimplicit-fallthrough" if CC_IS_CLANG && $(cc-option,-Wunreachable-code-fallthrough) +config CC_MS_EXTENSIONS + string + default "-fms-anonymous-structs" if $(cc-option,-fms-anonymous-structs) + default "-fms-extensions" + # Currently, disable gcc-10+ array-bounds globally. # It's still broken in gcc-13, so no upper bound yet. config GCC10_NO_ARRAY_BOUNDS From dc3b90751d6ffa8865e09a81645a539b9de6d642 Mon Sep 17 00:00:00 2001 From: Yonghong Song Date: Fri, 6 Mar 2026 21:02:50 -0800 Subject: [PATCH 15/35] kbuild: Reduce the number of compiler-generated suffixes for clang thin-lto build The current clang thin-lto build often produces lots of symbols with suffix. The following is a partial list of such function call symbols: ... ethnl_module_fw_flash_ntf.llvm.7631589765585346066 __nf_conntrack_alloc.llvm.6438426151906658917 tcp_can_early_drop.llvm.11937612064648250727 tcp_print_conntrack.llvm.11937612064648250727 ... In my particular build with current bpf-next, the number of '*.llvm.' function calls is 1212. As the side effect of cross-file inlining, some static variables may be promoted with '*.llvm.' as well. In my same setup, the number of variables with such suffixes is 9. Such symbols make kernel live patching difficult since - a minor code change will change the hash and then the '*.llvm.' symbol becomes another one with a different hash. Sometimes, maybe the suffix is gone. - a previous source-level symbol may become a one with suffix after live patching code. In [1], Song Liu suggested to reduce the number of '*.llvm.' functions to make live patch easier. In respond of this, I implemented this in llvm ([2]). The same thin-lto build with [2] only has two symbols with suffix: m_stop.llvm.14460341347352036579 m_next.llvm.14460341347352036579 This should make live patch much easier. To support suffix symbol reduction, two lld flags are necessary to enable this feature in kernel: - Flag '--lto-whole-program-visibility' is needed as it ensures that all non-assembly files are available in the same thin-lto lld, which is true for kernel. - Flag '-mllvm -always-rename-promoted-locals=false' is needed to enable suffix reduction. Currently in llvm [1], only process mode is supported. There is another distributed mode (across different processes or even different machines) which is not supported yet ([2]). The kernel uses process mode so it should work. The assembly files may have some global functions/data which may potentially conflict with thin-lto global symbols after the above two flags. But such assembly global symbols are limited and tend to be uniquely named for its context. Hence the conflict with globals in non-assembly codes is rare. If indeed the conflict happens, we can rename either of them to avoid conflicts. Nathan Chancellor suggested the following under thin-lto: KBUILD_LDFLAGS += $(call ld-option,--lto-whole-program-visibility -mllvm -always-rename-promoted-locals=false) The '-mllvm -always-rename-promoted-locals=false' flag is only available for llvm23. So for llvm22 or earlier, the above KBUILD_LDFLAGS will ignore those two flags. For llvm23 and later, two flags will be added to KBUILD_LDFLAGS. [1] https://lpc.events/event/19/contributions/2212 [2] https://github.com/llvm/llvm-project/pull/178587 Signed-off-by: Yonghong Song Acked-by: Song Liu Acked-by: Josh Poimboeuf Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor # build Link: https://patch.msgid.link/20260307050250.3767489-1-yonghong.song@linux.dev Signed-off-by: Nicolas Schier --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 1d5c0ab9ed5c..6b8e9fca2752 100644 --- a/Makefile +++ b/Makefile @@ -1045,6 +1045,7 @@ endif ifdef CONFIG_LTO_CLANG ifdef CONFIG_LTO_CLANG_THIN CC_FLAGS_LTO := -flto=thin -fsplit-lto-unit +KBUILD_LDFLAGS += $(call ld-option,--lto-whole-program-visibility -mllvm -always-rename-promoted-locals=false) else CC_FLAGS_LTO := -flto endif From c9bb03ac2c66bc5aa81b51ea0792477524c2763a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Thu, 5 Mar 2026 13:04:07 +0100 Subject: [PATCH 16/35] kbuild: reduce output spam when building out of tree MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The execution of $(call cmd,makefile) will print 'GEN Makefile' on each build, even if the Makefile is not effectively changed. Use a filechk command instead, so a message is only printed on changes. The Makefile is now created even if the build is aborted due to an unclean working tree. That should not make a difference in practice. Signed-off-by: Thomas Weißschuh Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor Link: https://patch.msgid.link/20260305-kbuild-makefile-spam-v1-1-910f6cf218a1@linutronix.de Signed-off-by: Nicolas Schier --- Makefile | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 6b8e9fca2752..a8d8ed711f9b 100644 --- a/Makefile +++ b/Makefile @@ -675,14 +675,19 @@ print_env_for_makefile = \ echo "export KBUILD_OUTPUT = $(CURDIR)" endif -quiet_cmd_makefile = GEN Makefile - cmd_makefile = { \ +filechk_makefile = { \ echo "\# Automatically generated by $(abs_srctree)/Makefile: don't edit"; \ $(print_env_for_makefile); \ echo "include $(abs_srctree)/Makefile"; \ - } > Makefile + } -outputmakefile: +$(objtree)/Makefile: FORCE + $(call filechk,makefile) + +# Prevent $(srcroot)/Makefile from inhibiting the rule to run. +PHONY += $(objtree)/Makefile + +outputmakefile: $(objtree)/Makefile ifeq ($(KBUILD_EXTMOD),) @if [ -f $(srctree)/.config -o \ -d $(srctree)/include/config -o \ @@ -703,7 +708,6 @@ else fi endif $(Q)ln -fsn $(srcroot) source - $(call cmd,makefile) $(Q)test -e .gitignore || \ { echo "# this is build directory, ignore it"; echo "*"; } > .gitignore endif From a261f6dff3c1653c19c065c3b3650c625447b8a7 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Fri, 6 Mar 2026 17:33:07 +0100 Subject: [PATCH 17/35] check-uapi: link into shared objects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While testing ABI changes across all architectures, I found that abidiff sometimes produces nonsensical output. Further debugging identified missing or broken libelf support for architecture specific relocations in ET_REL binaries as the source of the problem[1]. Change the script to no longer produce a relocatable object file but instead create a shared library for each header. This makes abidiff work for all of the architectures in upstream linux kernels. Link: https://sourceware.org/bugzilla/show_bug.cgi?id=33869 Cc: stable@vger.kernel.org Signed-off-by: Arnd Bergmann Reviewed-by: Thomas Weißschuh Acked-by: Nathan Chancellor Link: https://patch.msgid.link/20260306163309.2015837-2-arnd@kernel.org Signed-off-by: Nicolas Schier --- scripts/check-uapi.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/check-uapi.sh b/scripts/check-uapi.sh index 955581735cb3..9fa45cbdecc2 100755 --- a/scripts/check-uapi.sh +++ b/scripts/check-uapi.sh @@ -178,8 +178,11 @@ do_compile() { local -r inc_dir="$1" local -r header="$2" local -r out="$3" - printf "int main(void) { return 0; }\n" | \ - "$CC" -c \ + printf "int f(void) { return 0; }\n" | \ + "$CC" \ + -shared \ + -nostdlib \ + -fPIC \ -o "$out" \ -x c \ -O0 \ From 9940ec38f12ed8ffe8edc1944f9bbdf9b9a4689e Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Fri, 6 Mar 2026 17:33:08 +0100 Subject: [PATCH 18/35] check-uapi: honor ${CROSS_COMPILE} setting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When ${CROSS_COMPILE} is set, but ${CC} is not set, the logic in check-uapi.sh is different from the top-level Makefile, which defaults to using the cross gcc. This leads to using the native gcc instead of the cross version, resulting in unexpected false-positive and false-negative output. Use the same logic here that we use in Kbuild for consistency. Signed-off-by: Arnd Bergmann Reviewed-by: Thomas Weißschuh Acked-by: Nathan Chancellor Link: https://patch.msgid.link/20260306163309.2015837-3-arnd@kernel.org Signed-off-by: Nicolas Schier --- scripts/check-uapi.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/check-uapi.sh b/scripts/check-uapi.sh index 9fa45cbdecc2..e4d120eb09e3 100755 --- a/scripts/check-uapi.sh +++ b/scripts/check-uapi.sh @@ -33,9 +33,10 @@ Options: -v Verbose operation (print more information about each header being checked). Environmental args: - ABIDIFF Custom path to abidiff binary - CC C compiler (default is "gcc") - ARCH Target architecture for the UAPI check (default is host arch) + ABIDIFF Custom path to abidiff binary + CROSS_COMPILE Toolchain prefix for compiler + CC C compiler (default is "\${CROSS_COMPILE}gcc") + ARCH Target architecture for the UAPI check (default is host arch) Exit codes: $SUCCESS) Success @@ -198,7 +199,7 @@ do_compile() { run_make_headers_install() { local -r ref="$1" local -r install_dir="$(get_header_tree "$ref")" - make -j "$MAX_THREADS" ARCH="$ARCH" INSTALL_HDR_PATH="$install_dir" \ + make -j "$MAX_THREADS" CROSS_COMPILE="${CROSS_COMPILE}" ARCH="$ARCH" INSTALL_HDR_PATH="$install_dir" \ headers_install > /dev/null } @@ -407,7 +408,7 @@ min_version_is_satisfied() { # Make sure we have the tools we need and the arguments make sense check_deps() { ABIDIFF="${ABIDIFF:-abidiff}" - CC="${CC:-gcc}" + CC="${CC:-${CROSS_COMPILE}gcc}" ARCH="${ARCH:-$(uname -m)}" if [ "$ARCH" = "x86_64" ]; then ARCH="x86" From bb25b5635e90e33c8c1c4ef231d4d7351c06be49 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Fri, 6 Mar 2026 17:33:09 +0100 Subject: [PATCH 19/35] check-uapi: use dummy libc includes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Based on Thomas Weißschuh's series to kernel headers to no longer require an installed libc when build testing the uapi headers, the same can now be done for the scripts/check-uapi.sh script. The only required change here is to add the usr/dummy-include include path. Link: https://lore.kernel.org/lkml/20260227-kbuild-uapi-libc-v1-0-c17de0d19776@weissschuh.net/ [1] Signed-off-by: Arnd Bergmann Reviewed-by: Thomas Weißschuh Acked-by: Nathan Chancellor Link: https://patch.msgid.link/20260306163309.2015837-4-arnd@kernel.org Signed-off-by: Nicolas Schier --- scripts/check-uapi.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/check-uapi.sh b/scripts/check-uapi.sh index e4d120eb09e3..c8beec58871c 100755 --- a/scripts/check-uapi.sh +++ b/scripts/check-uapi.sh @@ -191,6 +191,7 @@ do_compile() { -fno-eliminate-unused-debug-types \ -g \ "-I${inc_dir}" \ + "-Iusr/dummy-include" \ -include "$header" \ - } From 55d68ec5b9ba004764acaa3291871513102b4fd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Mon, 16 Mar 2026 17:51:58 +0100 Subject: [PATCH 20/35] kbuild: uapi: move some compiler arguments out of the command definition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Simplify the definition of cmd_hdrtest by moving some of it to a new variable. This will both enable the upcoming reuse of those flags and also the extension of cmd_hdrtest. Signed-off-by: Thomas Weißschuh Reviewed-by: Nathan Chancellor Link: https://patch.msgid.link/20260316-kbuild-uapi-c-v2-1-35d6d0ed863f@weissschuh.net Signed-off-by: Nicolas Schier --- usr/include/Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/usr/include/Makefile b/usr/include/Makefile index 845d06b63c2b..0b1c9a4b0477 100644 --- a/usr/include/Makefile +++ b/usr/include/Makefile @@ -140,11 +140,13 @@ always-y := $(patsubst $(obj)/%.h,%.hdrtest, $(shell find $(obj) -name '*.h' 2>/ target-libc = $(filter $(uses-libc), $*.h) target-can-compile = $(filter-out $(no-header-test), $*.h) +hdrtest-flags = -fsyntax-only -Werror \ + -nostdinc $(if $(target-libc), -I $(srctree)/usr/dummy-include) + # Include the header twice to detect missing include guard. quiet_cmd_hdrtest = HDRTEST $< cmd_hdrtest = \ - $(CC) $(c_flags) -fsyntax-only -Werror -x c /dev/null \ - -nostdinc $(if $(target-libc), -I $(srctree)/usr/dummy-include) \ + $(CC) $(c_flags) $(hdrtest-flags) -x c /dev/null \ $(if $(target-can-compile), -include $< -include $<); \ $(PERL) $(src)/headers_check.pl $(obj) $<; \ touch $@ From cf822413093e4fdf17ce12f10f3983b1d5f8b659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Mon, 16 Mar 2026 17:51:59 +0100 Subject: [PATCH 21/35] kbuild: uapi: move all include path flags together MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The argument to add the root of the UAPI header tree to the include path is separated from the other arguments concerning the include path. Move all include path arguments together for more consistency and balanced line lengths. Signed-off-by: Thomas Weißschuh Reviewed-by: Nathan Chancellor Link: https://patch.msgid.link/20260316-kbuild-uapi-c-v2-2-35d6d0ed863f@weissschuh.net Signed-off-by: Nicolas Schier --- usr/include/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr/include/Makefile b/usr/include/Makefile index 0b1c9a4b0477..74f5ba24bb29 100644 --- a/usr/include/Makefile +++ b/usr/include/Makefile @@ -8,7 +8,7 @@ # We cannot go as far as adding -Wpedantic since it emits too many warnings. UAPI_CFLAGS := -std=c90 -Werror=implicit-function-declaration -override c_flags = $(KBUILD_USERCFLAGS) $(UAPI_CFLAGS) -Wp,-MMD,$(depfile) -I $(obj) +override c_flags = $(KBUILD_USERCFLAGS) $(UAPI_CFLAGS) -Wp,-MMD,$(depfile) # The following are excluded for now because they fail to build. # @@ -141,7 +141,7 @@ target-libc = $(filter $(uses-libc), $*.h) target-can-compile = $(filter-out $(no-header-test), $*.h) hdrtest-flags = -fsyntax-only -Werror \ - -nostdinc $(if $(target-libc), -I $(srctree)/usr/dummy-include) + -nostdinc -I $(obj) $(if $(target-libc), -I $(srctree)/usr/dummy-include) # Include the header twice to detect missing include guard. quiet_cmd_hdrtest = HDRTEST $< From b4ec38cb739e9419ddb7310f6c49fb6d7bc39c1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Mon, 16 Mar 2026 17:52:00 +0100 Subject: [PATCH 22/35] kbuild: uapi: handle UML in architecture-specific exclusion lists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When building User Mode Linux SRCARCH is set to 'um', while the actual underlying architecture is provided in HEADER_ARCH. Allow the exclusion lists to work on UML by comparing against HEADER_ARCH when that is available. Signed-off-by: Thomas Weißschuh Reviewed-by: Nathan Chancellor Link: https://patch.msgid.link/20260316-kbuild-uapi-c-v2-3-35d6d0ed863f@weissschuh.net Signed-off-by: Nicolas Schier --- usr/include/Makefile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/usr/include/Makefile b/usr/include/Makefile index 74f5ba24bb29..edeaf9d778c4 100644 --- a/usr/include/Makefile +++ b/usr/include/Makefile @@ -7,6 +7,7 @@ # -std=c90 (equivalent to -ansi) catches the violation of those. # We cannot go as far as adding -Wpedantic since it emits too many warnings. UAPI_CFLAGS := -std=c90 -Werror=implicit-function-declaration +UAPI_ARCH := $(or $(HEADER_ARCH),$(SRCARCH)) override c_flags = $(KBUILD_USERCFLAGS) $(UAPI_CFLAGS) -Wp,-MMD,$(depfile) @@ -48,11 +49,11 @@ no-header-test += xen/privcmd.h # More headers are broken in some architectures -ifneq ($(filter arc openrisc xtensa nios2, $(SRCARCH)),) +ifneq ($(filter arc openrisc xtensa nios2, $(UAPI_ARCH)),) no-header-test += linux/bpf_perf_event.h endif -ifeq ($(SRCARCH),sparc) +ifeq ($(UAPI_ARCH),sparc) no-header-test += asm/uctx.h no-header-test += asm/fbio.h endif @@ -122,15 +123,15 @@ uses-libc += linux/wireless.h uses-libc += regulator/regulator.h uses-libc += scsi/fc/fc_els.h -ifeq ($(SRCARCH),hexagon) +ifeq ($(UAPI_ARCH),hexagon) uses-libc += asm/sigcontext.h endif -ifeq ($(SRCARCH),nios2) +ifeq ($(UAPI_ARCH),nios2) uses-libc += asm/ptrace.h endif -ifeq ($(SRCARCH),s390) +ifeq ($(UAPI_ARCH),s390) uses-libc += asm/chpid.h uses-libc += asm/chsc.h endif From b187c1a1a0513593663b1adee0340d41d833d16d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Mon, 16 Mar 2026 17:52:01 +0100 Subject: [PATCH 23/35] kbuild: uapi: provide a C++ compatible dummy definition of NULL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NULL works differently in C++ compared to C. To allow testing the UAPI headers against C++ compilers, provide a variant of NULL which works with those. Signed-off-by: Thomas Weißschuh Reviewed-by: Nathan Chancellor Link: https://patch.msgid.link/20260316-kbuild-uapi-c-v2-4-35d6d0ed863f@weissschuh.net Signed-off-by: Nicolas Schier --- usr/dummy-include/stddef.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/usr/dummy-include/stddef.h b/usr/dummy-include/stddef.h index a61703d1c896..525489daffe2 100644 --- a/usr/dummy-include/stddef.h +++ b/usr/dummy-include/stddef.h @@ -3,6 +3,11 @@ #define _DUMMY_STDDEF_H #define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER) + +#ifdef __cplusplus +#define NULL 0 +#else #define NULL ((void *)0) +#endif #endif /* _DUMMY_STDDEF_H */ From dcc99abebfa1e9ca70f8af8695b6682ad7597bf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Mon, 16 Mar 2026 17:52:02 +0100 Subject: [PATCH 24/35] kbuild: uapi: also test UAPI headers against C++ compilers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit C++ language requirements differ from those of C. Also test the headers against C++ compilers to make sure no errors creep in accidentally. Signed-off-by: Thomas Weißschuh Reviewed-by: Nathan Chancellor Link: https://patch.msgid.link/20260316-kbuild-uapi-c-v2-5-35d6d0ed863f@weissschuh.net Signed-off-by: Nicolas Schier --- usr/include/Makefile | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/usr/include/Makefile b/usr/include/Makefile index edeaf9d778c4..ee69dd9d970e 100644 --- a/usr/include/Makefile +++ b/usr/include/Makefile @@ -10,6 +10,7 @@ UAPI_CFLAGS := -std=c90 -Werror=implicit-function-declaration UAPI_ARCH := $(or $(HEADER_ARCH),$(SRCARCH)) override c_flags = $(KBUILD_USERCFLAGS) $(UAPI_CFLAGS) -Wp,-MMD,$(depfile) +cxx_flags = $(filter-out -Wmissing-prototypes -Wstrict-prototypes -std=%, $(KBUILD_USERCFLAGS)) -std=c++98 # The following are excluded for now because they fail to build. # @@ -61,6 +62,27 @@ endif # asm-generic/*.h is used by asm/*.h, and should not be included directly no-header-test += asm-generic/% +# The following are not compatible with C++. +# +# Do not add a new header to the list without legitimate reason. +# Please consider to fix the header first. +# +# Sorted alphabetically. +no-header-test-cxx += linux/auto_dev-ioctl.h +no-header-test-cxx += linux/map_to_14segment.h +no-header-test-cxx += linux/map_to_7segment.h +no-header-test-cxx += linux/netfilter/xt_sctp.h +no-header-test-cxx += linux/target_core_user.h +no-header-test-cxx += linux/vhost.h +no-header-test-cxx += linux/vhost_types.h +no-header-test-cxx += linux/virtio_net.h +no-header-test-cxx += linux/virtio_ring.h +no-header-test-cxx += scsi/fc/fc_els.h + +ifeq ($(UAPI_ARCH),x86) +no-header-test-cxx += asm/elf.h +endif + # The following are using libc header and types. # # Do not add a new header to the list without legitimate reason. @@ -138,8 +160,12 @@ endif always-y := $(patsubst $(obj)/%.h,%.hdrtest, $(shell find $(obj) -name '*.h' 2>/dev/null)) +# $(cc-option) forces '-x c' which breaks '-x c++' detection. +cc-can-compile-cxx := $(call try-run,$(CC) $(CLANG_FLAGS) -c -x c++ /dev/null -o "$$TMP", 1) + target-libc = $(filter $(uses-libc), $*.h) target-can-compile = $(filter-out $(no-header-test), $*.h) +target-can-compile-cxx = $(and $(cc-can-compile-cxx), $(target-can-compile), $(filter-out $(no-header-test-cxx), $*.h)) hdrtest-flags = -fsyntax-only -Werror \ -nostdinc -I $(obj) $(if $(target-libc), -I $(srctree)/usr/dummy-include) @@ -149,6 +175,8 @@ quiet_cmd_hdrtest = HDRTEST $< cmd_hdrtest = \ $(CC) $(c_flags) $(hdrtest-flags) -x c /dev/null \ $(if $(target-can-compile), -include $< -include $<); \ + $(if $(target-can-compile-cxx), \ + $(CC) $(cxx_flags) $(hdrtest-flags) -x c++ /dev/null -include $<;) \ $(PERL) $(src)/headers_check.pl $(obj) $<; \ touch $@ From efa13f43c550e612c78e5dba7d776a6d5d5fed9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Tue, 31 Mar 2026 19:50:19 +0200 Subject: [PATCH 25/35] kbuild: vdso_install: split out the readelf invocation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Split up the logic as some upcoming changes to the readelf invocation would create a very long line otherwise. Signed-off-by: Thomas Weißschuh Reviewed-by: Nicolas Schier Reviewed-by: Nathan Chancellor Link: https://patch.msgid.link/20260331-kbuild-vdso-install-v2-1-606d0dc6beca@weissschuh.net Signed-off-by: Nicolas Schier --- scripts/Makefile.vdsoinst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/Makefile.vdsoinst b/scripts/Makefile.vdsoinst index ac85f9a4a569..214c561651cf 100644 --- a/scripts/Makefile.vdsoinst +++ b/scripts/Makefile.vdsoinst @@ -21,7 +21,8 @@ $$(dest): $(1) FORCE # Some architectures create .build-id symlinks ifneq ($(filter arm s390 sparc x86, $(SRCARCH)),) -link := $(install-dir)/.build-id/$$(shell $(READELF) -n $(1) | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p').debug +build-id-file := $$(shell $(READELF) -n $(1) | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p') +link := $(install-dir)/.build-id/$$(build-id-file).debug __default: $$(link) $$(link): $$(dest) FORCE From ec2137476df8c9551d8bad4c3b22b540035164c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Tue, 31 Mar 2026 19:50:20 +0200 Subject: [PATCH 26/35] kbuild: vdso_install: hide readelf warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If 'readelf -n' encounters a note it does not recognize it emits a warning. This for example happens when inspecting a compat vDSO for which the main kernel toolchain was not used. However the relevant build ID note is always readable, so the warnings are pointless. Hide the warnings to make it possible to extract build IDs for more architectures in the future. Signed-off-by: Thomas Weißschuh Reviewed-by: Nicolas Schier Reviewed-by: Nathan Chancellor Link: https://patch.msgid.link/20260331-kbuild-vdso-install-v2-2-606d0dc6beca@weissschuh.net Signed-off-by: Nicolas Schier --- scripts/Makefile.vdsoinst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/Makefile.vdsoinst b/scripts/Makefile.vdsoinst index 214c561651cf..aed153b3120b 100644 --- a/scripts/Makefile.vdsoinst +++ b/scripts/Makefile.vdsoinst @@ -21,7 +21,7 @@ $$(dest): $(1) FORCE # Some architectures create .build-id symlinks ifneq ($(filter arm s390 sparc x86, $(SRCARCH)),) -build-id-file := $$(shell $(READELF) -n $(1) | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p') +build-id-file := $$(shell $(READELF) -n $(1) 2>/dev/null | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p') link := $(install-dir)/.build-id/$$(build-id-file).debug __default: $$(link) From e4fb2342358c36b461632382fae9dfa11a957897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Tue, 31 Mar 2026 19:50:21 +0200 Subject: [PATCH 27/35] kbuild: vdso_install: gracefully handle images without build ID MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the vDSO does not contain a build ID, skip the symlink step. This will allow the removal of the explicit list of architectures. Signed-off-by: Thomas Weißschuh Reviewed-by: Nicolas Schier Reviewed-by: Nathan Chancellor Link: https://patch.msgid.link/20260331-kbuild-vdso-install-v2-3-606d0dc6beca@weissschuh.net Signed-off-by: Nicolas Schier --- scripts/Makefile.vdsoinst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/Makefile.vdsoinst b/scripts/Makefile.vdsoinst index aed153b3120b..3de70218b8d4 100644 --- a/scripts/Makefile.vdsoinst +++ b/scripts/Makefile.vdsoinst @@ -22,12 +22,15 @@ $$(dest): $(1) FORCE # Some architectures create .build-id symlinks ifneq ($(filter arm s390 sparc x86, $(SRCARCH)),) build-id-file := $$(shell $(READELF) -n $(1) 2>/dev/null | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p') + +ifneq ($$(build-id-file),) link := $(install-dir)/.build-id/$$(build-id-file).debug __default: $$(link) $$(link): $$(dest) FORCE $$(call cmd,symlink) endif +endif endef From 5471878477a3e9d4851f39c8becbb39d290d0192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Tue, 31 Mar 2026 19:50:22 +0200 Subject: [PATCH 28/35] kbuild: vdso_install: drop build ID architecture allow-list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Many architectures which do generate build IDs are missing from this list. For example arm64, riscv, loongarch, mips. Now that errors from readelf and binaries without any build ID are handled gracefully, the allow-list is not necessary anymore, drop it. Signed-off-by: Thomas Weißschuh Reviewed-by: Nicolas Schier Reviewed-by: Nathan Chancellor Link: https://patch.msgid.link/20260331-kbuild-vdso-install-v2-4-606d0dc6beca@weissschuh.net Signed-off-by: Nicolas Schier --- scripts/Makefile.vdsoinst | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/Makefile.vdsoinst b/scripts/Makefile.vdsoinst index 3de70218b8d4..d9f7243217bc 100644 --- a/scripts/Makefile.vdsoinst +++ b/scripts/Makefile.vdsoinst @@ -19,8 +19,6 @@ __default: $$(dest) $$(dest): $(1) FORCE $$(call cmd,install) -# Some architectures create .build-id symlinks -ifneq ($(filter arm s390 sparc x86, $(SRCARCH)),) build-id-file := $$(shell $(READELF) -n $(1) 2>/dev/null | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p') ifneq ($$(build-id-file),) @@ -30,7 +28,6 @@ __default: $$(link) $$(link): $$(dest) FORCE $$(call cmd,symlink) endif -endif endef From 9fba6131aeaec0637fd8636b9fb49b6596214525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Thu, 2 Apr 2026 16:36:18 +0200 Subject: [PATCH 29/35] checksyscalls: move path to reference table to a variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An upcoming patch will need to reuse this path. Move it into a reusable variable. Signed-off-by: Thomas Weißschuh Acked-by: Arnd Bergmann Reviewed-by: Nicolas Schier Link: https://patch.msgid.link/20260402-kbuild-missing-syscalls-v3-1-6641be1de2db@weissschuh.net Signed-off-by: Nicolas Schier --- scripts/checksyscalls.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/checksyscalls.sh b/scripts/checksyscalls.sh index 1e5d2eeb726d..9becaf8d7b78 100755 --- a/scripts/checksyscalls.sh +++ b/scripts/checksyscalls.sh @@ -10,6 +10,8 @@ # checksyscalls.sh gcc gcc-options # +reference_table="$(dirname $0)/../arch/x86/entry/syscalls/syscall_32.tbl" + ignore_list() { cat << EOF #include @@ -269,5 +271,5 @@ syscall_list() { done } -(ignore_list && syscall_list $(dirname $0)/../arch/x86/entry/syscalls/syscall_32.tbl) | \ +(ignore_list && syscall_list ${reference_table}) | \ $* -Wno-error -Wno-unused-macros -E -x c - > /dev/null From e856b6ca14765501a47eb497f7e35dc7efefce5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Sat, 4 Apr 2026 14:23:10 +0200 Subject: [PATCH 30/35] checksyscalls: fail on all intermediate errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make sure that a failure of any intermediate step also fails the overall execution. Link: https://sashiko.dev/#/patchset/20260402-kbuild-missing-syscalls-v3-0-6641be1de2db%40weissschuh.net Signed-off-by: Thomas Weißschuh Link: https://patch.msgid.link/20260404-checksyscalls-set-e-v1-1-206400e78668@weissschuh.net Signed-off-by: Nicolas Schier --- scripts/checksyscalls.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/checksyscalls.sh b/scripts/checksyscalls.sh index 9becaf8d7b78..b2ab3b1d76b8 100755 --- a/scripts/checksyscalls.sh +++ b/scripts/checksyscalls.sh @@ -10,6 +10,8 @@ # checksyscalls.sh gcc gcc-options # +set -e + reference_table="$(dirname $0)/../arch/x86/entry/syscalls/syscall_32.tbl" ignore_list() { From b34db3fa85c4d34ceee5231cd27e587153bc25ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Thu, 2 Apr 2026 16:36:19 +0200 Subject: [PATCH 31/35] checksyscalls: only run when necessary MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently checksyscalls.sh is unconditionally executed during each build. Most of these executions are unnecessary. Only run checksyscalls.sh if one of its inputs have changed. This new logic does not work for the multiple invocations done for MIPS. The effect is that checksyscalls.sh is still executed unconditionally. However this is not worse than before. Signed-off-by: Thomas Weißschuh Acked-by: Arnd Bergmann Reviewed-by: Nicolas Schier Link: https://patch.msgid.link/20260402-kbuild-missing-syscalls-v3-2-6641be1de2db@weissschuh.net Signed-off-by: Nicolas Schier --- Kbuild | 12 +++++++++--- scripts/checksyscalls.sh | 5 +++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Kbuild b/Kbuild index 13324b4bbe23..515cc6a27477 100644 --- a/Kbuild +++ b/Kbuild @@ -47,12 +47,18 @@ $(rq-offsets-file): kernel/sched/rq-offsets.s FORCE # Check for missing system calls +missing-syscalls-file := .tmp_missing-syscalls + +targets += $(missing-syscalls-file) + quiet_cmd_syscalls = CALL $< - cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags) + cmd_syscalls = DEPFILE=$(depfile) $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags); touch $@ + +$(missing-syscalls-file): scripts/checksyscalls.sh $(rq-offsets-file) FORCE + $(call if_changed_dep,syscalls) PHONY += missing-syscalls -missing-syscalls: scripts/checksyscalls.sh $(rq-offsets-file) - $(call cmd,syscalls) +missing-syscalls: $(missing-syscalls-file) # Check the manual modification of atomic headers diff --git a/scripts/checksyscalls.sh b/scripts/checksyscalls.sh index b2ab3b1d76b8..e2970421c1ff 100755 --- a/scripts/checksyscalls.sh +++ b/scripts/checksyscalls.sh @@ -275,3 +275,8 @@ syscall_list() { (ignore_list && syscall_list ${reference_table}) | \ $* -Wno-error -Wno-unused-macros -E -x c - > /dev/null + +# For fixdep +if [ -n "${DEPFILE}" ]; then + echo "${0}: ${0} ${reference_table}" >> "${DEPFILE}" +fi From c7c55f0e1667aa25c0ac047bd873159722358f6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Thu, 2 Apr 2026 16:36:20 +0200 Subject: [PATCH 32/35] checksyscalls: move instance functionality into generic code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On MIPS the checksyscalls.sh script may be executed multiple times. Currently these multiple executions are executed on each build as kbuild see that the commands have changed each time. Use a dedicated stamp file for each different invocation to avoid the spurious executions. Signed-off-by: Thomas Weißschuh Acked-by: Arnd Bergmann Reviewed-by: Nicolas Schier Link: https://patch.msgid.link/20260402-kbuild-missing-syscalls-v3-3-6641be1de2db@weissschuh.net Signed-off-by: Nicolas Schier --- Kbuild | 4 ++-- arch/mips/Makefile | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Kbuild b/Kbuild index 515cc6a27477..a6a0192dea08 100644 --- a/Kbuild +++ b/Kbuild @@ -47,11 +47,11 @@ $(rq-offsets-file): kernel/sched/rq-offsets.s FORCE # Check for missing system calls -missing-syscalls-file := .tmp_missing-syscalls +missing-syscalls-file := .tmp_missing-syscalls$(missing_syscalls_instance) targets += $(missing-syscalls-file) -quiet_cmd_syscalls = CALL $< +quiet_cmd_syscalls = CALL $< $(addprefix for ,$(missing_syscalls_instance)) cmd_syscalls = DEPFILE=$(depfile) $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags); touch $@ $(missing-syscalls-file): scripts/checksyscalls.sh $(rq-offsets-file) FORCE diff --git a/arch/mips/Makefile b/arch/mips/Makefile index d9057e29bc62..6705fa5d9211 100644 --- a/arch/mips/Makefile +++ b/arch/mips/Makefile @@ -421,12 +421,10 @@ CLEAN_FILES += vmlinux.32 vmlinux.64 archprepare: ifdef CONFIG_MIPS32_N32 - @$(kecho) ' Checking missing-syscalls for N32' - $(Q)$(MAKE) $(build)=. missing-syscalls missing_syscalls_flags="-mabi=n32" + $(Q)$(MAKE) $(build)=. missing-syscalls missing_syscalls_instance="N32" missing_syscalls_flags="-mabi=n32" endif ifdef CONFIG_MIPS32_O32 - @$(kecho) ' Checking missing-syscalls for O32' - $(Q)$(MAKE) $(build)=. missing-syscalls missing_syscalls_flags="-mabi=32" + $(Q)$(MAKE) $(build)=. missing-syscalls missing_syscalls_instance="O32" missing_syscalls_flags="-mabi=32" endif install: From 2fb62d915476e3c2253f009ed0f45b82f5f46124 Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Fri, 13 Mar 2026 16:37:29 -0700 Subject: [PATCH 33/35] Documentation: kbuild: Update the debug information notes in reproducible-builds.rst The debug information part of the "Absolute filenames" section in the reproducible builds document only mentions providing '-fdebug-prefix-map' to KCFLAGS but it needs to be provided to KAFLAGS as well since debug information has been generated for assembly files for a long time. Additionally, mention that the build directory may also appear as an absolute path in the debug information (via DW_AT_comp_dir), so it needs to be overridden via '-fdebug-prefix-map' as well. Reported-by: Alexander Coffin Closes: https://lore.kernel.org/b8dfe7035d19fd611b9be55ee3145fdb@purelymail.com/ Signed-off-by: Nathan Chancellor Link: https://patch.msgid.link/20260313-kbuild-docs-repro-builds-fdebug-prefix-map-updates-v1-1-3aeeef7fa710@kernel.org Signed-off-by: Nicolas Schier --- Documentation/kbuild/reproducible-builds.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Documentation/kbuild/reproducible-builds.rst b/Documentation/kbuild/reproducible-builds.rst index 96d208e578cd..bc1eb82211df 100644 --- a/Documentation/kbuild/reproducible-builds.rst +++ b/Documentation/kbuild/reproducible-builds.rst @@ -50,8 +50,10 @@ Absolute filenames ------------------ When the kernel is built out-of-tree, debug information may include -absolute filenames for the source files. This must be overridden by -including the ``-fdebug-prefix-map`` option in the `KCFLAGS`_ variable. +absolute filenames for the source files and build directory. These must +be overridden by including a ``-fdebug-prefix-map`` option for each in +the `KCFLAGS`_ and `KAFLAGS`_ variables to cover both ``.c`` and ``.S`` +files. Depending on the compiler used, the ``__FILE__`` macro may also expand to an absolute filename in an out-of-tree build. Kbuild automatically @@ -135,6 +137,7 @@ See ``scripts/setlocalversion`` for details. .. _KBUILD_BUILD_TIMESTAMP: kbuild.html#kbuild-build-timestamp .. _KBUILD_BUILD_USER and KBUILD_BUILD_HOST: kbuild.html#kbuild-build-user-kbuild-build-host .. _KCFLAGS: kbuild.html#kcflags +.. _KAFLAGS: kbuild.html#kaflags .. _prefix-map options: https://reproducible-builds.org/docs/build-path/ .. _Reproducible Builds project: https://reproducible-builds.org/ .. _SOURCE_DATE_EPOCH: https://reproducible-builds.org/docs/source-date-epoch/ From d13a089d823e6b9a5a63728c4d1617ba1aca2740 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Mon, 30 Mar 2026 20:57:35 +0900 Subject: [PATCH 34/35] kconfig: forbid multiple entries with the same symbol in a choice Commit 6a859f1a19d1 ("powerpc: unify two CONFIG_POWERPC64_CPU entries in the same choice block") removed the only occurrence of this tricky use case. Disallow this pattern in choice_check_sanity() and revert commit 4d46b5b623e0 ("kconfig: fix infinite loop in sym_calc_choice()"). Signed-off-by: Masahiro Yamada Reviewed-by: Nathan Chancellor Link: https://patch.msgid.link/20260330115736.1559962-1-masahiroy@kernel.org Reviewed-by: Nicolas Schier Signed-off-by: Nicolas Schier --- scripts/kconfig/parser.y | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y index 6d1bbee38f5d..5fb6f07b6ad2 100644 --- a/scripts/kconfig/parser.y +++ b/scripts/kconfig/parser.y @@ -159,14 +159,8 @@ config_stmt: config_entry_start config_option_list yynerrs++; } - /* - * If the same symbol appears twice in a choice block, the list - * node would be added twice, leading to a broken linked list. - * list_empty() ensures that this symbol has not yet added. - */ - if (list_empty(¤t_entry->sym->choice_link)) - list_add_tail(¤t_entry->sym->choice_link, - ¤t_choice->choice_members); + list_add_tail(¤t_entry->sym->choice_link, + ¤t_choice->choice_members); } printd(DEBUG_PARSE, "%s:%d:endconfig\n", cur_filename, cur_lineno); @@ -546,11 +540,10 @@ static int choice_check_sanity(const struct menu *menu) ret = -1; } - if (prop->menu != menu && prop->type == P_PROMPT && - prop->menu->parent != menu->parent) { + if (prop->menu != menu && prop->type == P_PROMPT) { fprintf(stderr, "%s:%d: error: %s", prop->filename, prop->lineno, - "choice value has a prompt outside its choice group\n"); + "choice value must not have a prompt in another entry\n"); ret = -1; } } From 404927758daac5ec4594071e033c1fa6ee9ca9b6 Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Mon, 30 Mar 2026 17:09:08 -0700 Subject: [PATCH 35/35] kbuild: expand inlining hints with -fdiagnostics-show-inlining-chain Clang recently added -fdiagnostics-show-inlining-chain [1] to improve the visibility of inlining chains in diagnostics. This is particularly useful for CONFIG_FORTIFY_SOURCE where detections can happen deep in inlined functions. Add this flag to KBUILD_CFLAGS under a cc-option so it is enabled if the compiler supports it. Note that GCC does not have an equivalent flag as it supports a similar diagnostic structure unconditionally. Link: https://github.com/llvm/llvm-project/pull/174892 [1] Link: https://github.com/ClangBuiltLinux/linux/issues/1571 Signed-off-by: Justin Stitt Reviewed-by: Nathan Chancellor Reviewed-by: Kees Cook Link: https://patch.msgid.link/20260330-kbuild-show-inlining-v2-1-c0c481a4ea7b@google.com Signed-off-by: Nicolas Schier --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index a8d8ed711f9b..c9d6f84ff489 100644 --- a/Makefile +++ b/Makefile @@ -987,6 +987,10 @@ KBUILD_CFLAGS += $(call cc-option, -fno-stack-clash-protection) # Get details on warnings generated due to GCC value tracking. KBUILD_CFLAGS += $(call cc-option, -fdiagnostics-show-context=2) +# Show inlining notes for __attribute__((warning/error)) call chains. +# GCC supports this unconditionally while Clang 23+ provides a flag. +KBUILD_CFLAGS += $(call cc-option, -fdiagnostics-show-inlining-chain) + # Clear used registers at func exit (to reduce data lifetime and ROP gadgets). ifdef CONFIG_ZERO_CALL_USED_REGS KBUILD_CFLAGS += -fzero-call-used-regs=used-gpr