summaryrefslogtreecommitdiffstats
path: root/core/combo/HOST_darwin-x86.mk
diff options
context:
space:
mode:
authorYing Wang <wangying@google.com>2012-01-20 12:22:49 -0800
committerYing Wang <wangying@google.com>2012-01-20 12:59:58 -0800
commitfcf246c989110d76a80fc66ac72f1fbba4289ff6 (patch)
tree19aa24ff0f5b7c2b1731dc840fe20e6feb0cbb89 /core/combo/HOST_darwin-x86.mk
parent545b7996cc5510310f69227f14e4e4e67e95e80c (diff)
downloadbuild-fcf246c989110d76a80fc66ac72f1fbba4289ff6.zip
build-fcf246c989110d76a80fc66ac72f1fbba4289ff6.tar.gz
build-fcf246c989110d76a80fc66ac72f1fbba4289ff6.tar.bz2
Workaround for lack of "-Wl,--whole-archive" in MacOS's linker.
Change-Id: I2b1de0a253d341bcb7ee05fdc96bdc0d0967985e
Diffstat (limited to 'core/combo/HOST_darwin-x86.mk')
-rw-r--r--core/combo/HOST_darwin-x86.mk22
1 files changed, 21 insertions, 1 deletions
diff --git a/core/combo/HOST_darwin-x86.mk b/core/combo/HOST_darwin-x86.mk
index 54a64a3..f5fd001 100644
--- a/core/combo/HOST_darwin-x86.mk
+++ b/core/combo/HOST_darwin-x86.mk
@@ -63,14 +63,34 @@ HOST_GLOBAL_ARFLAGS := cqs
HOST_CUSTOM_LD_COMMAND := true
+# Workaround for lack of "-Wl,--whole-archive" in MacOS's linker.
+define _darwin-extract-and-include-single-whole-static-lib
+@echo "preparing StaticLib: $(PRIVATE_MODULE) [including $(1)]"
+$(hide) ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(1)))_objs;\
+ mkdir -p $$ldir; \
+ filelist=; \
+ for f in `$(TARGET_AR) t $(1)`; do \
+ $(TARGET_AR) p $(1) $$f > $$ldir/$$f; \
+ filelist="$$filelist $$ldir/$$f"; \
+ done ;
+
+endef
+
+define darwin-extract-and-include-whole-static-libs
+$(if $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES), $(hide) rm -rf $(PRIVATE_INTERMEDIATES_DIR)/WHOLE)
+$(foreach lib,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES), \
+ $(call _darwin-extract-and-include-single-whole-static-lib, $(lib)))
+endef
+
define transform-host-o-to-shared-lib-inner
+$(call darwin-extract-and-include-whole-static-libs)
$(hide) $(PRIVATE_CXX) \
-dynamiclib -single_module -read_only_relocs suppress \
$(HOST_GLOBAL_LD_DIRS) \
$(HOST_GLOBAL_LDFLAGS) \
$(PRIVATE_ALL_OBJECTS) \
+ $(if $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES), `find $(PRIVATE_INTERMEDIATES_DIR)/WHOLE -name '*.o' 2>/dev/null`) \
$(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
- $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
$(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \