From 993d65f16c3084f99156bd91087ee323e833e679 Mon Sep 17 00:00:00 2001 From: Elliot Berman Date: Tue, 19 Jan 2021 17:42:36 -0800 Subject: [PATCH 1/2] Kbuild: Make composite object searching more generic Reduce repeated logic around expanding composite objects in preparation for later commit to support nested composite objects. Change-Id: I9f2f4788bd4a85f105432e4827f9984cd488b647 Signed-off-by: Elliot Berman Signed-off-by: Jeff Johnson --- scripts/Makefile.lib | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index e62bb0513297..ecf084bf1a95 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -41,9 +41,12 @@ obj-m := $(filter-out %/, $(obj-m)) # Subdirectories we need to descend into 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-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-))), $(m)))) -multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)) $($(m:.o=-))), $(m)))) +multi-search = $(sort $(foreach m,$(1), $(if $(strip $(call suffix-search,$(m),$(2) -)), $(m)))) +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) # $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to @@ -52,8 +55,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-obj-y := $(foreach m, $(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) -real-obj-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)) $($(m:.o=-))),$($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)),$(m))) +real-search = $(foreach m,$(1), $(if $(strip $(call suffix-search,$(m),$(2) -)),$(call suffix-search,$(m),$(2)),$(m))) +real-obj-y := $(call real-search, $(obj-y),-objs -y) +real-obj-m := $(call real-search, $(obj-m),-objs -y -m) # DTB # If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built From ac9f9a916691495666ab6e990ec061620fdb770d Mon Sep 17 00:00:00 2001 From: Elliot Berman Date: Tue, 19 Jan 2021 17:48:07 -0800 Subject: [PATCH 2/2] 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)