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

Configure Feed

Select the types of activity you want to include in your feed.

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: 7170b7ed6acb ("kunit: Add "hooks" to call into KUnit when it's built as a module").
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/linux-kselftest/CAHk-=wiEf7irTKwPJ0jTMOF3CS-13UXmF6Fns3wuWpOZ_wGyZQ@mail.gmail.com/
Signed-off-by: David Gow <davidgow@google.com>
Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

David Gow and committed by
Linus Torvalds
32ff6831 5ca26d60

+5 -9
+4 -8
lib/Makefile
··· 127 127 128 128 obj-$(CONFIG_TEST_LIVEPATCH) += livepatch/ 129 129 130 - obj-$(CONFIG_KUNIT) += kunit/ 131 - # Include the KUnit hooks unconditionally. They'll compile to nothing if 132 - # CONFIG_KUNIT=n, otherwise will be a small table of static data (static key, 133 - # function pointers) which need to be built-in even when KUnit is a module. 134 - ifeq ($(CONFIG_KUNIT), m) 135 - obj-y += kunit/hooks.o 136 - else 137 - obj-$(CONFIG_KUNIT) += kunit/hooks.o 130 + # Some KUnit files (hooks.o) need to be built-in even when KUnit is a module, 131 + # so we can't just use obj-$(CONFIG_KUNIT). 132 + ifdef CONFIG_KUNIT 133 + obj-y += kunit/ 138 134 endif 139 135 140 136 ifeq ($(CONFIG_DEBUG_KOBJECT),y)
+1 -1
lib/kunit/Makefile
··· 13 13 endif 14 14 15 15 # KUnit 'hooks' are built-in even when KUnit is built as a module. 16 - lib-y += hooks.o 16 + obj-y += hooks.o 17 17 18 18 obj-$(CONFIG_KUNIT_TEST) += kunit-test.o 19 19