public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/9] kbuild: uapi: remove usage of toolchain headers
@ 2026-02-27  6:37 Thomas Weißschuh
  2026-02-27  6:37 ` [PATCH 1/9] hexagon: uapi: Fix structure alignment attribute Thomas Weißschuh
                   ` (12 more replies)
  0 siblings, 13 replies; 16+ messages in thread
From: Thomas Weißschuh @ 2026-02-27  6:37 UTC (permalink / raw)
  To: Nathan Chancellor, Nicolas Schier, Brian Cain
  Cc: linux-kbuild, linux-kernel, Arnd Bergmann, linux-hexagon,
	Thomas Weißschuh, Thomas Weißschuh

Currently the test compilation of some UAPI headers requires a toolchain
libc headers. Remove that dependency.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
Thomas Weißschuh (9):
      hexagon: uapi: Fix structure alignment attribute
      kbuild: uapi: test linux/bpf_perf_event.h on powerpc
      kbuild: uapi: deduplicate linux/bpf_perf_event.h exclusions
      kbuild: uapi: completely exclude linux/bpf_perf_event.h on nios2
      kbuild: uapi: only use dummy-include for headers which use libc
      kbuild: uapi: provide stub includes for some libc headers
      kbuild: uapi: use custom stub headers instead of libc ones
      kbuild: uapi: simplify libc dependency logic
      kbuild: uapi: remove now unneeded guard headers

 arch/hexagon/include/uapi/asm/sigcontext.h |  2 +-
 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/stdbool.h                |  7 -------
 usr/dummy-include/stddef.h                 |  8 ++++++++
 usr/dummy-include/stdint.h                 | 17 +++++++++++++++++
 usr/dummy-include/stdlib.h                 |  7 -------
 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
 usr/include/Makefile                       | 24 +++++-------------------
 17 files changed, 66 insertions(+), 34 deletions(-)
---
base-commit: 93e7204d4b0e7b69ebbceee0dc09092e975cece3
change-id: 20260124-kbuild-uapi-libc-896f152c81d6

Best regards,
-- 
Thomas Weißschuh <linux@weissschuh.net>


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/9] hexagon: uapi: Fix structure alignment attribute
  2026-02-27  6:37 [PATCH 0/9] kbuild: uapi: remove usage of toolchain headers Thomas Weißschuh
@ 2026-02-27  6:37 ` Thomas Weißschuh
  2026-02-27  6:38 ` [PATCH 2/9] kbuild: uapi: test linux/bpf_perf_event.h on powerpc Thomas Weißschuh
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Thomas Weißschuh @ 2026-02-27  6:37 UTC (permalink / raw)
  To: Nathan Chancellor, Nicolas Schier, Brian Cain
  Cc: linux-kbuild, linux-kernel, Arnd Bergmann, linux-hexagon,
	Thomas Weißschuh, Thomas Weißschuh

From: Thomas Weißschuh <thomas.weissschuh@linutronix.de>

