Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kunit: Always descend into kunit directory during build

For kbuild to properly clean up these build artifacts in the subdirectory,
even after CONFIG_KUNIT changed do disabled, the directory needs to be
processed always.

Pushing the special logic for hook.o into the kunit Makefile also makes the
logic easier to understand.

Link: https://lore.kernel.org/r/20250813-kunit-always-descend-v1-1-7bbd387ff13b@linutronix.de
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Thomas Weißschuh and committed by
Shuah Khan
29128da2 8f5ae30d

+1 -5
-4
lib/Makefile
··· 109 109 CFLAGS_test_fpu_impl.o += $(CC_FLAGS_FPU) 110 110 CFLAGS_REMOVE_test_fpu_impl.o += $(CC_FLAGS_NO_FPU) 111 111 112 - # Some KUnit files (hooks.o) need to be built-in even when KUnit is a module, 113 - # so we can't just use obj-$(CONFIG_KUNIT). 114 - ifdef CONFIG_KUNIT 115 112 obj-y += kunit/ 116 - endif 117 113 118 114 ifeq ($(CONFIG_DEBUG_KOBJECT),y) 119 115 CFLAGS_kobject.o += -DDEBUG
+1 -1
lib/kunit/Makefile
··· 17 17 endif 18 18 19 19 # KUnit 'hooks' are built-in even when KUnit is built as a module. 20 - obj-y += hooks.o 20 + obj-$(if $(CONFIG_KUNIT),y) += hooks.o 21 21 22 22 obj-$(CONFIG_KUNIT_TEST) += kunit-test.o 23 23 obj-$(CONFIG_KUNIT_TEST) += platform-test.o