Re: [PATCH 4/5] kbuild: hdrtest: place header test files in .hdrtest subdirectories

From: Masahiro Yamada
Date: Tue Apr 01 2025 - 13:50:21 EST


On Tue, Apr 1, 2025 at 9:19 PM Jani Nikula <jani.nikula@xxxxxxxxx> wrote:
>
> The header tests track whether headers have been checked using empty
> *.hdrtest files in the build tree. This pollutes the build directories,
> as the files live in the same "name space" as the real output files,
> messing with TAB completion among other things.
>
> Hide the disgusting turds by placing them in .hdrtest subdirectories.
>
> Note that it would be somewhat nicer to have the basename of the
> .hdrtest files be dot-prefixed instead of using subdirectories. However,
> it's challenging to come up with a pattern rule for that, as we can list
> headers to test in the subdirectories of $(src) too, without requiring
> Makefiles and kbuild to descend to each of them.
>
> Reported-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
> Closes: https://lore.kernel.org/r/CAHk-=wjMrqzuUmH-mFbR_46EWEFS=bB=J7h9ABMVy56Vi81PKQ@xxxxxxxxxxxxxx
> Fixes: fcbb8461fd23 ("kbuild: remove header compile test")
> Cc: Masahiro Yamada <masahiroy@xxxxxxxxxx>
> Cc: David Airlie <airlied@xxxxxxxxx>
> Cc: Daniel Vetter <daniel@xxxxxxxx>
> Signed-off-by: Jani Nikula <jani.nikula@xxxxxxxxx>
>
> ---


Linus did not mention anything bad for usr/include/.

This crap is unneeded.

NACK.






>
> Cc: linux-kbuild@xxxxxxxxxxxxxxx
> Cc: dri-devel@xxxxxxxxxxxxxxxxxxxxx
> Cc: intel-xe@xxxxxxxxxxxxxxxxxxxxx
> Cc: intel-gfx@xxxxxxxxxxxxxxxxxxxxx
> ---
> usr/include/Makefile | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/usr/include/Makefile b/usr/include/Makefile
> index e3d6b03527fe..4fb574fd3fec 100644
> --- a/usr/include/Makefile
> +++ b/usr/include/Makefile
> @@ -71,7 +71,7 @@ endif
> # asm-generic/*.h is used by asm/*.h, and should not be included directly
> no-header-test += asm-generic/%
>
> -always-y := $(patsubst $(obj)/%.h,%.hdrtest, $(shell find $(obj) -name '*.h' 2>/dev/null))
> +always-y := $(patsubst $(obj)/%.h,.hdrtest/%.hdrtest, $(shell find $(obj) -name '*.h' 2>/dev/null))
>
> # Include the header twice to detect missing include guard.
> quiet_cmd_hdrtest = HDRTEST $<
> @@ -81,7 +81,7 @@ quiet_cmd_hdrtest = HDRTEST $<
> $(PERL) $(src)/headers_check.pl $(obj) $<; \
> touch $@
>
> -$(obj)/%.hdrtest: $(obj)/%.h FORCE
> +$(obj)/.hdrtest/%.hdrtest: $(obj)/%.h FORCE
> $(call if_changed_dep,hdrtest)
>
> # Since GNU Make 4.3, $(patsubst $(obj)/%/,%,$(wildcard $(obj)/*/)) works.
> --
> 2.39.5
>


--
Best Regards
Masahiro Yamada