__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 <thomas.weissschuh@linutronix.de>
Acked-by: Arnd Bergmann <arnd@arndb.de>
---
 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

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 2/9] kbuild: uapi: test linux/bpf_perf_event.h on powerpc
  2026-02-27  6:37 [PATCH 0/9] kbuild: uapi: remove usage of toolchain headers Thomas Weißschuh
  2026-02-27  6:37 ` [PATCH 1/9] hexagon: uapi: Fix structure alignment attribute Thomas Weißschuh
@ 2026-02-27  6:38 ` Thomas Weißschuh
  2026-02-27  6:38 ` [PATCH 3/9] kbuild: uapi: deduplicate linux/bpf_perf_event.h exclusions Thomas Weißschuh
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Thomas Weißschuh @ 2026-02-27  6:38 UTC (permalink / raw)
  To: Nathan Chancellor, Nicolas Schier, Brian Cain
  Cc: linux-kbuild, linux-kernel, Arnd Bergmann, linux-hexagon,
	Thomas Weißschuh

This header works now, so test it.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 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

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 3/9] kbuild: uapi: deduplicate linux/bpf_perf_event.h exclusions
  2026-02-27  6:37 [PATCH 0/9] kbuild: uapi: remove usage of toolchain headers Thomas Weißschuh
  2026-02-27  6:37 ` [PATCH 1/9] hexagon: uapi: Fix structure alignment attribute Thomas Weißschuh
  2026-02-27  6:38 ` [PATCH 2/9] kbuild: uapi: test linux/bpf_perf_event.h on powerpc Thomas Weißschuh
@ 2026-02-27  6:38 ` Thomas Weißschuh
  2026-02-27  6:38 ` [PATCH 4/9] kbuild: uapi: completely exclude linux/bpf_perf_event.h on nios2 Thomas Weißschuh
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Thomas Weißschuh @ 2026-02-27  6:38 UTC (permalink / raw)
  To: Nathan Chancellor, Nicolas Schier, Brian Cain
  Cc: linux-kbuild, linux-kernel, Arnd Bergmann, linux-hexagon,
	Thomas Weißschuh

This header is excluded for multiple architectures.
Use a single exclusion for all of them.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 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/%
 

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 4/9] kbuild: uapi: completely exclude linux/bpf_perf_event.h on nios2
  2026-02-27  6:37 [PATCH 0/9] kbuild: uapi: remove usage of toolchain headers Thomas Weißschuh
                   ` (2 preceding siblings ...)
  2026-02-27  6:38 ` [PATCH 3/9] kbuild: uapi: deduplicate linux/bpf_perf_event.h exclusions Thomas Weißschuh
@ 2026-02-27  6:38 ` Thomas Weißschuh
  2026-02-27  6:38 ` [PATCH 5/9] kbuild: uapi: only use dummy-include for headers which use libc Thomas Weißschuh
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Thomas Weißschuh @ 2026-02-27  6:38 UTC (permalink / raw)
  To: Nathan Chancellor, Nicolas Schier, Brian Cain
  Cc: linux-kbuild, linux-kernel, Arnd Bergmann, linux-hexagon,
	Thomas Weißschuh

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 <linux@weissschuh.net>
---
 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)

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 5/9] kbuild: uapi: only use dummy-include for headers which use libc
  2026-02-27  6:37 [PATCH 0/9] kbuild: uapi: remove usage of toolchain headers Thomas Weißschuh
                   ` (3 preceding siblings ...)
  2026-02-27  6:38 ` [PATCH 4/9] kbuild: uapi: completely exclude linux/bpf_perf_event.h on nios2 Thomas Weißschuh
@ 2026-02-27  6:38 ` Thomas Weißschuh
  2026-02-27  6:38 ` [PATCH 6/9] kbuild: uapi: provide stub includes for some libc headers Thomas Weißschuh
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Thomas Weißschuh @ 2026-02-27  6:38 UTC (permalink / raw)
  To: Nathan Chancellor, Nicolas Schier, Brian Cain
  Cc: linux-kbuild, linux-kernel, Arnd Bergmann, linux-hexagon,
	Thomas Weißschuh

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 <linux@weissschuh.net>
---
 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 $@

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 6/9] kbuild: uapi: provide stub includes for some libc headers
  2026-02-27  6:37 [PATCH 0/9] kbuild: uapi: remove usage of toolchain headers Thomas Weißschuh
                   ` (4 preceding siblings ...)
  2026-02-27  6:38 ` [PATCH 5/9] kbuild: uapi: only use dummy-include for headers which use libc Thomas Weißschuh
@ 2026-02-27  6:38 ` Thomas Weißschuh
  2026-02-27  6:38 ` [PATCH 7/9] kbuild: uapi: use custom stub headers instead of libc ones Thomas Weißschuh
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Thomas Weißschuh @ 2026-02-27  6:38 UTC (permalink / raw)
  To: Nathan Chancellor, Nicolas Schier, Brian Cain
  Cc: linux-kbuild, linux-kernel, Arnd Bergmann, linux-hexagon,
	Thomas Weißschuh

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 <linux@weissschuh.net>
---
 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(+)

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 <linux/types.h>
+
+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 <stddef.h>
+
+#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 <linux/socket.h>
+
+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 <linux/time.h>
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

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 7/9] kbuild: uapi: use custom stub headers instead of libc ones
  2026-02-27  6:37 [PATCH 0/9] kbuild: uapi: remove usage of toolchain headers Thomas Weißschuh
                   ` (5 preceding siblings ...)
  2026-02-27  6:38 ` [PATCH 6/9] kbuild: uapi: provide stub includes for some libc headers Thomas Weißschuh
@ 2026-02-27  6:38 ` Thomas Weißschuh
  2026-02-27  6:38 ` [PATCH 8/9] kbuild: uapi: simplify libc dependency logic Thomas Weißschuh
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Thomas Weißschuh @ 2026-02-27  6:38 UTC (permalink / raw)
  To: Nathan Chancellor, Nicolas Schier, Brian Cain
  Cc: linux-kbuild, linux-kernel, Arnd Bergmann, linux-hexagon,
	Thomas Weißschuh

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 <linux@weissschuh.net>
---
 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 $@

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 8/9] kbuild: uapi: simplify libc dependency logic
  2026-02-27  6:37 [PATCH 0/9] kbuild: uapi: remove usage of toolchain headers Thomas Weißschuh
                   ` (6 preceding siblings ...)
  2026-02-27  6:38 ` [PATCH 7/9] kbuild: uapi: use custom stub headers instead of libc ones Thomas Weißschuh
@ 2026-02-27  6:38 ` Thomas Weißschuh
  2026-02-27  6:38 ` [PATCH 9/9] kbuild: uapi: remove now unneeded guard headers Thomas Weißschuh
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Thomas Weißschuh @ 2026-02-27  6:38 UTC (permalink / raw)
  To: Nathan Chancellor, Nicolas Schier, Brian Cain
  Cc: linux-kbuild, linux-kernel, Arnd Bergmann, linux-hexagon,
	Thomas Weißschuh

The only left user of the condition inverts it.

Invert the condition completely and simplify its user.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 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 $@

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 9/9] kbuild: uapi: remove now unneeded guard headers
  2026-02-27  6:37 [PATCH 0/9] kbuild: uapi: remove usage of toolchain headers Thomas Weißschuh
                   ` (7 preceding siblings ...)
  2026-02-27  6:38 ` [PATCH 8/9] kbuild: uapi: simplify libc dependency logic Thomas Weißschuh
@ 2026-02-27  6:38 ` Thomas Weißschuh
  2026-02-27  9:18 ` [PATCH 0/9] kbuild: uapi: remove usage of toolchain headers Arnd Bergmann
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Thomas Weißschuh @ 2026-02-27  6:38 UTC (permalink / raw)
  To: Nathan Chancellor, Nicolas Schier, Brian Cain
  Cc: linux-kbuild, linux-kernel, Arnd Bergmann, linux-hexagon,
	Thomas Weißschuh

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 <linux@weissschuh.net>
---
 usr/dummy-include/stdbool.h | 7 -------
 usr/dummy-include/stdlib.h  | 7 -------
 2 files changed, 14 deletions(-)

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 <stdbool.h> 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 <stdlib.h> from exported headers"
-
-#endif /* _STDLIB_H */

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/9] kbuild: uapi: remove usage of toolchain headers
  2026-02-27  6:37 [PATCH 0/9] kbuild: uapi: remove usage of toolchain headers Thomas Weißschuh
                   ` (8 preceding siblings ...)
  2026-02-27  6:38 ` [PATCH 9/9] kbuild: uapi: remove now unneeded guard headers Thomas Weißschuh
@ 2026-02-27  9:18 ` Arnd Bergmann
  2026-02-27  9:38   ` Thomas Weißschuh
  2026-03-05  9:41 ` Nicolas Schier
                   ` (2 subsequent siblings)
  12 siblings, 1 reply; 16+ messages in thread
From: Arnd Bergmann @ 2026-02-27  9:18 UTC (permalink / raw)
  To: Thomas Weißschuh, Nathan Chancellor, Nicolas Schier,
	Brian Cain
  Cc: linux-kbuild, linux-kernel, linux-hexagon, Thomas Weißschuh

On Fri, Feb 27, 2026, at 07:37, Thomas Weißschuh wrote:
> Currently the test compilation of some UAPI headers requires a toolchain
> libc headers. Remove that dependency.
>
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>

Nice work!

Acked-by: Arnd Bergmann <arnd@arndb.de>

I had toyed around with a similar series, using a slightly different
approach of always using the in-kernel nolibc headers, and making
those compile across all architectures (using empty stubs for those
that are missing syscall entry functions).

I don't care much which way we do this as long as we can build test
the headers, but I wonder what your reason was for picking this
approach over the other.

     Arnd

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/9] kbuild: uapi: remove usage of toolchain headers
  2026-02-27  9:18 ` [PATCH 0/9] kbuild: uapi: remove usage of toolchain headers Arnd Bergmann
@ 2026-02-27  9:38   ` Thomas Weißschuh
  2026-02-27 10:04     ` Arnd Bergmann
  0 siblings, 1 reply; 16+ messages in thread
From: Thomas Weißschuh @ 2026-02-27  9:38 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Thomas Weißschuh, Nathan Chancellor, Nicolas Schier,
	Brian Cain, linux-kbuild, linux-kernel, linux-hexagon

On Fri, Feb 27, 2026 at 10:18:41AM +0100, Arnd Bergmann wrote:
> On Fri, Feb 27, 2026, at 07:37, Thomas Weißschuh wrote:
> > Currently the test compilation of some UAPI headers requires a toolchain
> > libc headers. Remove that dependency.
> >
> > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> 
> Nice work!
> 
> Acked-by: Arnd Bergmann <arnd@arndb.de>
> 
> I had toyed around with a similar series, using a slightly different
> approach of always using the in-kernel nolibc headers, and making
> those compile across all architectures (using empty stubs for those
> that are missing syscall entry functions).
> 
> I don't care much which way we do this as long as we can build test
> the headers, but I wonder what your reason was for picking this
> approach over the other.

My goal is to reduce the reliance of the UAPI headers on libc ones.
Hopefully we can remove libc usages from the UAPI headers and then also
drop the compatibility bits from the stub headers. If we use the full nolibc
the message to UAPI authors would not be clear and new dependencies may be
introduced again.


Thomas

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/9] kbuild: uapi: remove usage of toolchain headers
  2026-02-27  9:38   ` Thomas Weißschuh
@ 2026-02-27 10:04     ` Arnd Bergmann
  0 siblings, 0 replies; 16+ messages in thread
From: Arnd Bergmann @ 2026-02-27 10:04 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Thomas Weißschuh, Nathan Chancellor, Nicolas Schier,
	Brian Cain, linux-kbuild, linux-kernel, linux-hexagon

On Fri, Feb 27, 2026, at 10:38, Thomas Weißschuh wrote:
> On Fri, Feb 27, 2026 at 10:18:41AM +0100, Arnd Bergmann wrote:
>> On Fri, Feb 27, 2026, at 07:37, Thomas Weißschuh wrote:
>> 
>> I had toyed around with a similar series, using a slightly different
>> approach of always using the in-kernel nolibc headers, and making
>> those compile across all architectures (using empty stubs for those
>> that are missing syscall entry functions).
>> 
>> I don't care much which way we do this as long as we can build test
>> the headers, but I wonder what your reason was for picking this
>> approach over the other.
>
> My goal is to reduce the reliance of the UAPI headers on libc ones.
> Hopefully we can remove libc usages from the UAPI headers and then also
> drop the compatibility bits from the stub headers. If we use the full nolibc
> the message to UAPI authors would not be clear and new dependencies may be
> introduced again.

Good point, thanks for the clarification!

      Arnd

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/9] kbuild: uapi: remove usage of toolchain headers
  2026-02-27  6:37 [PATCH 0/9] kbuild: uapi: remove usage of toolchain headers Thomas Weißschuh
                   ` (9 preceding siblings ...)
  2026-02-27  9:18 ` [PATCH 0/9] kbuild: uapi: remove usage of toolchain headers Arnd Bergmann
@ 2026-03-05  9:41 ` Nicolas Schier
  2026-03-10  1:00 ` Nathan Chancellor
  2026-03-12 12:08 ` Nicolas Schier
  12 siblings, 0 replies; 16+ messages in thread
From: Nicolas Schier @ 2026-03-05  9:41 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Nathan Chancellor, Nicolas Schier, Brian Cain, linux-kbuild,
	linux-kernel, Arnd Bergmann, linux-hexagon, Thomas Weißschuh

On Fri, 27 Feb 2026 07:37:58 +0100, Thomas Weißschuh <linux@weissschuh.net> wrote:
> Currently the test compilation of some UAPI headers requires a toolchain
> libc headers. Remove that dependency.

Thanks a lot for the highly appreciated clean up!  Having -nostdinc in
UAPI header tests is good thing!

Kind regards,
Nicolas

Reviewed-by: Nicolas Schier <nsc@kernel.org>
Tested-by: Nicolas Schier <nsc@kernel.org>

-- 
Nicolas


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/9] kbuild: uapi: remove usage of toolchain headers
  2026-02-27  6:37 [PATCH 0/9] kbuild: uapi: remove usage of toolchain headers Thomas Weißschuh
                   ` (10 preceding siblings ...)
  2026-03-05  9:41 ` Nicolas Schier
@ 2026-03-10  1:00 ` Nathan Chancellor
  2026-03-12 12:08 ` Nicolas Schier
  12 siblings, 0 replies; 16+ messages in thread
From: Nathan Chancellor @ 2026-03-10  1:00 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Nicolas Schier, Brian Cain, linux-kbuild, linux-kernel,
	Arnd Bergmann, linux-hexagon, Thomas Weißschuh

On Fri, Feb 27, 2026 at 07:37:58AM +0100, Thomas Weißschuh wrote:
> Currently the test compilation of some UAPI headers requires a toolchain
> libc headers. Remove that dependency.
> 
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> ---
> Thomas Weißschuh (9):
>       hexagon: uapi: Fix structure alignment attribute
>       kbuild: uapi: test linux/bpf_perf_event.h on powerpc
>       kbuild: uapi: deduplicate linux/bpf_perf_event.h exclusions
>       kbuild: uapi: completely exclude linux/bpf_perf_event.h on nios2
>       kbuild: uapi: only use dummy-include for headers which use libc
>       kbuild: uapi: provide stub includes for some libc headers
>       kbuild: uapi: use custom stub headers instead of libc ones
>       kbuild: uapi: simplify libc dependency logic
>       kbuild: uapi: remove now unneeded guard headers

This is nice! For the series:

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

Cheers,
Nathan

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/9] kbuild: uapi: remove usage of toolchain headers
  2026-02-27  6:37 [PATCH 0/9] kbuild: uapi: remove usage of toolchain headers Thomas Weißschuh
                   ` (11 preceding siblings ...)
  2026-03-10  1:00 ` Nathan Chancellor
@ 2026-03-12 12:08 ` Nicolas Schier
  12 siblings, 0 replies; 16+ messages in thread
From: Nicolas Schier @ 2026-03-12 12:08 UTC (permalink / raw)
  To: Nathan Chancellor, Brian Cain, Thomas Weißschuh
  Cc: Nicolas Schier, linux-kbuild, linux-kernel, Arnd Bergmann,
	linux-hexagon, Thomas Weißschuh

On Fri, 27 Feb 2026 07:37:58 +0100, Thomas Weißschuh wrote:
> Currently the test compilation of some UAPI headers requires a toolchain
> libc headers. Remove that dependency.

Applied to kbuild/kbuild-next.git (kbuild-next), thanks!

[1/9] hexagon: uapi: Fix structure alignment attribute
      https://git.kernel.org/kbuild/c/47bca1cb
[2/9] kbuild: uapi: test linux/bpf_perf_event.h on powerpc
      https://git.kernel.org/kbuild/c/a8c9d3cc
[3/9] kbuild: uapi: deduplicate linux/bpf_perf_event.h exclusions
      https://git.kernel.org/kbuild/c/45bd8643
[4/9] kbuild: uapi: completely exclude linux/bpf_perf_event.h on nios2
      https://git.kernel.org/kbuild/c/60a16bee
[5/9] kbuild: uapi: only use dummy-include for headers which use libc
      https://git.kernel.org/kbuild/c/0ef1b7a6
[6/9] kbuild: uapi: provide stub includes for some libc headers
      https://git.kernel.org/kbuild/c/aad94ba6
[7/9] kbuild: uapi: use custom stub headers instead of libc ones
      https://git.kernel.org/kbuild/c/579f103f
[8/9] kbuild: uapi: simplify libc dependency logic
      https://git.kernel.org/kbuild/c/510c7a57
[9/9] kbuild: uapi: remove now unneeded guard headers
      https://git.kernel.org/kbuild/c/febb5c81

Please look out for regression or issue reports or other follow up
comments, as they may result in the patch/series getting dropped,
reverted or modified (e.g. trailers).

Best regards,
-- 
Nicolas


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2026-03-12 12:10 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-27  6:37 [PATCH 0/9] kbuild: uapi: remove usage of toolchain headers Thomas Weißschuh
2026-02-27  6:37 ` [PATCH 1/9] hexagon: uapi: Fix structure alignment attribute Thomas Weißschuh
2026-02-27  6:38 ` [PATCH 2/9] kbuild: uapi: test linux/bpf_perf_event.h on powerpc Thomas Weißschuh
2026-02-27  6:38 ` [PATCH 3/9] kbuild: uapi: deduplicate linux/bpf_perf_event.h exclusions Thomas Weißschuh
2026-02-27  6:38 ` [PATCH 4/9] kbuild: uapi: completely exclude linux/bpf_perf_event.h on nios2 Thomas Weißschuh
2026-02-27  6:38 ` [PATCH 5/9] kbuild: uapi: only use dummy-include for headers which use libc Thomas Weißschuh
2026-02-27  6:38 ` [PATCH 6/9] kbuild: uapi: provide stub includes for some libc headers Thomas Weißschuh
2026-02-27  6:38 ` [PATCH 7/9] kbuild: uapi: use custom stub headers instead of libc ones Thomas Weißschuh
2026-02-27  6:38 ` [PATCH 8/9] kbuild: uapi: simplify libc dependency logic Thomas Weißschuh
2026-02-27  6:38 ` [PATCH 9/9] kbuild: uapi: remove now unneeded guard headers Thomas Weißschuh
2026-02-27  9:18 ` [PATCH 0/9] kbuild: uapi: remove usage of toolchain headers Arnd Bergmann
2026-02-27  9:38   ` Thomas Weißschuh
2026-02-27 10:04     ` Arnd Bergmann
2026-03-05  9:41 ` Nicolas Schier
2026-03-10  1:00 ` Nathan Chancellor
2026-03-12 12:08 ` Nicolas Schier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox