* [PATCH 0/5] kbuild: uapi: improvements to header testing
@ 2025-12-23 7:04 Thomas Weißschuh
2025-12-23 7:04 ` [PATCH 1/5] kbuild: uapi: validate that headers do not use libc Thomas Weißschuh
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Thomas Weißschuh @ 2025-12-23 7:04 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier, Brian Cain
Cc: linux-kbuild, linux-kernel, bpf, linux-hexagon,
Thomas Weißschuh
Also validate that UAPI headers do not depend on libc and remove the
dependency on CC_CAN_LINK.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
Thomas Weißschuh (5):
kbuild: uapi: validate that headers do not use libc
hexagon: Drop invalid UAPI header asm/signal.h
kbuild: uapi: don't compile test bpf_perf_event.h on xtensa
kbuild: uapi: split out command conditions into variables
kbuild: uapi: drop dependency on CC_CAN_LINK
arch/hexagon/include/{uapi => }/asm/signal.h | 0
init/Kconfig | 2 +-
usr/include/Makefile | 87 +++++++++++++++++++++++++++-
3 files changed, 87 insertions(+), 2 deletions(-)
---
base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20251203-uapi-nostdinc-64edce85d464
Best regards,
--
Thomas Weißschuh <thomas.weissschuh@linutronix.de>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/5] kbuild: uapi: validate that headers do not use libc
2025-12-23 7:04 [PATCH 0/5] kbuild: uapi: improvements to header testing Thomas Weißschuh
@ 2025-12-23 7:04 ` Thomas Weißschuh
2025-12-23 7:04 ` [PATCH 2/5] hexagon: Drop invalid UAPI header asm/signal.h Thomas Weißschuh
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Thomas Weißschuh @ 2025-12-23 7:04 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier, Brian Cain
Cc: linux-kbuild, linux-kernel, bpf, linux-hexagon,
Thomas Weißschuh
The UAPI headers should be self-contained. That means they should not
use other headers from libc. Currently this is not enforced and various
dependencies have crept in.
Add a check to make sure no new ones are added.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
This currently depends on a fix for linux/fcntl.h:
https://lore.kernel.org/lkml/20251203-uapi-fcntl-v1-1-490c67bf3425@linutronix.de/
---
usr/include/Makefile | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 77 insertions(+)
diff --git a/usr/include/Makefile b/usr/include/Makefile
index d8a508042fed..a9a861ec8702 100644
--- a/usr/include/Makefile
+++ b/usr/include/Makefile
@@ -68,12 +68,89 @@ endif
# asm-generic/*.h is used by asm/*.h, and should not be included directly
no-header-test += asm-generic/%
+# The following are using libc header and types.
+#
+# Do not add a new header to the list without legitimate reason.
+# Please consider to fix the header first.
+#
+# Sorted alphabetically.
+uses-libc += linux/a.out.h
+uses-libc += linux/atmbr2684.h
+uses-libc += linux/auto_dev-ioctl.h
+uses-libc += linux/auto_fs.h
+uses-libc += linux/auto_fs4.h
+uses-libc += linux/btrfs_tree.h
+uses-libc += linux/cec-funcs.h
+uses-libc += linux/cec.h
+uses-libc += linux/dvb/dmx.h
+uses-libc += linux/dvb/video.h
+uses-libc += linux/ethtool.h
+uses-libc += linux/ethtool_netlink.h
+uses-libc += linux/fuse.h
+uses-libc += linux/gsmmux.h
+uses-libc += linux/icmp.h
+uses-libc += linux/idxd.h
+uses-libc += linux/if.h
+uses-libc += linux/if_arp.h
+uses-libc += linux/if_bonding.h
+uses-libc += linux/if_pppox.h
+uses-libc += linux/if_tunnel.h
+uses-libc += linux/input.h
+uses-libc += linux/ip6_tunnel.h
+uses-libc += linux/joystick.h
+uses-libc += linux/llc.h
+uses-libc += linux/mctp.h
+uses-libc += linux/mdio.h
+uses-libc += linux/mii.h
+uses-libc += linux/mptcp.h
+uses-libc += linux/netdevice.h
+uses-libc += linux/netfilter/xt_RATEEST.h
+uses-libc += linux/netfilter/xt_hashlimit.h
+uses-libc += linux/netfilter/xt_physdev.h
+uses-libc += linux/netfilter/xt_rateest.h
+uses-libc += linux/netfilter_arp/arp_tables.h
+uses-libc += linux/netfilter_arp/arpt_mangle.h
+uses-libc += linux/netfilter_bridge.h
+uses-libc += linux/netfilter_bridge/ebtables.h
+uses-libc += linux/netfilter_ipv4.h
+uses-libc += linux/netfilter_ipv4/ip_tables.h
+uses-libc += linux/netfilter_ipv6.h
+uses-libc += linux/netfilter_ipv6/ip6_tables.h
+uses-libc += linux/route.h
+uses-libc += linux/shm.h
+uses-libc += linux/soundcard.h
+uses-libc += linux/string.h
+uses-libc += linux/tipc_config.h
+uses-libc += linux/uhid.h
+uses-libc += linux/uinput.h
+uses-libc += linux/vhost.h
+uses-libc += linux/vhost_types.h
+uses-libc += linux/virtio_ring.h
+uses-libc += linux/wireless.h
+uses-libc += regulator/regulator.h
+uses-libc += scsi/fc/fc_els.h
+
+ifeq ($(SRCARCH),hexagon)
+uses-libc += asm/sigcontext.h
+endif
+
+ifeq ($(SRCARCH),nios2)
+uses-libc += asm/ptrace.h
+uses-libc += linux/bpf_perf_event.h
+endif
+
+ifeq ($(SRCARCH),s390)
+uses-libc += asm/chpid.h
+uses-libc += asm/chsc.h
+endif
+
always-y := $(patsubst $(obj)/%.h,%.hdrtest, $(shell find $(obj) -name '*.h' 2>/dev/null))
# 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 $(filter-out $(uses-libc), $*.h), -nostdinc) \
$(if $(filter-out $(no-header-test), $*.h), -include $< -include $<); \
$(PERL) $(src)/headers_check.pl $(obj) $<; \
touch $@
--
2.52.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/5] hexagon: Drop invalid UAPI header asm/signal.h
2025-12-23 7:04 [PATCH 0/5] kbuild: uapi: improvements to header testing Thomas Weißschuh
2025-12-23 7:04 ` [PATCH 1/5] kbuild: uapi: validate that headers do not use libc Thomas Weißschuh
@ 2025-12-23 7:04 ` Thomas Weißschuh
2025-12-23 7:04 ` [PATCH 3/5] kbuild: uapi: don't compile test bpf_perf_event.h on xtensa Thomas Weißschuh
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Thomas Weißschuh @ 2025-12-23 7:04 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier, Brian Cain
Cc: linux-kbuild, linux-kernel, bpf, linux-hexagon,
Thomas Weißschuh
This UAPI header contains declarations of internal kernel symbols.
Such declarations are invalid. Normally headers_check.pl would report
an error, but apparently its dependency on CC_CAN_LINK prevent its
execution on hexagon so far.
As the header does not expose any additional UAPI, just make it a
regular internal kernel header. asm-generic/signal.h will be used
for the UAPI automatically, the same as before.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
arch/hexagon/include/{uapi => }/asm/signal.h | 0
1 file changed, 0 insertions(+), 0 deletions(-)
diff --git a/arch/hexagon/include/uapi/asm/signal.h b/arch/hexagon/include/asm/signal.h
similarity index 100%
rename from arch/hexagon/include/uapi/asm/signal.h
rename to arch/hexagon/include/asm/signal.h
--
2.52.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/5] kbuild: uapi: don't compile test bpf_perf_event.h on xtensa
2025-12-23 7:04 [PATCH 0/5] kbuild: uapi: improvements to header testing Thomas Weißschuh
2025-12-23 7:04 ` [PATCH 1/5] kbuild: uapi: validate that headers do not use libc Thomas Weißschuh
2025-12-23 7:04 ` [PATCH 2/5] hexagon: Drop invalid UAPI header asm/signal.h Thomas Weißschuh
@ 2025-12-23 7:04 ` Thomas Weißschuh
2025-12-23 7:04 ` [PATCH 4/5] kbuild: uapi: split out command conditions into variables Thomas Weißschuh
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Thomas Weißschuh @ 2025-12-23 7:04 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier, Brian Cain
Cc: linux-kbuild, linux-kernel, bpf, linux-hexagon,
Thomas Weißschuh
The xtensa UAPI headers do not provide 'struct pt_regs',
triggering an error:
usr/include/linux/bpf_perf_event.h:14:28: error: field 'regs' has incomplete type
Disable the header tests for this file on xtensa.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
usr/include/Makefile | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/usr/include/Makefile b/usr/include/Makefile
index a9a861ec8702..fd29c11c35cb 100644
--- a/usr/include/Makefile
+++ b/usr/include/Makefile
@@ -65,6 +65,10 @@ 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.52.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/5] kbuild: uapi: split out command conditions into variables
2025-12-23 7:04 [PATCH 0/5] kbuild: uapi: improvements to header testing Thomas Weißschuh
` (2 preceding siblings ...)
2025-12-23 7:04 ` [PATCH 3/5] kbuild: uapi: don't compile test bpf_perf_event.h on xtensa Thomas Weißschuh
@ 2025-12-23 7:04 ` Thomas Weißschuh
2025-12-23 7:04 ` [PATCH 5/5] kbuild: uapi: drop dependency on CC_CAN_LINK Thomas Weißschuh
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Thomas Weißschuh @ 2025-12-23 7:04 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier, Brian Cain
Cc: linux-kbuild, linux-kernel, bpf, linux-hexagon,
Thomas Weißschuh
The condition logic will become a bit more complicated.
Split them out into dedicated variables so they stay readable.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
usr/include/Makefile | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/usr/include/Makefile b/usr/include/Makefile
index fd29c11c35cb..fa01bcda21f5 100644
--- a/usr/include/Makefile
+++ b/usr/include/Makefile
@@ -150,12 +150,15 @@ 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 = $(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 $(filter-out $(uses-libc), $*.h), -nostdinc) \
- $(if $(filter-out $(no-header-test), $*.h), -include $< -include $<); \
+ $(if $(target-no-libc), -nostdinc) \
+ $(if $(target-can-compile), -include $< -include $<); \
$(PERL) $(src)/headers_check.pl $(obj) $<; \
touch $@
--
2.52.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/5] kbuild: uapi: drop dependency on CC_CAN_LINK
2025-12-23 7:04 [PATCH 0/5] kbuild: uapi: improvements to header testing Thomas Weißschuh
` (3 preceding siblings ...)
2025-12-23 7:04 ` [PATCH 4/5] kbuild: uapi: split out command conditions into variables Thomas Weißschuh
@ 2025-12-23 7:04 ` Thomas Weißschuh
2025-12-30 20:31 ` [PATCH 0/5] kbuild: uapi: improvements to header testing Nathan Chancellor
2026-01-06 22:10 ` Nathan Chancellor
6 siblings, 0 replies; 8+ messages in thread
From: Thomas Weißschuh @ 2025-12-23 7:04 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier, Brian Cain
Cc: linux-kbuild, linux-kernel, bpf, linux-hexagon,
Thomas Weißschuh
The header tests try to compile each header. Some UAPI headers depend on
libc headers so they need a full userspace toolchain to build. This
dependency is expressed in kconfig as a dependency on CC_CAN_LINK.
Many kernel builds do not satisfy CC_CAN_LINK as they only use a
minimal kernel (cross-) compiler. In those configurations the UAPI
headers are not tested at all.
However most UAPI headers do not even depend on any libc headers,
and such dependencies are undesired in any case. Also the static
analysis performed by headers_check.pl does not need CC_CAN_LINK.
Drop the hard dependency on CC_CAN_LINK and instead skip the affected
compilation step for exactly those headers which require libc.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
init/Kconfig | 2 +-
usr/include/Makefile | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/init/Kconfig b/init/Kconfig
index fa79feb8fe57..4e7ae65683ee 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -247,7 +247,7 @@ config WERROR
config UAPI_HEADER_TEST
bool "Compile test UAPI headers"
- depends on HEADERS_INSTALL && CC_CAN_LINK
+ depends on HEADERS_INSTALL
help
Compile test headers exported to user-space to ensure they are
self-contained, i.e. compilable as standalone units.
diff --git a/usr/include/Makefile b/usr/include/Makefile
index fa01bcda21f5..6d86a53c6f0a 100644
--- a/usr/include/Makefile
+++ b/usr/include/Makefile
@@ -151,7 +151,8 @@ 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 = $(filter-out $(no-header-test), $*.h)
+target-can-compile = $(and $(filter-out $(no-header-test), $*.h), \
+ $(or $(CONFIG_CC_CAN_LINK), $(target-no-libc)))
# Include the header twice to detect missing include guard.
quiet_cmd_hdrtest = HDRTEST $<
--
2.52.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 0/5] kbuild: uapi: improvements to header testing
2025-12-23 7:04 [PATCH 0/5] kbuild: uapi: improvements to header testing Thomas Weißschuh
` (4 preceding siblings ...)
2025-12-23 7:04 ` [PATCH 5/5] kbuild: uapi: drop dependency on CC_CAN_LINK Thomas Weißschuh
@ 2025-12-30 20:31 ` Nathan Chancellor
2026-01-06 22:10 ` Nathan Chancellor
6 siblings, 0 replies; 8+ messages in thread
From: Nathan Chancellor @ 2025-12-30 20:31 UTC (permalink / raw)
To: Thomas Weißschuh
Cc: Nicolas Schier, Brian Cain, linux-kbuild, linux-kernel, bpf,
linux-hexagon
Hi Thomas,
On Tue, Dec 23, 2025 at 08:04:07AM +0100, Thomas Weißschuh wrote:
> Also validate that UAPI headers do not depend on libc and remove the
> dependency on CC_CAN_LINK.
>
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> ---
> Thomas Weißschuh (5):
> kbuild: uapi: validate that headers do not use libc
> hexagon: Drop invalid UAPI header asm/signal.h
> kbuild: uapi: don't compile test bpf_perf_event.h on xtensa
> kbuild: uapi: split out command conditions into variables
> kbuild: uapi: drop dependency on CC_CAN_LINK
>
> arch/hexagon/include/{uapi => }/asm/signal.h | 0
> init/Kconfig | 2 +-
> usr/include/Makefile | 87 +++++++++++++++++++++++++++-
> 3 files changed, 87 insertions(+), 2 deletions(-)
This seems like a great improvement to the UAPI header testing. I don't
see any immediate problems and it works for me in my brief local
testing. I will give a week or so for comments before I apply this to
kbuild-next (plus -next should be operating at that point).
Cheers,
Nathan
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/5] kbuild: uapi: improvements to header testing
2025-12-23 7:04 [PATCH 0/5] kbuild: uapi: improvements to header testing Thomas Weißschuh
` (5 preceding siblings ...)
2025-12-30 20:31 ` [PATCH 0/5] kbuild: uapi: improvements to header testing Nathan Chancellor
@ 2026-01-06 22:10 ` Nathan Chancellor
6 siblings, 0 replies; 8+ messages in thread
From: Nathan Chancellor @ 2026-01-06 22:10 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier, Brian Cain,
Thomas Weißschuh
Cc: linux-kbuild, linux-kernel, bpf, linux-hexagon
On Tue, 23 Dec 2025 08:04:07 +0100, Thomas Weißschuh wrote:
> Also validate that UAPI headers do not depend on libc and remove the
> dependency on CC_CAN_LINK.
>
>
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/kbuild/linux.git kbuild-next-unstable
Thanks!
[1/5] kbuild: uapi: validate that headers do not use libc
https://git.kernel.org/kbuild/c/6059b880a93c3
[2/5] hexagon: Drop invalid UAPI header asm/signal.h
https://git.kernel.org/kbuild/c/cc45d2ea5cfb8
[3/5] kbuild: uapi: don't compile test bpf_perf_event.h on xtensa
https://git.kernel.org/kbuild/c/e2772ba5f43df
[4/5] kbuild: uapi: split out command conditions into variables
https://git.kernel.org/kbuild/c/4ac85d9bc73ed
[5/5] kbuild: uapi: drop dependency on CC_CAN_LINK
https://git.kernel.org/kbuild/c/e3970d77ec504
Please look out for regression or issue reports or other follow up
comments, as they may result in the patch/series getting dropped or
reverted. Patches applied to an "unstable" branch are accepted pending
wider testing in -next and any post-commit review; they will generally
be moved to the main branch in a week if no issues are found.
Best regards,
--
Nathan Chancellor <nathan@kernel.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-01-06 22:10 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-23 7:04 [PATCH 0/5] kbuild: uapi: improvements to header testing Thomas Weißschuh
2025-12-23 7:04 ` [PATCH 1/5] kbuild: uapi: validate that headers do not use libc Thomas Weißschuh
2025-12-23 7:04 ` [PATCH 2/5] hexagon: Drop invalid UAPI header asm/signal.h Thomas Weißschuh
2025-12-23 7:04 ` [PATCH 3/5] kbuild: uapi: don't compile test bpf_perf_event.h on xtensa Thomas Weißschuh
2025-12-23 7:04 ` [PATCH 4/5] kbuild: uapi: split out command conditions into variables Thomas Weißschuh
2025-12-23 7:04 ` [PATCH 5/5] kbuild: uapi: drop dependency on CC_CAN_LINK Thomas Weißschuh
2025-12-30 20:31 ` [PATCH 0/5] kbuild: uapi: improvements to header testing Nathan Chancellor
2026-01-06 22:10 ` Nathan Chancellor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox