[PATCH v3 1/2] scripts/kernel-doc.py: don't create *.pyc files

Mauro Carvalho Chehab posted 2 patches 9 months, 4 weeks ago
There is a newer version of this series
[PATCH v3 1/2] scripts/kernel-doc.py: don't create *.pyc files
Posted by Mauro Carvalho Chehab 9 months, 4 weeks ago
As reported by Andy, kernel-doc.py is creating a __pycache__
directory at build time.

Disable creation of __pycache__ for the libraries used by
kernel-doc.py, when excecuted via the build system or via
scripts/find-unused-docs.sh.

Reported-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Closes: https://lore.kernel.org/linux-doc/Z_zYXAJcTD-c3xTe@black.fi.intel.com/
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/gpu/drm/Makefile      | 2 +-
 drivers/gpu/drm/i915/Makefile | 2 +-
 include/drm/Makefile          | 2 +-
 scripts/Makefile.build        | 2 +-
 scripts/find-unused-docs.sh   | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index ed54a546bbe2..d21d0cd2c752 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -236,7 +236,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 $<; \
-		$(srctree)/scripts/kernel-doc -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \
+		 PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \
 		touch $@
 
 $(obj)/%.hdrtest: $(src)/%.h FORCE
diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index ed05b131ed3a..ab6b89a163e7 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -408,7 +408,7 @@ obj-$(CONFIG_DRM_I915_GVT_KVMGT) += kvmgt.o
 #
 # Enable locally for CONFIG_DRM_I915_WERROR=y. See also scripts/Makefile.build
 ifdef CONFIG_DRM_I915_WERROR
-    cmd_checkdoc = $(srctree)/scripts/kernel-doc -none -Werror $<
+    cmd_checkdoc = PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none -Werror $<
 endif
 
 # header test
diff --git a/include/drm/Makefile b/include/drm/Makefile
index a7bd15d2803e..1df6962556ef 100644
--- a/include/drm/Makefile
+++ b/include/drm/Makefile
@@ -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 $<; \
-		$(srctree)/scripts/kernel-doc -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \
+		PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \
 		touch $@
 
 $(obj)/%.hdrtest: $(src)/%.h FORCE
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 13dcd86e74ca..884dc86ce04e 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -83,7 +83,7 @@ else ifeq ($(KBUILD_CHECKSRC),2)
 endif
 
 ifneq ($(KBUILD_EXTRA_WARN),)
-  cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $(KDOCFLAGS) \
+  cmd_checkdoc = PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none $(KDOCFLAGS) \
         $(if $(findstring 2, $(KBUILD_EXTRA_WARN)), -Wall) \
         $<
 endif
diff --git a/scripts/find-unused-docs.sh b/scripts/find-unused-docs.sh
index ee6a50e33aba..d6d397fbf917 100755
--- a/scripts/find-unused-docs.sh
+++ b/scripts/find-unused-docs.sh
@@ -54,7 +54,7 @@ for file in `find $1 -name '*.c'`; do
 	if [[ ${FILES_INCLUDED[$file]+_} ]]; then
 	continue;
 	fi
-	str=$(scripts/kernel-doc -export "$file" 2>/dev/null)
+	str=$(PYTHONDONTWRITEBYTECODE=1 scripts/kernel-doc -export "$file" 2>/dev/null)
 	if [[ -n "$str" ]]; then
 	echo "$file"
 	fi
-- 
2.49.0
Re: [PATCH v3 1/2] scripts/kernel-doc.py: don't create *.pyc files
Posted by kernel test robot 9 months, 3 weeks ago
Hi Mauro,

kernel test robot noticed the following build errors:

[auto build test ERROR on lwn/docs-next]
[also build test ERROR on drm-i915/for-linux-next drm-i915/for-linux-next-fixes linus/master v6.15-rc2 next-20250417]
[cannot apply to masahiroy-kbuild/for-next masahiroy-kbuild/fixes]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Mauro-Carvalho-Chehab/scripts-kernel-doc-py-don-t-create-pyc-files/20250416-155336
base:   git://git.lwn.net/linux.git docs-next
patch link:    https://lore.kernel.org/r/4ad5eb8d4b819997c1615d2401581c22a32bb2c1.1744789777.git.mchehab%2Bhuawei%40kernel.org
patch subject: [PATCH v3 1/2] scripts/kernel-doc.py: don't create *.pyc files
config: x86_64-rhel-9.4-rust (https://download.01.org/0day-ci/archive/20250419/202504190154.lSj16P1a-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
rustc: rustc 1.78.0 (9b00956e5 2024-04-29)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250419/202504190154.lSj16P1a-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202504190154.lSj16P1a-lkp@intel.com/

All errors (new ones prefixed by >>):

>> /bin/bash: line 1: -none: command not found

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH v3 1/2] scripts/kernel-doc.py: don't create *.pyc files
Posted by kernel test robot 9 months, 3 weeks ago
Hi Mauro,

kernel test robot noticed the following build errors:

[auto build test ERROR on lwn/docs-next]
[also build test ERROR on drm-i915/for-linux-next drm-i915/for-linux-next-fixes linus/master v6.15-rc2 next-20250416]
[cannot apply to masahiroy-kbuild/for-next masahiroy-kbuild/fixes]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Mauro-Carvalho-Chehab/scripts-kernel-doc-py-don-t-create-pyc-files/20250416-155336
base:   git://git.lwn.net/linux.git docs-next
patch link:    https://lore.kernel.org/r/4ad5eb8d4b819997c1615d2401581c22a32bb2c1.1744789777.git.mchehab%2Bhuawei%40kernel.org
patch subject: [PATCH v3 1/2] scripts/kernel-doc.py: don't create *.pyc files
config: csky-randconfig-001-20250417 (https://download.01.org/0day-ci/archive/20250417/202504171512.FiYw2rGC-lkp@intel.com/config)
compiler: csky-linux-gcc (GCC) 13.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250417/202504171512.FiYw2rGC-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202504171512.FiYw2rGC-lkp@intel.com/

All errors (new ones prefixed by >>):

>> /bin/sh: 1: -none: not found
   make[3]: *** [scripts/Makefile.build:203: scripts/mod/empty.o] Error 127 shuffle=2754938148
   make[3]: *** Deleting file 'scripts/mod/empty.o'
   make[3]: Target 'scripts/mod/' not remade because of errors.
   make[2]: *** [Makefile:1276: prepare0] Error 2 shuffle=2754938148
   make[2]: Target 'prepare' not remade because of errors.
   make[1]: *** [Makefile:248: __sub-make] Error 2 shuffle=2754938148
   make[1]: Target 'prepare' not remade because of errors.
   make: *** [Makefile:248: __sub-make] Error 2 shuffle=2754938148
   make: Target 'prepare' not remade because of errors.

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH v3 1/2] scripts/kernel-doc.py: don't create *.pyc files
Posted by Jani Nikula 9 months, 4 weeks ago
On Wed, 16 Apr 2025, Mauro Carvalho Chehab <mchehab+huawei@kernel.org> wrote:
> As reported by Andy, kernel-doc.py is creating a __pycache__
> directory at build time.
>
> Disable creation of __pycache__ for the libraries used by
> kernel-doc.py, when excecuted via the build system or via
> scripts/find-unused-docs.sh.
>
> Reported-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> Closes: https://lore.kernel.org/linux-doc/Z_zYXAJcTD-c3xTe@black.fi.intel.com/
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> ---
>  drivers/gpu/drm/Makefile      | 2 +-
>  drivers/gpu/drm/i915/Makefile | 2 +-
>  include/drm/Makefile          | 2 +-
>  scripts/Makefile.build        | 2 +-
>  scripts/find-unused-docs.sh   | 2 +-
>  5 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> index ed54a546bbe2..d21d0cd2c752 100644
> --- a/drivers/gpu/drm/Makefile
> +++ b/drivers/gpu/drm/Makefile
> @@ -236,7 +236,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 $<; \
> -		$(srctree)/scripts/kernel-doc -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \
> +		 PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \

KERNELDOC is not set here.

/bin/sh: 1: -none: not found


>  		touch $@
>  
>  $(obj)/%.hdrtest: $(src)/%.h FORCE
> diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
> index ed05b131ed3a..ab6b89a163e7 100644
> --- a/drivers/gpu/drm/i915/Makefile
> +++ b/drivers/gpu/drm/i915/Makefile
> @@ -408,7 +408,7 @@ obj-$(CONFIG_DRM_I915_GVT_KVMGT) += kvmgt.o
>  #
>  # Enable locally for CONFIG_DRM_I915_WERROR=y. See also scripts/Makefile.build
>  ifdef CONFIG_DRM_I915_WERROR
> -    cmd_checkdoc = $(srctree)/scripts/kernel-doc -none -Werror $<
> +    cmd_checkdoc = PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none -Werror $<
>  endif
>  
>  # header test
> diff --git a/include/drm/Makefile b/include/drm/Makefile
> index a7bd15d2803e..1df6962556ef 100644
> --- a/include/drm/Makefile
> +++ b/include/drm/Makefile
> @@ -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 $<; \
> -		$(srctree)/scripts/kernel-doc -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \
> +		PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \
>  		touch $@
>  
>  $(obj)/%.hdrtest: $(src)/%.h FORCE
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index 13dcd86e74ca..884dc86ce04e 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -83,7 +83,7 @@ else ifeq ($(KBUILD_CHECKSRC),2)
>  endif
>  
>  ifneq ($(KBUILD_EXTRA_WARN),)
> -  cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $(KDOCFLAGS) \
> +  cmd_checkdoc = PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none $(KDOCFLAGS) \
>          $(if $(findstring 2, $(KBUILD_EXTRA_WARN)), -Wall) \
>          $<
>  endif
> diff --git a/scripts/find-unused-docs.sh b/scripts/find-unused-docs.sh
> index ee6a50e33aba..d6d397fbf917 100755
> --- a/scripts/find-unused-docs.sh
> +++ b/scripts/find-unused-docs.sh
> @@ -54,7 +54,7 @@ for file in `find $1 -name '*.c'`; do
>  	if [[ ${FILES_INCLUDED[$file]+_} ]]; then
>  	continue;
>  	fi
> -	str=$(scripts/kernel-doc -export "$file" 2>/dev/null)
> +	str=$(PYTHONDONTWRITEBYTECODE=1 scripts/kernel-doc -export "$file" 2>/dev/null)
>  	if [[ -n "$str" ]]; then
>  	echo "$file"
>  	fi

-- 
Jani Nikula, Intel
Re: [PATCH v3 1/2] scripts/kernel-doc.py: don't create *.pyc files
Posted by Mauro Carvalho Chehab 9 months, 4 weeks ago
Em Wed, 16 Apr 2025 11:34:16 +0300
Jani Nikula <jani.nikula@linux.intel.com> escreveu:

> On Wed, 16 Apr 2025, Mauro Carvalho Chehab <mchehab+huawei@kernel.org> wrote:
> > As reported by Andy, kernel-doc.py is creating a __pycache__
> > directory at build time.
> >
> > Disable creation of __pycache__ for the libraries used by
> > kernel-doc.py, when excecuted via the build system or via
> > scripts/find-unused-docs.sh.
> >
> > Reported-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> > Closes: https://lore.kernel.org/linux-doc/Z_zYXAJcTD-c3xTe@black.fi.intel.com/
> > Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> > ---
> >  drivers/gpu/drm/Makefile      | 2 +-
> >  drivers/gpu/drm/i915/Makefile | 2 +-
> >  include/drm/Makefile          | 2 +-
> >  scripts/Makefile.build        | 2 +-
> >  scripts/find-unused-docs.sh   | 2 +-
> >  5 files changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> > index ed54a546bbe2..d21d0cd2c752 100644
> > --- a/drivers/gpu/drm/Makefile
> > +++ b/drivers/gpu/drm/Makefile
> > @@ -236,7 +236,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 $<; \
> > -		$(srctree)/scripts/kernel-doc -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \
> > +		 PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \  
> 
> KERNELDOC is not set here.

