Skip to contentSkip to conversation

tools/ynl: add missing uapi header deps in Makefile.deps

PATCH In review Stanislav Fomichev 3 participants 5 messages May 8 – May 10

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover tools/ynl: add missing uapi header deps in Makefile.deps

When syncing ynl-cpp to net-next v7.0-rc3, typelimits.h (for ethtool) and dev_energymodel.h had to be manually hacked into the downstream Makefile.deps:

https://github.com/linux-netdev/ynl-cpp/pull/16/changes/94bd9656423cab7dfce73dc824f75b59ef25668d

Fix the upstream Makefile.deps so that downstream copies stay in sync.

Stanislav Fomichev (2):
tools/ynl: add missing uapi header deps in Makefile.deps tools/ynl: add check-deps target to verify Makefile.deps completeness

 tools/net/ynl/Makefile.deps      | 39 +++++++++++++++++++++++++++++++-
 tools/net/ynl/generated/Makefile |  6 ++++-
 2 files changed, 43 insertions(+), 2 deletions(-)
Signature · 1 line
2.53.0-Meta
#1 lore raw

PATCH 1/2 tools/ynl: add missing uapi header deps in Makefile.deps

ethtool.h includes linux/typelimits.h which is a relatively new header not yet shipped in most distro kernel-header packages. Without the explicit entry, the build silently falls through to -idirafter.

dev_energymodel.h is a new YNL family whose uapi header is not in system paths at all and was missing a CFLAGS entry entirely.

---
 tools/net/ynl/Makefile.deps | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/net/ynl/Makefile.deps +3 -1
index 08205f9fc525..cc53b2f21c44 100644
@@ -15,9 +15,11 @@ UAPI_PATH:=../../../../include/uapi/
 get_hdr_inc=-D$(1) -include $(UAPI_PATH)/linux/$(2)
 get_hdr_inc2=-D$(1) -D$(2) -include $(UAPI_PATH)/linux/$(3)
 
+CFLAGS_dev-energymodel:=$(call get_hdr_inc,_LINUX_DEV_ENERGYMODEL_H,dev_energymodel.h)
 CFLAGS_devlink:=$(call get_hdr_inc,_LINUX_DEVLINK_H_,devlink.h)
 CFLAGS_dpll:=$(call get_hdr_inc,_LINUX_DPLL_H,dpll.h)
-CFLAGS_ethtool:=$(call get_hdr_inc,_LINUX_ETHTOOL_H,ethtool.h) \
+CFLAGS_ethtool:=$(call get_hdr_inc,_LINUX_TYPELIMITS_H,typelimits.h) \
+	$(call get_hdr_inc,_LINUX_ETHTOOL_H,ethtool.h) \
 	$(call get_hdr_inc,_LINUX_ETHTOOL_NETLINK_H_,ethtool_netlink.h) \
 	$(call get_hdr_inc,_LINUX_ETHTOOL_NETLINK_GENERATED_H,ethtool_netlink_generated.h)
 CFLAGS_handshake:=$(call get_hdr_inc,_LINUX_HANDSHAKE_H,handshake.h)
Signature · 1 line
2.53.0-Meta
#2 lore raw

PATCH 2/2 tools/ynl: add check-deps target to verify Makefile.deps completeness

In reply to Stanislav Fomichev

Add two make rules that detect missing entries in Makefile.deps:

check-existing-deps-<family>: for families that already have CFLAGS,
parse each force-included header for #include directives and verify that every included uapi header is either already listed in CFLAGS or findable by the compiler without -idirafter.

check-new-deps-<family>: for families without CFLAGS, check whether
their default uapi header (linux/<family>.h) exists in the kernel tree but is not findable by the compiler -- meaning it needs a new CFLAGS entry.

(this is slop but I added extensive comments on how it works)

---
 tools/net/ynl/Makefile.deps      | 35 ++++++++++++++++++++++++++++++++
 tools/net/ynl/generated/Makefile |  6 +++++-
 2 files changed, 40 insertions(+), 1 deletion(-)
tools/net/ynl/Makefile.deps +35 -0
index cc53b2f21c44..f2c24097a2c8 100644
@@ -52,3 +52,38 @@ CFLAGS_tc:= $(call get_hdr_inc,__LINUX_RTNETLINK_H,rtnetlink.h) \
 	$(call get_hdr_inc,_TC_TUNNEL_KEY_H,tc_act/tc_tunnel_key.h)
 CFLAGS_tcp_metrics:=$(call get_hdr_inc,_LINUX_TCP_METRICS_H,tcp_metrics.h)
 CFLAGS_wireguard:=$(call get_hdr_inc2,_LINUX_WIREGUARD_H,_WG_UAPI_WIREGUARD_H,wireguard.h)
