Commit 32ff6831 authored by David Gow's avatar David Gow Committed by Linus Torvalds

kunit: Fix 'hooks.o' build by recursing into kunit

KUnit's 'hooks.o' file need to be built-in whenever KUnit is enabled
(even if CONFIG_KUNIT=m).  We'd previously attemtped to do this by
adding 'kunit/hooks.o' to obj-y in lib/Makefile, but this caused hooks.c
to be rebuilt even when it was unchanged.

Instead, always recurse into lib/kunit using obj-y when KUnit is
enabled, and add the hooks there.

Fixes: 7170b7ed ("kunit: Add "hooks" to call into KUnit when it's built as a module").
Reported-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/linux-kselftest/CAHk-=wiEf7irTKwPJ0jTMOF3CS-13UXmF6Fns3wuWpOZ_wGyZQ@mail.gmail.com/Signed-off-by: default avatarDavid Gow <davidgow@google.com>
Reviewed-by: default avatarBrendan Higgins <brendanhiggins@google.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 5ca26d60
...@@ -127,14 +127,10 @@ CFLAGS_test_fpu.o += $(FPU_CFLAGS) ...@@ -127,14 +127,10 @@ CFLAGS_test_fpu.o += $(FPU_CFLAGS)
obj-$(CONFIG_TEST_LIVEPATCH) += livepatch/ obj-$(CONFIG_TEST_LIVEPATCH) += livepatch/
obj-$(CONFIG_KUNIT) += kunit/ # Some KUnit files (hooks.o) need to be built-in even when KUnit is a module,
# Include the KUnit hooks unconditionally. They'll compile to nothing if # so we can't just use obj-$(CONFIG_KUNIT).
# CONFIG_KUNIT=n, otherwise will be a small table of static data (static key, ifdef CONFIG_KUNIT
# function pointers) which need to be built-in even when KUnit is a module. obj-y += kunit/
ifeq ($(CONFIG_KUNIT), m)
obj-y += kunit/hooks.o
else
obj-$(CONFIG_KUNIT) += kunit/hooks.o
endif endif
ifeq ($(CONFIG_DEBUG_KOBJECT),y) ifeq ($(CONFIG_DEBUG_KOBJECT),y)
......
...@@ -13,7 +13,7 @@ kunit-objs += debugfs.o ...@@ -13,7 +13,7 @@ kunit-objs += debugfs.o
endif endif
# KUnit 'hooks' are built-in even when KUnit is built as a module. # KUnit 'hooks' are built-in even when KUnit is built as a module.
lib-y += hooks.o obj-y += hooks.o
obj-$(CONFIG_KUNIT_TEST) += kunit-test.o obj-$(CONFIG_KUNIT_TEST) += kunit-test.o
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment