From 44203f3316e3ba574555c75d65176df7f22417da Mon Sep 17 00:00:00 2001 From: Christopher Ferris Date: Wed, 7 Jan 2015 17:14:03 -0800 Subject: Fix whole static lib handling of duplicate names. If LOCAL_WHOLE_STATIC_LIBRARIES contains a library that has two files that have the same name but are in different directories, only the first gets included. This fix detects this case, and uses the m option to ar to force the duplicate object to the end of the archive. After this, using the p option gets the correct object file. Change-Id: I2e183f48cef3c79499d4ab8ff147444611ff938b --- core/definitions.mk | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/core/definitions.mk b/core/definitions.mk index 935050d..2ef7961 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -1182,10 +1182,21 @@ define _extract-and-include-single-target-whole-static-lib $(hide) ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(1)))_objs;\ rm -rf $$ldir; \ mkdir -p $$ldir; \ + cp $(1) $$ldir; \ + lib_to_include=$$ldir/$(notdir $(1)); \ filelist=; \ + subdir=0; \ for f in `$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) t $(1)`; do \ - $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) p $(1) $$f > $$ldir/$$f; \ - filelist="$$filelist $$ldir/$$f"; \ + if [ -e $$ldir/$$f ]; then \ + mkdir $$ldir/$$subdir; \ + ext=$$subdir/; \ + subdir=$$((subdir+1)); \ + $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) m $$lib_to_include $$f; \ + else \ + ext=; \ + fi; \ + $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) p $$lib_to_include $$f > $$ldir/$$ext$$f; \ + filelist="$$filelist $$ldir/$$ext$$f"; \ done ; \ $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_ARFLAGS) \ $(PRIVATE_ARFLAGS) $@ $$filelist @@ -1227,10 +1238,21 @@ define _extract-and-include-single-host-whole-static-lib $(hide) ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(1)))_objs;\ rm -rf $$ldir; \ mkdir -p $$ldir; \ + cp $(1) $$ldir; \ + lib_to_include=$$ldir/$(notdir $(1)); \ filelist=; \ + subdir=0; \ for f in `$($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_AR) t $(1) | \grep '\.o$$'`; do \ - $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_AR) p $(1) $$f > $$ldir/$$f; \ - filelist="$$filelist $$ldir/$$f"; \ + if [ -e $$ldir/$$f ]; then \ + mkdir $$ldir/$$subdir; \ + ext=$$subdir/; \ + subdir=$$((subdir+1)); \ + $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_AR) m $$lib_to_include $$f; \ + else \ + ext=; \ + fi; \ + $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_AR) p $$lib_to_include $$f > $$ldir/$$ext$$f; \ + filelist="$$filelist $$ldir/$$ext$$f"; \ done ; \ $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_AR) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_ARFLAGS) \ $(PRIVATE_ARFLAGS) $@ $$filelist -- cgit v1.1