Skip to contentSkip to conversation

Makefile: Let kernel-doc.py use PYTHON3 override

PATCH Applied Jean Delvare 4 participants 5 messages Nov 7, 2025 – Nov 9, 2025

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

PATCH v2 1/1 Makefile: Let kernel-doc.py use PYTHON3 override

It is possible to force a specific version of python to be used when building the kernel by passing PYTHON3= on the make command line. However kernel-doc.py is currently called with python3 hard-coded and thus ignores this setting.

Use $(PYTHON3) to run $(KERNELDOC) so that the desired version of python is used.

---
Changes in v2:
* Leave KERNELDOC alone and patch the calling sites instead.

 drivers/gpu/drm/Makefile      |    2 +-
 drivers/gpu/drm/i915/Makefile |    2 +-
 include/drm/Makefile          |    2 +-
 scripts/Makefile.build        |    2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/Makefile +1 -1
@@ -244,7 +244,7 @@ always-$(CONFIG_DRM_HEADER_TEST) += \
 quiet_cmd_hdrtest = HDRTEST $(patsubst %.hdrtest,%.h,$@)
       cmd_hdrtest = \
 		$(CC) $(c_flags) -fsyntax-only -x c /dev/null -include $< -include $<; \
-		 PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \
+		 PYTHONDONTWRITEBYTECODE=1 $(PYTHON3) $(KERNELDOC) -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \
 		touch $@
 
 $(obj)/%.hdrtest: $(src)/%.h FORCE
drivers/gpu/drm/i915/Makefile +1 -1
@@ -411,7 +411,7 @@ obj-$(CONFIG_DRM_I915_GVT_KVMGT) += kvmg
 #
 # Enable locally for CONFIG_DRM_I915_WERROR=y. See also scripts/Makefile.build
 ifdef CONFIG_DRM_I915_WERROR
-    cmd_checkdoc = PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none -Werror $<
+    cmd_checkdoc = PYTHONDONTWRITEBYTECODE=1 $(PYTHON3) $(KERNELDOC) -none -Werror $<
 endif
 
 # header test
include/drm/Makefile +1 -1
@@ -11,7 +11,7 @@ always-$(CONFIG_DRM_HEADER_TEST) += \
 quiet_cmd_hdrtest = HDRTEST $(patsubst %.hdrtest,%.h,$@)
       cmd_hdrtest = \
 		$(CC) $(c_flags) -fsyntax-only -x c /dev/null -include $< -include $<; \
-		PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \
+		PYTHONDONTWRITEBYTECODE=1 $(PYTHON3) $(KERNELDOC) -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \
 		touch $@
 
 $(obj)/%.hdrtest: $(src)/%.h FORCE
scripts/Makefile.build +1 -1
@@ -167,7 +167,7 @@ else ifeq ($(KBUILD_CHECKSRC),2)
 endif
 
 ifneq ($(KBUILD_EXTRA_WARN),)
-  cmd_checkdoc = PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none $(KDOCFLAGS) \
+  cmd_checkdoc = PYTHONDONTWRITEBYTECODE=1 $(PYTHON3) $(KERNELDOC) -none $(KDOCFLAGS) \
         $(if $(findstring 2, $(KBUILD_EXTRA_WARN)), -Wall) \
         $<
 endif
Signature · 2 lines
Jean Delvare
SUSE L3 Support
#1 lore raw
Quoted 10 lines · Jean Delvare

It is possible to force a specific version of python to be used when building the kernel by passing PYTHON3= on the make command line. However kernel-doc.py is currently called with python3 hard-coded and thus ignores this setting.

Use $(PYTHON3) to run $(KERNELDOC) so that the desired version of python is used.

---

Thanks, I can take this as a fix for 6.18 since it results in warnings in your environment. I will give it a day or so for folks to comment for review.

Quoted 58 lines

Changes in v2:
* Leave KERNELDOC alone and patch the calling sites instead.

 drivers/gpu/drm/Makefile      |    2 +-
 drivers/gpu/drm/i915/Makefile |    2 +-
 include/drm/Makefile          |    2 +-
 scripts/Makefile.build        |    2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/Makefile +1 -1
@@ -244,7 +244,7 @@ always-$(CONFIG_DRM_HEADER_TEST) += \
 quiet_cmd_hdrtest = HDRTEST $(patsubst %.hdrtest,%.h,$@)
       cmd_hdrtest = \
 		$(CC) $(c_flags) -fsyntax-only -x c /dev/null -include $< -include $<; \
-		 PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \
+		 PYTHONDONTWRITEBYTECODE=1 $(PYTHON3) $(KERNELDOC) -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \
 		touch $@
 
 $(obj)/%.hdrtest: $(src)/%.h FORCE
drivers/gpu/drm/i915/Makefile +1 -1
@@ -411,7 +411,7 @@ obj-$(CONFIG_DRM_I915_GVT_KVMGT) += kvmg
 #
 # Enable locally for CONFIG_DRM_I915_WERROR=y. See also scripts/Makefile.build
 ifdef CONFIG_DRM_I915_WERROR
-    cmd_checkdoc = PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none -Werror $<
+    cmd_checkdoc = PYTHONDONTWRITEBYTECODE=1 $(PYTHON3) $(KERNELDOC) -none -Werror $<
 endif
 
 # header test
include/drm/Makefile +1 -1
@@ -11,7 +11,7 @@ always-$(CONFIG_DRM_HEADER_TEST) += \
 quiet_cmd_hdrtest = HDRTEST $(patsubst %.hdrtest,%.h,$@)
       cmd_hdrtest = \
 		$(CC) $(c_flags) -fsyntax-only -x c /dev/null -include $< -include $<; \
