From ac9f9a916691495666ab6e990ec061620fdb770d Mon Sep 17 00:00:00 2001 From: Elliot Berman Date: Tue, 19 Jan 2021 17:48:07 -0800 Subject: [PATCH] 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 Signed-off-by: Jeff Johnson --- Makefile | 4 ++++ scripts/Makefile.lib | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0fb38663ccde..af6024e31374 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index ecf084bf1a95..b0c8d7a962e5 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -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)