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.
Unified · Split
| @@ -109,11 +109,7 @@ test_fpu-y := test_fpu_glue.o test_fpu_impl.o · 108 unmodified lines | ||
| 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 |
| @@ -17,7 +17,7 @@ kunit-objs += debugfs.o · 16 unmodified lines | ||
| 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 |