-		PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \
+		PYTHONDONTWRITEBYTECODE=1 $(PYTHON3) $(KERNELDOC) -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \
 		touch $@
 
 $(obj)/%.hdrtest: $(src)/%.h FORCE
scripts/Makefile.build +1 -1
@@ -167,7 +167,7 @@ else ifeq ($(KBUILD_CHECKSRC),2)
 endif
 
 ifneq ($(KBUILD_EXTRA_WARN),)
-  cmd_checkdoc = PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none $(KDOCFLAGS) \
+  cmd_checkdoc = PYTHONDONTWRITEBYTECODE=1 $(PYTHON3) $(KERNELDOC) -none $(KDOCFLAGS) \
         $(if $(findstring 2, $(KBUILD_EXTRA_WARN)), -Wall) \
         $<
 endif
Signature · 3 lines
-- 
Jean Delvare
SUSE L3 Support
Reviewed-by on v2 1/1
#2 lore raw
In reply to Jean Delvare

Em Fri, 7 Nov 2025 19:29:33 +0100
Jean Delvare <[email protected]> escreveu:

Quoted 9 lines

It is possible to force a specific version of python to be used when building the kernel by passing PYTHON3= on the make command line. However kernel-doc.py is currently called with python3 hard-coded and thus ignores this setting.

Use $(PYTHON3) to run $(KERNELDOC) so that the desired version of python is used.

Quoted 48 lines

---
Changes in v2:
* Leave KERNELDOC alone and patch the calling sites instead.

 drivers/gpu/drm/Makefile      |    2 +-
 drivers/gpu/drm/i915/Makefile |    2 +-
 include/drm/Makefile          |    2 +-
 scripts/Makefile.build        |    2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/Makefile +1 -1
@@ -244,7 +244,7 @@ always-$(CONFIG_DRM_HEADER_TEST) += \
 quiet_cmd_hdrtest = HDRTEST $(patsubst %.hdrtest,%.h,$@)
       cmd_hdrtest = \
 		$(CC) $(c_flags) -fsyntax-only -x c /dev/null -include $< -include $<; \
-		 PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \
+		 PYTHONDONTWRITEBYTECODE=1 $(PYTHON3) $(KERNELDOC) -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \
 		touch $@
 
 $(obj)/%.hdrtest: $(src)/%.h FORCE
drivers/gpu/drm/i915/Makefile +1 -1
@@ -411,7 +411,7 @@ obj-$(CONFIG_DRM_I915_GVT_KVMGT) += kvmg
 #
 # Enable locally for CONFIG_DRM_I915_WERROR=y. See also scripts/Makefile.build
 ifdef CONFIG_DRM_I915_WERROR
-    cmd_checkdoc = PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none -Werror $<
+    cmd_checkdoc = PYTHONDONTWRITEBYTECODE=1 $(PYTHON3) $(KERNELDOC) -none -Werror $<
 endif
 
 # header test
include/drm/Makefile +1 -1
@@ -11,7 +11,7 @@ always-$(CONFIG_DRM_HEADER_TEST) += \
 quiet_cmd_hdrtest = HDRTEST $(patsubst %.hdrtest,%.h,$@)
       cmd_hdrtest = \
 		$(CC) $(c_flags) -fsyntax-only -x c /dev/null -include $< -include $<; \
-		PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \
+		PYTHONDONTWRITEBYTECODE=1 $(PYTHON3) $(KERNELDOC) -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \
 		touch $@
 
 $(obj)/%.hdrtest: $(src)/%.h FORCE

scripts/Makefile.build else ifeq ($(KBUILD_CHECKSRC),2) · line 173

Quoted 8 lines
scripts/Makefile.build +1 -1
@@ -167,7 +167,7 @@ else ifeq ($(KBUILD_CHECKSRC),2)
 endif
 
 ifneq ($(KBUILD_EXTRA_WARN),)
-  cmd_checkdoc = PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none $(KDOCFLAGS) \
+  cmd_checkdoc = PYTHONDONTWRITEBYTECODE=1 $(PYTHON3) $(KERNELDOC) -none $(KDOCFLAGS) \
         $(if $(findstring 2, $(KBUILD_EXTRA_WARN)), -Wall) \
         $<
 endif

Thanks,
Mauro

maintainer Reviewed-by on v2 1/1
#3 lore raw
In reply to Jean Delvare
Quoted 13 lines · Jean Delvare

It is possible to force a specific version of python to be used when building the kernel by passing PYTHON3= on the make command line. However kernel-doc.py is currently called with python3 hard-coded and thus ignores this setting.

Use $(PYTHON3) to run $(KERNELDOC) so that the desired version of python is used.

---
Changes in v2:
* Leave KERNELDOC alone and patch the calling sites instead.

Quoted 6 lines
 drivers/gpu/drm/Makefile      |    2 +-
 drivers/gpu/drm/i915/Makefile |    2 +-
 include/drm/Makefile          |    2 +-
 scripts/Makefile.build        |    2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

Thanks.

maintainer Applied
#4 lore raw
In reply to Jean Delvare
Quoted 9 lines · Jean Delvare

It is possible to force a specific version of python to be used when building the kernel by passing PYTHON3= on the make command line. However kernel-doc.py is currently called with python3 hard-coded and thus ignores this setting.

Use $(PYTHON3) to run $(KERNELDOC) so that the desired version of python is used.

[...]

Applied, thanks!

[1/1] Makefile: Let kernel-doc.py use PYTHON3 override

      https://git.kernel.org/kbuild/c/002621a4df3c1

Best regards,

Signature · 1 line
Nathan Chancellor <[email protected]>