# ===========================================================================
 
-subdir-obj-y := $(filter %/built-in.a, $(real-obj-y))
+# subdir-builtin may contain duplications. Use $(sort ...)
+subdir-builtin := $(sort $(filter %/built-in.a, $(real-obj-y)))
 
 ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),)
 lib-target := $(obj)/lib.a
 $(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE
        $(call if_changed_rule,as_o_S)
 
-targets += $(filter-out $(subdir-obj-y), $(real-obj-y)) $(real-obj-m) $(lib-y)
+targets += $(filter-out $(subdir-builtin), $(real-obj-y)) $(real-obj-m) $(lib-y)
 targets += $(extra-y) $(always-y) $(MAKECMDGOALS)
 
 # Linker scripts preprocessor (.lds.S -> .lds)
 # ---------------------------------------------------------------------------
 
 # To build objects in subdirs, we need to descend into the directories
-$(obj)/%/built-in.a: $(obj)/% ;
+$(subdir-builtin): $(obj)/%/built-in.a: $(obj)/% ;
 
 #
 # Rule to compile a set of .o files into one .a file (without symbol table)
 $(subdir-ym):
        $(Q)$(MAKE) $(build)=$@ \
        $(if $(filter $@/, $(KBUILD_SINGLE_TARGETS)),single-build=) \
-       need-builtin=$(if $(filter $@/built-in.a, $(subdir-obj-y)),1) \
+       need-builtin=$(if $(filter $@/built-in.a, $(subdir-builtin)),1) \
        need-modorder=$(if $(need-modorder),$(if $(filter $@/modules.order, $(modorder)),1))
 
 # Add FORCE to the prequisites of a target to force it to be always rebuilt.