+
+# For families that already have CFLAGS, verify that every #include in
+# their force-included headers is accounted for.
+#
+# How it works:
+#   1. Extract -include paths from CFLAGS_<family>      (grep + sed)
+#   2. Parse each header for #include <...> directives  (sed)
+#   3. Skip if the included file is not a uapi header   (test against UAPI_PATH)
+#   4. Skip if it is already listed in CFLAGS_<family>  (grep)
+#   5. Skip if the compiler can find it without help    (try $(CC))
+#   6. Otherwise error -- the header needs to be added
+check-existing-deps-%:
+	@for inc in $$(sed -n 's/.*#include <\([^>]*\)>.*/\1/p' \
+		$$(echo "$(CFLAGS_$*)" | grep -o '\-include [^ ]*' | sed 's/-include //')); do \
+	  test -f $(UAPI_PATH)/$$inc || continue; \
+	  echo "$(CFLAGS_$*)" | grep -qF "$$inc" && continue; \
+	  echo "#include <$$inc>" | $(CC) -x c -fsyntax-only - 2>/dev/null && continue; \
+	  echo "ERROR: $* missing $$inc"; exit 1; \
+	done; true
+
+# For families without CFLAGS, check whether their default uapi header
+# (linux/<family>.h) exists in the kernel tree but is not findable by
+# the compiler -- meaning it needs a new CFLAGS entry.
+#
+# How it works (short-circuit chain, all four must fail to error):
+#   1. Skip if CFLAGS_<family> is already defined          (test -n)
+#   2. Skip if the default uapi header does not exist      (test -f)
+#   3. Skip if the compiler can find it without help       (try $(CC))
+#   4. Otherwise error -- a new CFLAGS entry is needed
+check-new-deps-%:
+	@test -n "$(CFLAGS_$*)" \
+	  || ! test -f $(UAPI_PATH)/linux/$(subst -,_,$*).h \
+	  || echo "#include <linux/$(subst -,_,$*).h>" | \
+	     $(CC) -x c -fsyntax-only - 2>/dev/null \
+	  || { echo "ERROR: $* needs CFLAGS entry for linux/$(subst -,_,$*).h"; exit 1; }
tools/net/ynl/generated/Makefile +5 -1
index 86e1e4a959a7..0f1d2c70b6a5 100644
@@ -83,5 +83,9 @@ install-rsts: $(RSTS)
 
 install: install-headers install-rsts install-specs
 
-.PHONY: all clean distclean regen install install-headers install-rsts install-specs
+check-deps: $(patsubst %,check-existing-deps-%,$(GENS)) \
+	    $(patsubst %,check-new-deps-%,$(GENS))
+	@echo "All Makefile.deps OK"
+
+.PHONY: all clean distclean regen install install-headers install-rsts install-specs check-deps
 .DEFAULT_GOAL: all
Signature · 1 line
2.53.0-Meta
maintainer
#3 lore raw

Re: [PATCH net-next 2/2] tools/ynl: add check-deps target to verify Makefile.deps completeness

Quoted 7 lines · On Fri, 8 May 2026 13:41:14 -0700 Stanislav Fomichev wrote:

Add two make rules that detect missing entries in Makefile.deps:

check-existing-deps-<family>: for families that already have CFLAGS,
parse each force-included header for #include directives and verify that every included uapi header is either already listed in CFLAGS or findable by the compiler without -idirafter.

Quoted 6 lines

check-new-deps-<family>: for families without CFLAGS, check whether
their default uapi header (linux/<family>.h) exists in the kernel tree but is not findable by the compiler -- meaning it needs a new CFLAGS entry.

(this is slop but I added extensive comments on how it works)

Would it be more suitable as a NIPA check? Or at least it'd feel less bad to carry slop in NIPA than in the kernel tree. We already have a test for YNL build.

#4 lore raw
In reply to Stanislav Fomichev
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Fri, 8 May 2026 13:41:12 -0700 you wrote:

When syncing ynl-cpp to net-next v7.0-rc3, typelimits.h (for ethtool) and dev_energymodel.h had to be manually hacked into the downstream Makefile.deps:

https://github.com/linux-netdev/ynl-cpp/pull/16/changes/94bd9656423cab7dfce73dc824f75b59ef25668d

Fix the upstream Makefile.deps so that downstream copies stay in sync.

[...]

Here is the summary with links:
- [net-next,1/2] tools/ynl: add missing uapi header deps in Makefile.deps

    https://git.kernel.org/netdev/net/c/46e9b0224475

- [net-next,2/2] tools/ynl: add check-deps target to verify Makefile.deps completeness (no matching commit)

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html