> 
> /bin/sh: 1: -none: not found

Weird. This is set on Documentation/Makefile:

	$ grep KERNELDOC Documentation/Makefile 
	KERNELDOC       = $(srctree)/scripts/kernel-doc.py
	...

drivers/gpu/drm/Makefile should be able to see this variable there...

> 
> >  		touch $@
> >  
> >  $(obj)/%.hdrtest: $(src)/%.h FORCE
> > diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
> > index ed05b131ed3a..ab6b89a163e7 100644
> > --- a/drivers/gpu/drm/i915/Makefile
> > +++ b/drivers/gpu/drm/i915/Makefile
> > @@ -408,7 +408,7 @@ obj-$(CONFIG_DRM_I915_GVT_KVMGT) += kvmgt.o
> >  #
> >  # Enable locally for CONFIG_DRM_I915_WERROR=y. See also scripts/Makefile.build
> >  ifdef CONFIG_DRM_I915_WERROR
> > -    cmd_checkdoc = $(srctree)/scripts/kernel-doc -none -Werror $<
> > +    cmd_checkdoc = PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none -Werror $<
> >  endif
> >  
> >  # header test
> > diff --git a/include/drm/Makefile b/include/drm/Makefile
> > index a7bd15d2803e..1df6962556ef 100644
> > --- a/include/drm/Makefile
> > +++ b/include/drm/Makefile
> > @@ -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 $<; \
> > -		$(srctree)/scripts/kernel-doc -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \
> > +		PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \
> >  		touch $@
> >  
> >  $(obj)/%.hdrtest: $(src)/%.h FORCE
> > diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> > index 13dcd86e74ca..884dc86ce04e 100644
> > --- a/scripts/Makefile.build
> > +++ b/scripts/Makefile.build
> > @@ -83,7 +83,7 @@ else ifeq ($(KBUILD_CHECKSRC),2)
> >  endif
> >  
> >  ifneq ($(KBUILD_EXTRA_WARN),)
> > -  cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $(KDOCFLAGS) \
> > +  cmd_checkdoc = PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none $(KDOCFLAGS) \
> >          $(if $(findstring 2, $(KBUILD_EXTRA_WARN)), -Wall) \
> >          $<
> >  endif
> > diff --git a/scripts/find-unused-docs.sh b/scripts/find-unused-docs.sh
> > index ee6a50e33aba..d6d397fbf917 100755
> > --- a/scripts/find-unused-docs.sh
> > +++ b/scripts/find-unused-docs.sh
> > @@ -54,7 +54,7 @@ for file in `find $1 -name '*.c'`; do
> >  	if [[ ${FILES_INCLUDED[$file]+_} ]]; then
> >  	continue;
> >  	fi
> > -	str=$(scripts/kernel-doc -export "$file" 2>/dev/null)
> > +	str=$(PYTHONDONTWRITEBYTECODE=1 scripts/kernel-doc -export "$file" 2>/dev/null)
> >  	if [[ -n "$str" ]]; then
> >  	echo "$file"
> >  	fi  
>
Re: [PATCH v3 1/2] scripts/kernel-doc.py: don't create *.pyc files
Posted by Mauro Carvalho Chehab 9 months, 4 weeks ago
Em Wed, 16 Apr 2025 17:19:17 +0800
Mauro Carvalho Chehab <mchehab+huawei@kernel.org> escreveu:

> Em Wed, 16 Apr 2025 11:34:16 +0300
> Jani Nikula <jani.nikula@linux.intel.com> escreveu:
> 
> > On Wed, 16 Apr 2025, Mauro Carvalho Chehab <mchehab+huawei@kernel.org> wrote:
> > > As reported by Andy, kernel-doc.py is creating a __pycache__
> > > directory at build time.
> > >
> > > Disable creation of __pycache__ for the libraries used by
> > > kernel-doc.py, when excecuted via the build system or via
> > > scripts/find-unused-docs.sh.
> > >
> > > Reported-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> > > Closes: https://lore.kernel.org/linux-doc/Z_zYXAJcTD-c3xTe@black.fi.intel.com/
> > > Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> > > ---
> > >  drivers/gpu/drm/Makefile      | 2 +-
> > >  drivers/gpu/drm/i915/Makefile | 2 +-
> > >  include/drm/Makefile          | 2 +-
> > >  scripts/Makefile.build        | 2 +-
> > >  scripts/find-unused-docs.sh   | 2 +-
> > >  5 files changed, 5 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> > > index ed54a546bbe2..d21d0cd2c752 100644
> > > --- a/drivers/gpu/drm/Makefile
> > > +++ b/drivers/gpu/drm/Makefile
> > > @@ -236,7 +236,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 $<; \
> > > -		$(srctree)/scripts/kernel-doc -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \
> > > +		 PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \  
> > 
> > KERNELDOC is not set here.
> 
> > 
> > /bin/sh: 1: -none: not found
> 
> Weird. This is set on Documentation/Makefile:
> 
> 	$ grep KERNELDOC Documentation/Makefile 
> 	KERNELDOC       = $(srctree)/scripts/kernel-doc.py
> 	...
> 
> drivers/gpu/drm/Makefile should be able to see this variable there...

I suspect that the building system tries to confine variables to
sub-directories, so maybe one solution would be to move it to the
main makefile.

could you please check if this patch solves the issue?

[PATCH] Makefile: move KERNELDOC macro to the main Makefile

As kernel-doc script is used not only on Documentation, but
also on scripts and drivers/drm Makefiles, move it to the
main makefile, as otherwise sub-makefiles may not have it.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

diff --git a/Documentation/Makefile b/Documentation/Makefile
index c022b97c487e..7a2069e87dbd 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -60,7 +60,6 @@ endif #HAVE_LATEXMK
 # Internal variables.
 PAPEROPT_a4     = -D latex_paper_size=a4
 PAPEROPT_letter = -D latex_paper_size=letter
-KERNELDOC       = $(srctree)/scripts/kernel-doc.py
 KERNELDOC_CONF  = -D kerneldoc_srctree=$(srctree) -D kerneldoc_bin=$(KERNELDOC)
 ALLSPHINXOPTS   =  $(KERNELDOC_CONF) $(PAPEROPT_$(PAPER)) $(SPHINXOPTS)
 ifneq ($(wildcard $(srctree)/.config),)
diff --git a/Makefile b/Makefile
index 38689a0c3605..c8e46f0c1f63 100644
--- a/Makefile
+++ b/Makefile
@@ -458,6 +458,8 @@ endif
 HOSTRUSTC = rustc
 HOSTPKG_CONFIG	= pkg-config
 
+KERNELDOC       = $(srctree)/scripts/kernel-doc.py
+
 KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
 			 -O2 -fomit-frame-pointer -std=gnu11
 KBUILD_USERCFLAGS  := $(KBUILD_USERHOSTCFLAGS) $(USERCFLAGS)
Re: [PATCH v3 1/2] scripts/kernel-doc.py: don't create *.pyc files
Posted by Andy Shevchenko 9 months, 4 weeks ago
On Wed, Apr 16, 2025 at 05:29:01PM +0800, Mauro Carvalho Chehab wrote:
> Em Wed, 16 Apr 2025 17:19:17 +0800
> Mauro Carvalho Chehab <mchehab+huawei@kernel.org> escreveu:

...

> could you please check if this patch solves the issue?

Doesn't work for me.

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v3 1/2] scripts/kernel-doc.py: don't create *.pyc files
Posted by Mauro Carvalho Chehab 9 months, 4 weeks ago
Em Wed, 16 Apr 2025 17:29:01 +0800
Mauro Carvalho Chehab <mchehab+huawei@kernel.org> escreveu:

> Em Wed, 16 Apr 2025 17:19:17 +0800
> Mauro Carvalho Chehab <mchehab+huawei@kernel.org> escreveu:
> 
> > Em Wed, 16 Apr 2025 11:34:16 +0300
> > Jani Nikula <jani.nikula@linux.intel.com> escreveu:
> > 
> > > On Wed, 16 Apr 2025, Mauro Carvalho Chehab <mchehab+huawei@kernel.org> wrote:
> > > > As reported by Andy, kernel-doc.py is creating a __pycache__
> > > > directory at build time.
> > > >
> > > > Disable creation of __pycache__ for the libraries used by
> > > > kernel-doc.py, when excecuted via the build system or via
> > > > scripts/find-unused-docs.sh.
> > > >
> > > > Reported-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> > > > Closes: https://lore.kernel.org/linux-doc/Z_zYXAJcTD-c3xTe@black.fi.intel.com/
> > > > Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> > > > ---
> > > >  drivers/gpu/drm/Makefile      | 2 +-
> > > >  drivers/gpu/drm/i915/Makefile | 2 +-
> > > >  include/drm/Makefile          | 2 +-
> > > >  scripts/Makefile.build        | 2 +-
> > > >  scripts/find-unused-docs.sh   | 2 +-
> > > >  5 files changed, 5 insertions(+), 5 deletions(-)
> > > >
> > > > diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> > > > index ed54a546bbe2..d21d0cd2c752 100644
> > > > --- a/drivers/gpu/drm/Makefile
> > > > +++ b/drivers/gpu/drm/Makefile
> > > > @@ -236,7 +236,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 $<; \
> > > > -		$(srctree)/scripts/kernel-doc -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \
> > > > +		 PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \  
> > > 
> > > KERNELDOC is not set here.
> > 
> > > 
> > > /bin/sh: 1: -none: not found
> > 
> > Weird. This is set on Documentation/Makefile:
> > 
> > 	$ grep KERNELDOC Documentation/Makefile 
> > 	KERNELDOC       = $(srctree)/scripts/kernel-doc.py
> > 	...
> > 
> > drivers/gpu/drm/Makefile should be able to see this variable there...
> 
> I suspect that the building system tries to confine variables to
> sub-directories, so maybe one solution would be to move it to the
> main makefile.
> 
> could you please check if this patch solves the issue?

Answering myself: it doesn't.

Heh, trying to quickly write a patch before calling it a day is
usually not a good idea ;-)

I'll send a fix tomorrow.

Regards,
Mauro
Re: [PATCH v3 1/2] scripts/kernel-doc.py: don't create *.pyc files
Posted by Andy Shevchenko 9 months, 4 weeks ago
On Wed, Apr 16, 2025 at 05:38:11PM +0800, Mauro Carvalho Chehab wrote:
> Em Wed, 16 Apr 2025 17:29:01 +0800
> Mauro Carvalho Chehab <mchehab+huawei@kernel.org> escreveu:

...

> Heh, trying to quickly write a patch before calling it a day is
> usually not a good idea ;-)
> 
> I'll send a fix tomorrow.

Take your time, we still have a couple or so weeks to address this.

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v3 1/2] scripts/kernel-doc.py: don't create *.pyc files
Posted by Mauro Carvalho Chehab 9 months, 3 weeks ago
Hi Andy,

Em Wed, 16 Apr 2025 12:41:29 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> escreveu:

> On Wed, Apr 16, 2025 at 05:38:11PM +0800, Mauro Carvalho Chehab wrote:
> > Em Wed, 16 Apr 2025 17:29:01 +0800
> > Mauro Carvalho Chehab <mchehab+huawei@kernel.org> escreveu:  
> 
> ...
> 
> > Heh, trying to quickly write a patch before calling it a day is
> > usually not a good idea ;-)
> > 
> > I'll send a fix tomorrow.  
> 
> Take your time, we still have a couple or so weeks to address this.

Sent a v3. Please check.

Regards,
Mauro
Re: [PATCH v3 1/2] scripts/kernel-doc.py: don't create *.pyc files
Posted by Andy Shevchenko 9 months, 4 weeks ago
On Wed, Apr 16, 2025 at 05:29:01PM +0800, Mauro Carvalho Chehab wrote:
> Em Wed, 16 Apr 2025 17:19:17 +0800
> Mauro Carvalho Chehab <mchehab+huawei@kernel.org> escreveu:
> > Em Wed, 16 Apr 2025 11:34:16 +0300
> > Jani Nikula <jani.nikula@linux.intel.com> escreveu:
> > > On Wed, 16 Apr 2025, Mauro Carvalho Chehab <mchehab+huawei@kernel.org> wrote:

