On 7/28/26 5:06 PM, Ricardo B. Marlière (SUSE) wrote:
> [...]
> 
> diff --git a/tools/testing/selftests/bpf/Makefile 
> b/tools/testing/selftests/bpf/Makefile
> index 7d42632f9d42..b150a66f3c25 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
> @@ -135,6 +135,9 @@ TEST_PROGS_EXTENDED := \
>  TEST_KMODS := bpf_testmod.ko bpf_test_no_cfi.ko bpf_test_modorder_x.ko \
>       bpf_test_modorder_y.ko bpf_test_rqspinlock.ko
>  TEST_KMOD_TARGETS = $(addprefix $(OUTPUT)/,$(TEST_KMODS))
> +# Build directory for kernel modules: routed to $(OUTPUT)/test_kmods when
> +# OUTPUT is set so that kbuild intermediates stay out of the source tree.
> +TEST_KMODS_OUTDIR := $(if $(OUTPUT),$(OUTPUT)/test_kmods,test_kmods)
>  
>  # Compile but not part of 'make run_tests'
>  TEST_GEN_PROGS_EXTENDED = \
> @@ -163,8 +166,8 @@ override define CLEAN
>       $(Q)$(RM) -r $(TEST_GEN_FILES)
>       $(Q)$(RM) -r $(TEST_KMODS)
>       $(Q)$(RM) -r $(EXTRA_CLEAN)
> -     $(Q)$(MAKE) -C test_kmods clean
> -     $(Q)$(MAKE) -C libarena clean
> +     $(Q)$(MAKE) -C test_kmods $(if $(OUTPUT),OUTPUT=$(OUTPUT)/test_kmods) 
> clean
> +     $(Q)$(MAKE) -C libarena $(if $(OUTPUT),OUTPUT=$(OUTPUT)/libarena) clean

This is broken. What happens if the caller set OUTPUT but not O= ?

If at linux root you do:

  $ make defconfig && make -j$(nproc)
  $ mkdir -p /tmp/kout
  $ make -C tools/testing/selftests/bpf OUTPUT=/tmp/kout clean

it destroys the root Makefile:

  $ git diff --stat -- Makefile
  Makefile | 2364 
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  1 file changed, 5 insertions(+), 2359 deletions(-)

  $ cat Makefile
  # Automatically generated by 
/home/isolodrai/sandbox/2026-08-06.review.out-of-tree-fixes/linux/Makefile: 
don't edit
  export KBUILD_OUTPUT = 
/home/isolodrai/sandbox/2026-08-06.review.out-of-tree-fixes/linux
  export KBUILD_EXTMOD = 
/home/isolodrai/sandbox/2026-08-06.review.out-of-tree-fixes/linux/tools/testing/selftests/bpf/test_kmods
  export KBUILD_EXTMOD_OUTPUT = /tmp/kout/test_kmods
  include 
/home/isolodrai/sandbox/2026-08-06.review.out-of-tree-fixes/linux/Makefile

pw-bot: cr


Also the selftests clean loop runs clean rules this way [1]:

clean:
        @for TARGET in $(TARGETS) $(INSTALL_DEP_TARGETS); do \
                BUILD_TARGET=$$BUILD/$$TARGET;  \
                $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
        done;

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/testing/selftests/Makefile?h=v7.2-rc6#n325


>       $(Q)$(MAKE) docs-clean
>  endef
>  
> [...]
> 


Reply via email to