All of lore.kernel.org
 help / color / mirror / Atom feed
From: Baoli Zhang <baoli.zhang@linux.intel.com>
To: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Cc: Johannes Berg <johannes.berg@intel.com>,
	linux-wireless@vger.kernel.org,
	Baoli Zhang <baoli.zhang@linux.intel.com>
Subject: [PATCH] backports: look for kernel headers in source dir too
Date: Thu, 26 Nov 2026 08:42:00 +0800	[thread overview]
Message-ID: <20261126004200.626863-1-baoli.zhang@linux.intel.com> (raw)

Debian splits the kernel headers: /lib/modules/<ver>/build only has
.config, Module.symvers and the generated headers, include/linux is
under /lib/modules/<ver>/source. The grep checks in compat/Kconfig
then can't find the headers and all evaluate to n, so on 7.3 we
redefine the spinlock_bh guards and fail to build.

Add KLIB_SRC for these checks. Use the build dir if it has
include/linux, otherwise its source symlink (O= builds), and only then
$(KLIB)/source, so that a custom KLIB_BUILD doesn't pick up the headers
of the running kernel. Warn if no headers are found at all, instead of
silently disabling the checks.

Fixes: e0449c805011 ("backports: auto-detect spinlock_bh guard()")
Fixes: e9e903010322 ("[BUGFIX] backports: Auto detect genlmsg_multicast_allns()")
Fixes: 6bd0558a1593 ("[FROMGIT] netfilter: flowtable: restore ieee80211 forward path")
Signed-off-by: Baoli Zhang <baoli.zhang@linux.intel.com>
---
 Makefile       | 14 +++++++++++++-
 compat/Kconfig |  6 +++---
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 2b33a80c3..daba7181e 100644
--- a/Makefile
+++ b/Makefile
@@ -19,8 +19,13 @@ KLIB_BUILD ?= $(KLIB)/build/
 KERNEL_CONFIG := $(KLIB_BUILD)/.config
 KERNEL_MAKEFILE := $(KLIB_BUILD)/Makefile
 CONFIG_MD5 := $(shell md5sum $(KERNEL_CONFIG) 2>/dev/null | sed 's/\s.*//')
+# Debian splits the headers, its build dir has no include/linux
+KLIB_SRC ?= $(patsubst %/include/linux,%,$(firstword $(wildcard	\
+	$(KLIB_BUILD)/include/linux					\
+	$(KLIB_BUILD)/source/include/linux				\
+	$(KLIB)/source/include/linux)))
 
-export KLIB KLIB_BUILD BACKPORT_DIR KMODDIR KMODPATH_ARG
+export KLIB KLIB_BUILD KLIB_SRC BACKPORT_DIR KMODDIR KMODPATH_ARG
 
 # disable built-in rules for this file
 .SUFFIXES:
@@ -60,6 +65,13 @@ mrproper:
 	echo "| (that isn't currently running.)"					;\
 	echo "\\--"									;\
 	false)
+	@test -n "$(KLIB_SRC)" || (							\
+	echo "/--------------"								;\
+	echo "| WARNING: kernel headers (include/linux) not found in"		;\
+	echo "| $(KLIB_BUILD) or its source dir, kernel feature"			;\
+	echo "| detection will not work. Set KLIB_SRC to the kernel"		;\
+	echo "| source tree to fix this."						;\
+	echo "\\--")
 	@set -e ; if [ "$$(cat .kernel_config_md5 2>/dev/null)" != "$(CONFIG_MD5)" ]	;\
 	then 										\
 		echo -n "Generating local configuration database from kernel ..."	;\
diff --git a/compat/Kconfig b/compat/Kconfig
index 09663a8bc..e1db4dd71 100644
--- a/compat/Kconfig
+++ b/compat/Kconfig
@@ -74,13 +74,13 @@ config BP_MODULES
 	for the "modules" directive to control the 'm' state.
 
 config KERNEL_HAS_SPINLOCK_BH_GUARD
-	def_bool $(success,grep -q DEFINE_LOCK_GUARD_1\$(left_paren)spinlock_bh$(comma) $(KLIB_BUILD)/include/linux/spinlock.h)
+	def_bool $(success,grep -q DEFINE_LOCK_GUARD_1\$(left_paren)spinlock_bh$(comma) $(KLIB_SRC)/include/linux/spinlock.h)
 
 config KERNEL_HAS_GENLMSG_MULTICAST_ALLNS_GFP
-	def_bool $(success,grep -A5 'int genlmsg_multicast_allns' $(KLIB_BUILD)/include/net/genetlink.h | grep -q gfp_t)
+	def_bool $(success,grep -A5 'int genlmsg_multicast_allns' $(KLIB_SRC)/include/net/genetlink.h | grep -q gfp_t)
 
 config KERNEL_HAS_DEV_PATH_IEEE80211
-	def_bool $(success,grep -q DEV_PATH_IEEE80211 $(KLIB_BUILD)/include/linux/netdevice.h)
+	def_bool $(success,grep -q DEV_PATH_IEEE80211 $(KLIB_SRC)/include/linux/netdevice.h)
 
 config BPAUTO_BUILD_NLATTR
 	def_bool y
-- 
2.43.0


                 reply	other threads:[~2026-11-26  0:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261126004200.626863-1-baoli.zhang@linux.intel.com \
    --to=baoli.zhang@linux.intel.com \
    --cc=johannes.berg@intel.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=miriam.rachel.korenblit@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.