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.

kbuild: do not create orphan built-in.a or obj-y objects

Both 'obj-y += foo/' and 'obj-m += foo/' request Kbuild to visit the
sub-directory foo/, but the difference is that only the former combines
foo/built-in.a into the built-in.a of the current directory because
everything in sub-directories visited by obj-m is supposed to be modular.

So, it makes sense to create built-in.a only if that sub-directory is
reachable by the chain of obj-y. Otherwise, built-in.a will not be
linked into vmlinux anyway. For the same reason, it is pointless to
compile obj-y objects in the directory visited by obj-m.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

+5 -1
+1 -1
scripts/Makefile.build
··· 66 66 real-obj-y += $(obj)/lib-ksyms.o 67 67 endif 68 68 69 - ifneq ($(strip $(real-obj-y) $(need-builtin)),) 69 + ifdef need-builtin 70 70 builtin-target := $(obj)/built-in.a 71 71 endif 72 72
+4
scripts/Makefile.lib
··· 35 35 subdir-y += $(__subdir-y) 36 36 __subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) 37 37 subdir-m += $(__subdir-m) 38 + ifdef need-builtin 38 39 obj-y := $(patsubst %/, %/built-in.a, $(obj-y)) 40 + else 41 + obj-y := $(filter-out %/, $(obj-y)) 42 + endif 39 43 obj-m := $(filter-out %/, $(obj-m)) 40 44 41 45 # Subdirectories we need to descend into