...

> > > >  quiet_cmd_hdrtest = HDRTEST $(patsubst %.hdrtest,%.h,$@)
> > > >        cmd_hdrtest = \
> > > >  		$(CC) $(c_flags) -fsyntax-only -x c /dev/null -include $< -include $<; \
> > > > -		$(srctree)/scripts/kernel-doc -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \
> > > > +		 PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \  
> > > 
> > > KERNELDOC is not set here.
> > 
> > > 
> > > /bin/sh: 1: -none: not found
> > 
> > Weird. This is set on Documentation/Makefile:
> > 
> > 	$ grep KERNELDOC Documentation/Makefile 
> > 	KERNELDOC       = $(srctree)/scripts/kernel-doc.py
> > 	...
> > 
> > drivers/gpu/drm/Makefile should be able to see this variable there...
> 
> I suspect that the building system tries to confine variables to
> sub-directories, so maybe one solution would be to move it to the
> main makefile.
> 
> could you please check if this patch solves the issue?
> 
> [PATCH] Makefile: move KERNELDOC macro to the main Makefile
> 
> As kernel-doc script is used not only on Documentation, but
> also on scripts and drivers/drm Makefiles, move it to the
> main makefile, as otherwise sub-makefiles may not have it.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> 
> diff --git a/Documentation/Makefile b/Documentation/Makefile
> index c022b97c487e..7a2069e87dbd 100644
> --- a/Documentation/Makefile
> +++ b/Documentation/Makefile
> @@ -60,7 +60,6 @@ endif #HAVE_LATEXMK
>  # Internal variables.
>  PAPEROPT_a4     = -D latex_paper_size=a4
>  PAPEROPT_letter = -D latex_paper_size=letter
> -KERNELDOC       = $(srctree)/scripts/kernel-doc.py
>  KERNELDOC_CONF  = -D kerneldoc_srctree=$(srctree) -D kerneldoc_bin=$(KERNELDOC)

In this case the _CONF makes sense to move together as they are coupled
semantically.

>  ALLSPHINXOPTS   =  $(KERNELDOC_CONF) $(PAPEROPT_$(PAPER)) $(SPHINXOPTS)
>  ifneq ($(wildcard $(srctree)/.config),)
> diff --git a/Makefile b/Makefile
> index 38689a0c3605..c8e46f0c1f63 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -458,6 +458,8 @@ endif
>  HOSTRUSTC = rustc
>  HOSTPKG_CONFIG	= pkg-config
>  
> +KERNELDOC       = $(srctree)/scripts/kernel-doc.py
> +
>  KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
>  			 -O2 -fomit-frame-pointer -std=gnu11
>  KBUILD_USERCFLAGS  := $(KBUILD_USERHOSTCFLAGS) $(USERCFLAGS)

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v3 1/2] scripts/kernel-doc.py: don't create *.pyc files
Posted by Mauro Carvalho Chehab 9 months, 3 weeks ago
Em Wed, 16 Apr 2025 12:36:06 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> escreveu:

> On Wed, Apr 16, 2025 at 05:29:01PM +0800, Mauro Carvalho Chehab wrote:
> > Em Wed, 16 Apr 2025 17:19:17 +0800
> > Mauro Carvalho Chehab <mchehab+huawei@kernel.org> escreveu:  
> > > Em Wed, 16 Apr 2025 11:34:16 +0300
> > > Jani Nikula <jani.nikula@linux.intel.com> escreveu:  
> > > > On Wed, 16 Apr 2025, Mauro Carvalho Chehab <mchehab+huawei@kernel.org> wrote:  
> 
> ...
> 
> > > > >  quiet_cmd_hdrtest = HDRTEST $(patsubst %.hdrtest,%.h,$@)
> > > > >        cmd_hdrtest = \
> > > > >  		$(CC) $(c_flags) -fsyntax-only -x c /dev/null -include $< -include $<; \
> > > > > -		$(srctree)/scripts/kernel-doc -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \
> > > > > +		 PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \    
> > > > 
> > > > KERNELDOC is not set here.  
> > >   
> > > > 
> > > > /bin/sh: 1: -none: not found  
> > > 
> > > Weird. This is set on Documentation/Makefile:
> > > 
> > > 	$ grep KERNELDOC Documentation/Makefile 
> > > 	KERNELDOC       = $(srctree)/scripts/kernel-doc.py
> > > 	...
> > > 
> > > drivers/gpu/drm/Makefile should be able to see this variable there...  
> > 
> > I suspect that the building system tries to confine variables to
> > sub-directories, so maybe one solution would be to move it to the
> > main makefile.
> > 
> > could you please check if this patch solves the issue?
> > 
> > [PATCH] Makefile: move KERNELDOC macro to the main Makefile
> > 
> > As kernel-doc script is used not only on Documentation, but
> > also on scripts and drivers/drm Makefiles, move it to the
> > main makefile, as otherwise sub-makefiles may not have it.
> > 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> > 
> > diff --git a/Documentation/Makefile b/Documentation/Makefile
> > index c022b97c487e..7a2069e87dbd 100644
> > --- a/Documentation/Makefile
> > +++ b/Documentation/Makefile
> > @@ -60,7 +60,6 @@ endif #HAVE_LATEXMK
> >  # Internal variables.
> >  PAPEROPT_a4     = -D latex_paper_size=a4
> >  PAPEROPT_letter = -D latex_paper_size=letter
> > -KERNELDOC       = $(srctree)/scripts/kernel-doc.py
> >  KERNELDOC_CONF  = -D kerneldoc_srctree=$(srctree) -D kerneldoc_bin=$(KERNELDOC)  
> 
> In this case the _CONF makes sense to move together as they are coupled
> semantically.

In a matter of fact, it doesn't...

> >  ALLSPHINXOPTS   =  $(KERNELDOC_CONF) $(PAPEROPT_$(PAPER)) $(SPHINXOPTS)

This is just part of ALLSPHINXOPTS, where it places two definitions
to be used by the Sphinx kerneldoc extension. I need to double-check
it, but I suspect that this is not even used there anymore. If it is
still used, it can be cleaned up after we remove the Perl version.

So, I prefer to keep this (perhaps with a different name) at the
documentation makefile.

Regards,
Mauro
Re: [PATCH v3 1/2] scripts/kernel-doc.py: don't create *.pyc files
Posted by Andy Shevchenko 9 months, 4 weeks ago
On Wed, Apr 16, 2025 at 05:19:17PM +0800, Mauro Carvalho Chehab wrote:
> Em Wed, 16 Apr 2025 11:34:16 +0300
> Jani Nikula <jani.nikula@linux.intel.com> escreveu:
> > On Wed, 16 Apr 2025, Mauro Carvalho Chehab <mchehab+huawei@kernel.org> wrote:

...

> > >  quiet_cmd_hdrtest = HDRTEST $(patsubst %.hdrtest,%.h,$@)
> > >        cmd_hdrtest = \
> > >  		$(CC) $(c_flags) -fsyntax-only -x c /dev/null -include $< -include $<; \
> > > -		$(srctree)/scripts/kernel-doc -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \
> > > +		 PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \  
> > 
> > KERNELDOC is not set here.
> 
> > 
> > /bin/sh: 1: -none: not found
> 
> Weird. This is set on Documentation/Makefile:
> 
> 	$ grep KERNELDOC Documentation/Makefile 
> 	KERNELDOC       = $(srctree)/scripts/kernel-doc.py
> 	...
> 
> drivers/gpu/drm/Makefile should be able to see this variable there...

Does it work in the case of `make drivers/gpu/drm` ? This is probably how Jani
tried it.

> > >  		touch $@

-- 
With Best Regards,
Andy Shevchenko