summaryrefslogtreecommitdiffstats
path: root/core/combo/HOST_darwin-x86.mk
diff options
context:
space:
mode:
Diffstat (limited to 'core/combo/HOST_darwin-x86.mk')
-rw-r--r--core/combo/HOST_darwin-x86.mk33
1 files changed, 30 insertions, 3 deletions
diff --git a/core/combo/HOST_darwin-x86.mk b/core/combo/HOST_darwin-x86.mk
index 5ab2c0d..2ad3dd9 100644
--- a/core/combo/HOST_darwin-x86.mk
+++ b/core/combo/HOST_darwin-x86.mk
@@ -17,11 +17,17 @@
# Configuration for Darwin (Mac OS X) on x86.
# Included by combo/select.mk
-# We build everything in 32-bit, because some host tools are
-# 32-bit-only anyway (emulator, acc), and because it gives us
+ifneq ($(strip $(BUILD_HOST_64bit)),)
+# By default we build everything in 32-bit, because it gives us
# more consistency between the host tools and the target.
+# BUILD_HOST_64bit=1 overrides it for tool like emulator
+# which can benefit from 64-bit host arch.
+HOST_GLOBAL_CFLAGS += -m64
+HOST_GLOBAL_LDFLAGS += -m64
+else
HOST_GLOBAL_CFLAGS += -m32
HOST_GLOBAL_LDFLAGS += -m32
+endif # BUILD_HOST_64bit
mac_sdk_version := 10.6
mac_sdk_root := /Developer/SDKs/MacOSX$(mac_sdk_version).sdk
@@ -74,25 +80,46 @@ 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; \
+ for f in `$(HOST_AR) t $(1)`; do \
+ $(HOST_AR) p $(1) $$f > $$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) \
$(PRIVATE_LDLIBS) \
-o $@ \
+ -install_name @rpath/$(notdir $@) \
+ -Wl,-rpath,@loader_path/../lib \
$(PRIVATE_LDFLAGS) \
$(HOST_LIBGCC)
endef
define transform-host-o-to-executable-inner
$(hide) $(PRIVATE_CXX) \
+ -Wl,-rpath,@loader_path/../lib \
-o $@ \
$(PRE_LION_DYNAMIC_LINKER_OPTIONS) -headerpad_max_install_names \
$(HOST_GLOBAL_LD_DIRS) \