Kbuild: Support nested composite objects

Kbuild composite object only supports one level of composite objects.
That is, a composite object may only be composed of real compilable
objects. A composite object may not itself be composed of other
composite objects.

As a simple example, the following Kbuild description is not supported:

bar-a-y := a/bar0.o a/bar1.o
bar-b-y := b/bar2.o b/bar3.o

foo-objs := bar-a.o bar-b.o

obj-m += foo.o

Add such support by recursively searching for composite objects and
listing them in $(multi-used-*) and $(real-obj-*).

Change-Id: I59df994237e27bf54d11034ff871442938050313
Signed-off-by: Elliot Berman <eberman@codeaurora.org>
Signed-off-by: Jeff Johnson <jjohnson@codeaurora.org>
This commit is contained in:
Elliot Berman 2021-01-19 17:48:07 -08:00 committed by Jeff Johnson
parent 993d65f16c
commit ac9f9a9166
2 changed files with 9 additions and 2 deletions

View File

@ -5,6 +5,10 @@ SUBLEVEL = 61
EXTRAVERSION =
NAME = Kleptomaniac Octopus
# indicate that change "Kbuild: Support nested composite objects" is
# present in the kernel so that out-of-tree modules can act upon it
export KERNEL_SUPPORTS_NESTED_COMPOSITES := y
# *DOCUMENTATION*
# To see a list of typical targets execute "make help"
# More info can be located in ./README

View File

@ -44,7 +44,8 @@ subdir-ym := $(sort $(subdir-y) $(subdir-m))
# Expand $(foo-objs) $(foo-y) by calling $(call suffix-search,foo.o,-objs -y)
suffix-search = $(foreach s,$(2),$($(1:.o=$s)))
# If $(foo-objs), $(foo-y), $(foo-m), or $(foo-) exists, foo.o is a composite object
multi-search = $(sort $(foreach m,$(1), $(if $(strip $(call suffix-search,$(m),$(2) -)), $(m))))
multi-search = $(sort $(foreach m,$(1),$(if $(strip $(call suffix-search,$(m),$(2) -)),\
$(m) $(call multi-search,$(filter-out $(m),$(call suffix-search,$(m),$(2))),$(2)))))
multi-used-y := $(call multi-search,$(obj-y),-objs -y)
multi-used-m := $(call multi-search,$(obj-m),-objs -y -m)
multi-used := $(multi-used-y) $(multi-used-m)
@ -55,7 +56,9 @@ subdir-obj-y := $(filter %/built-in.a, $(obj-y))
# Replace multi-part objects by their individual parts,
# including built-in.a from subdirectories
real-search = $(foreach m,$(1), $(if $(strip $(call suffix-search,$(m),$(2) -)),$(call suffix-search,$(m),$(2)),$(m)))
real-search = $(foreach m,$(1), $(if $(strip $(call suffix-search,$(m),$(2) -)), \
$(filter $(m),$(call suffix-search,$(m),$(2))) $(call real-search,$(filter-out $(m),$(call suffix-search,$(m),$(2))),$(2)),\
$(m)))
real-obj-y := $(call real-search, $(obj-y),-objs -y)
real-obj-m := $(call real-search, $(obj-m),-objs -y -m)