6969
7070# ===========================================================================
7171
72- subdir-obj-y := $(filter %/built-in.a, $(real-obj-y))
72+ # subdir-builtin may contain duplications. Use $(sort ...)
73+ subdir-builtin := $(sort $(filter %/built-in.a, $(real-obj-y)))
7374
7475ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),)
7576lib-target := $(obj)/lib.a
@@ -356,7 +357,7 @@ endif
356357$(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE
357358 $(call if_changed_rule,as_o_S)
358359
359- targets += $(filter-out $(subdir-obj-y ), $(real-obj-y)) $(real-obj-m) $(lib-y)
360+ targets += $(filter-out $(subdir-builtin ), $(real-obj-y)) $(real-obj-m) $(lib-y)
360361targets += $(extra-y) $(always-y) $(MAKECMDGOALS)
361362
362363# Linker scripts preprocessor (.lds.S -> .lds)
@@ -381,7 +382,7 @@ $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler
381382# ---------------------------------------------------------------------------
382383
383384# To build objects in subdirs, we need to descend into the directories
384- $(obj)/%/built-in.a: $(obj)/% ;
385+ $(subdir-builtin): $( obj)/%/built-in.a: $(obj)/% ;
385386
386387#
387388# Rule to compile a set of .o files into one .a file (without symbol table)
@@ -489,7 +490,7 @@ PHONY += $(subdir-ym)
489490$(subdir-ym):
490491 $(Q)$(MAKE) $(build)=$@ \
491492 $(if $(filter $@/, $(KBUILD_SINGLE_TARGETS)),single-build=) \
492- need-builtin=$(if $(filter $@/built-in.a, $(subdir-obj-y )),1) \
493+ need-builtin=$(if $(filter $@/built-in.a, $(subdir-builtin )),1) \
493494 need-modorder=$(if $(need-modorder),$(if $(filter $@/modules.order, $(modorder)),1))
494495
495496# Add FORCE to the prequisites of a target to force it to be always rebuilt.
0 commit comments