diff options
Diffstat (limited to 'core/combo')
-rw-r--r-- | core/combo/HOST_darwin-x86.mk | 33 | ||||
-rw-r--r-- | core/combo/HOST_linux-x86.mk | 12 | ||||
-rw-r--r-- | core/combo/HOST_windows-x86.mk | 12 | ||||
-rw-r--r-- | core/combo/TARGET_linux-arm.mk | 12 | ||||
-rw-r--r-- | core/combo/TARGET_linux-sh.mk | 4 | ||||
-rw-r--r-- | core/combo/TARGET_linux-x86.mk | 96 | ||||
-rw-r--r-- | core/combo/arch/arm/armv7-a-neon.mk | 1 | ||||
-rw-r--r-- | core/combo/arch/arm/armv7-a.mk | 1 | ||||
-rw-r--r-- | core/combo/arch/x86/x86-atom.mk | 18 | ||||
-rw-r--r-- | core/combo/arch/x86/x86.mk | 35 | ||||
-rw-r--r-- | core/combo/select.mk | 2 |
11 files changed, 178 insertions, 48 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) \ diff --git a/core/combo/HOST_linux-x86.mk b/core/combo/HOST_linux-x86.mk index 1014f4b..a4da5ce 100644 --- a/core/combo/HOST_linux-x86.mk +++ b/core/combo/HOST_linux-x86.mk @@ -32,7 +32,6 @@ endef # which is loaded by the 64-bit JVM through JNI), will have to use # LOCAL_CC and LOCAL_CXX to override this. # -ifeq ($(TARGET_PRODUCT),sdk) HOST_SDK_TOOLCHAIN_PREFIX := prebuilts/tools/gcc-sdk # Don't do anything if the toolchain is not there ifneq (,$(strip $(wildcard $(HOST_SDK_TOOLCHAIN_PREFIX)/gcc))) @@ -40,13 +39,18 @@ HOST_CC := $(HOST_SDK_TOOLCHAIN_PREFIX)/gcc HOST_CXX := $(HOST_SDK_TOOLCHAIN_PREFIX)/g++ HOST_AR := $(HOST_SDK_TOOLCHAIN_PREFIX)/ar endif # $(HOST_SDK_TOOLCHAIN_PREFIX)/gcc exists -endif # TARGET_PRODUCT == sdk -# 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 HOST_GLOBAL_CFLAGS += -fPIC HOST_GLOBAL_CFLAGS += \ diff --git a/core/combo/HOST_windows-x86.mk b/core/combo/HOST_windows-x86.mk index 9870998..fe4bd66 100644 --- a/core/combo/HOST_windows-x86.mk +++ b/core/combo/HOST_windows-x86.mk @@ -26,13 +26,19 @@ TOOLS_EXE_SUFFIX := .exe ifneq ($(findstring Linux,$(UNAME)),) ifneq ($(strip $(USE_MINGW)),) HOST_ACP_UNAVAILABLE := true -TOOLS_PREFIX := /usr/bin/i586-mingw32msvc- TOOLS_EXE_SUFFIX := HOST_GLOBAL_CFLAGS += -DUSE_MINGW +ifneq ($(strip $(BUILD_HOST_64bit)),) +TOOLS_PREFIX := /usr/bin/amd64-mingw32msvc- +HOST_C_INCLUDES += /usr/lib/gcc/amd64-mingw32msvc/4.4.2/include +HOST_GLOBAL_LD_DIRS += -L/usr/amd64-mingw32msvc/lib +else +TOOLS_PREFIX := /usr/bin/i586-mingw32msvc- HOST_C_INCLUDES += /usr/lib/gcc/i586-mingw32msvc/3.4.4/include HOST_GLOBAL_LD_DIRS += -L/usr/i586-mingw32msvc/lib -endif -endif +endif # BUILD_HOST_64bit +endif # USE_MINGW +endif # Linux HOST_CC := $(TOOLS_PREFIX)gcc$(TOOLS_EXE_SUFFIX) HOST_CXX := $(TOOLS_PREFIX)g++$(TOOLS_EXE_SUFFIX) diff --git a/core/combo/TARGET_linux-arm.mk b/core/combo/TARGET_linux-arm.mk index 4971a0c..14c3d28 100644 --- a/core/combo/TARGET_linux-arm.mk +++ b/core/combo/TARGET_linux-arm.mk @@ -43,8 +43,8 @@ include $(TARGET_ARCH_SPECIFIC_MAKEFILE) # You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else ifeq ($(strip $(TARGET_TOOLS_PREFIX)),) -TARGET_TOOLS_PREFIX := \ - prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-linux-androideabi-4.6/bin/arm-linux-androideabi- +TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-linux-androideabi-4.6 +TARGET_TOOLS_PREFIX := $(TARGET_TOOLCHAIN_ROOT)/bin/arm-linux-androideabi- endif # Only define these if there's actually a gcc in there. @@ -102,7 +102,7 @@ android_config_h := $(call select-android-config-h,linux-arm) arch_include_dir := $(dir $(android_config_h)) TARGET_GLOBAL_CFLAGS += \ - -msoft-float -fpic \ + -msoft-float -fpic -fPIE \ -ffunction-sections \ -fdata-sections \ -funwind-tables \ @@ -135,6 +135,8 @@ TARGET_GLOBAL_CFLAGS += -Wno-psabi TARGET_GLOBAL_LDFLAGS += \ -Wl,-z,noexecstack \ + -Wl,-z,relro \ + -Wl,-z,now \ -Wl,--icf=safe \ $(arch_variant_ldflags) @@ -246,7 +248,7 @@ endif define transform-o-to-shared-lib-inner $(hide) $(PRIVATE_CXX) \ - -nostdlib -Wl,-soname,$(notdir $@) -Wl,-T,$(BUILD_SYSTEM)/armelf.xsc \ + -nostdlib -Wl,-soname,$(notdir $@) \ -Wl,--gc-sections \ -Wl,-shared,-Bsymbolic \ $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \ @@ -268,7 +270,7 @@ $(hide) $(PRIVATE_CXX) \ endef define transform-o-to-executable-inner -$(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \ +$(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -fPIE -pie \ -Wl,-dynamic-linker,/system/bin/linker \ -Wl,--gc-sections \ -Wl,-z,nocopyreloc \ diff --git a/core/combo/TARGET_linux-sh.mk b/core/combo/TARGET_linux-sh.mk index fe4c4f3..9ecd649 100644 --- a/core/combo/TARGET_linux-sh.mk +++ b/core/combo/TARGET_linux-sh.mk @@ -19,8 +19,8 @@ # You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else ifeq ($(strip $(TARGET_TOOLS_PREFIX)),) -TARGET_TOOLS_PREFIX := \ - prebuilt/$(HOST_PREBUILT_TAG)/toolchain/sh-4.3.3/bin/sh-linux-gnu- +TARGET_TOOLCHAIN_ROOT := prebuilt/$(HOST_PREBUILT_TAG)/toolchain/sh-4.3.3 +TARGET_TOOLS_PREFIX := $(TARGET_TOOLCHAIN_ROOT)/bin/sh-linux-gnu- endif TARGET_CC := $(TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX) diff --git a/core/combo/TARGET_linux-x86.mk b/core/combo/TARGET_linux-x86.mk index 5020c84..0863e63 100644 --- a/core/combo/TARGET_linux-x86.mk +++ b/core/combo/TARGET_linux-x86.mk @@ -22,10 +22,22 @@ ifeq ($(strip $(TARGET_ARCH_VARIANT)),) TARGET_ARCH_VARIANT := x86 endif +# Include the arch-variant-specific configuration file. +# Its role is to define various ARCH_X86_HAVE_XXX feature macros, +# plus initial values for TARGET_GLOBAL_CFLAGS +# +TARGET_ARCH_SPECIFIC_MAKEFILE := $(BUILD_COMBOS)/arch/$(TARGET_ARCH)/$(TARGET_ARCH_VARIANT).mk +ifeq ($(strip $(wildcard $(TARGET_ARCH_SPECIFIC_MAKEFILE))),) +$(error Unknown $(TARGET_ARCH) architecture version: $(TARGET_ARCH_VARIANT)) +endif + +include $(TARGET_ARCH_SPECIFIC_MAKEFILE) + + # You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else ifeq ($(strip $(TARGET_TOOLS_PREFIX)),) -TARGET_TOOLS_PREFIX := \ - prebuilts/gcc/$(HOST_PREBUILT_TAG)/x86/i686-linux-android-4.6/bin/i686-linux-android- +TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/x86/i686-linux-android-4.6 +TARGET_TOOLS_PREFIX := $(TARGET_TOOLCHAIN_ROOT)/bin/i686-linux-android- endif TARGET_CC := $(TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX) @@ -73,7 +85,7 @@ TARGET_GLOBAL_CFLAGS += \ -Wa,--noexecstack \ -Werror=format-security \ -Wstrict-aliasing=2 \ - -fPIC \ + -fPIC -fPIE \ -ffunction-sections \ -finline-functions \ -finline-limit=300 \ @@ -84,45 +96,50 @@ TARGET_GLOBAL_CFLAGS += \ -funwind-tables \ -include $(call select-android-config-h,target_linux-x86) -# Needs to be fixed later -#TARGET_GLOBAL_CFLAGS += \ -# -fstack-protector - -# Needs to be added for RELEASE -#TARGET_GLOBAL_CFLAGS += \ -# -DNDEBUG - +# XXX: Not sure this is still needed. Must check with our toolchains. TARGET_GLOBAL_CPPFLAGS += \ -fno-use-cxa-atexit -ifeq ($(TARGET_ARCH_VARIANT),x86-atom) - # Basic ATOM flags. - TARGET_GLOBAL_CFLAGS += -march=atom -mstackrealign -mfpmath=sse +# XXX: Our toolchain is normally configured to always set these flags by default +# however, there have been reports that this is sometimes not the case. So make +# them explicit here unless we have the time to carefully check it +# +TARGET_GLOBAL_CFLAGS += -mstackrealign -msse3 -mfpmath=sse - # There are various levels of ATOM processors out there. Different ones have different - # capabilities. This first define matches the NDK's minimum ABI requirements. - # Note: Not all of the flags set here are actually used in Android. They are provided - # to allow for the addition of corresponding optimizations. - TARGET_GLOBAL_CFLAGS += -DUSE_MMX -DUSE_SSE -DUSE_SSE2 -DUSE_SSE3 +# XXX: These flags should not be defined here anymore. Instead, the Android.mk +# of the modules that depend on these features should instead check the +# corresponding macros (e.g. ARCH_X86_HAVE_SSE2 and ARCH_X86_HAVE_SSSE3) +# Keep them here until this is all cleared up. +# +ifeq ($(ARCH_X86_HAVE_SSE2),true) +TARGET_GLOBAL_CFLAGS += -DUSE_SSE2 +endif - # If you wish to build a BSP that will only be used on hardware that has additional - # available instructions, enable them here. By default, this is commented off so that - # the default images can run on all processors that are NDK ABI compliant. - # TARGET_GLOBAL_CFLAGS += -DUSE_SSSE3 -else - # Plain 'x86' - lowest common denominator. This should run pretty much on any hardware. - # - # Note: The NDK's ABI (see the NDK ABI documentation) requires many of the more recent - # instruction set additions. You can build an "x86" BSP that will run on very old hardware, - # but it won't be able to run much of the x86 NDK compliant code. - TARGET_GLOBAL_CFLAGS += -march=i686 +ifeq ($(ARCH_X86_HAVE_SSSE3),true) # yes, really SSSE3, not SSE3! +TARGET_GLOBAL_CFLAGS += -DUSE_SSSE3 endif +# XXX: This flag is probably redundant. I believe our toolchain always sets +# it by default. Consider for removal. +# TARGET_GLOBAL_CFLAGS += -mbionic + +# XXX: This flag is probably redundant. The macro should be defined by our +# toolchain binaries automatically (as a compiler built-in). +# Check with: $BINPREFIX-gcc -dM -E < /dev/null +# +# Consider for removal. +# TARGET_GLOBAL_CFLAGS += -D__ANDROID__ +# XXX: This flag is probably redundant since our toolchain binaries already +# generate 32-bit machine code. It probably dates back to the old days +# where we were using the host toolchain on Linux to build the platform +# images. Consider it for removal. TARGET_GLOBAL_LDFLAGS += -m32 + TARGET_GLOBAL_LDFLAGS += -Wl,-z,noexecstack +TARGET_GLOBAL_LDFLAGS += -Wl,-z,relro -Wl,-z,now TARGET_GLOBAL_LDFLAGS += -Wl,--gc-sections TARGET_C_INCLUDES := \ @@ -175,6 +192,7 @@ $(hide) $(PRIVATE_CXX) \ -nostdlib -Bdynamic \ -Wl,-dynamic-linker,/system/bin/linker \ -Wl,-z,nocopyreloc \ + -fPIE -pie \ -o $@ \ $(TARGET_GLOBAL_LD_DIRS) \ -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \ @@ -210,3 +228,21 @@ $(hide) $(PRIVATE_CXX) \ -Wl,--end-group \ $(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTEND_O)) endef + +# Special check for x86 NDK ABI compatibility. +# The TARGET_CPU_ABI variable should be defined in BoardConfig.mk to 'x86' +# *only* if the platform image is compatible with the NDK x86 ABI. +# +# We perform a small check here to ensure that nothing bad can happen. +# +ifeq ($(TARGET_CPU_ABI),x86) + ifneq (true-true-true-true,$(ARCH_X86_HAVE_MMX)-$(ARCH_X86_HAVE_SSE)-$(ARCH_X86_HAVE_SSE2)-$(ARCH_X86_HAVE_SSE3)) + $(info ERROR: Your x86 platform image is not compatible with the NDK x86 ABI) + $(info As such, you should *not* define TARGET_CPU_ABI to 'x86' in your BoardConfig.mk) + $(info to ensure that your device will not be mistakenly listed as compatible by + $(info the Android Market. Also, it is likely that the image will fail the CTS tests) + $(info Please undefine TARGET_CPU_ABI in your BoardConfig.mk, or select the value 'none') + $(info The corresponding image will still be able to run Dalvik-based Android applications) + $(error Aborting build! Please fix your BoardConfig.mk) + endif +endif diff --git a/core/combo/arch/arm/armv7-a-neon.mk b/core/combo/arch/arm/armv7-a-neon.mk index 7b5b8ed..32273ff 100644 --- a/core/combo/arch/arm/armv7-a-neon.mk +++ b/core/combo/arch/arm/armv7-a-neon.mk @@ -8,6 +8,7 @@ ARCH_ARM_HAVE_HALFWORD_MULTIPLY := true ARCH_ARM_HAVE_CLZ := true ARCH_ARM_HAVE_FFS := true ARCH_ARM_HAVE_ARMV7A := true +ARCH_ARM_HAVE_TLS_REGISTER := true ARCH_ARM_HAVE_VFP := true ARCH_ARM_HAVE_VFP_D32 := true ARCH_ARM_HAVE_NEON := true diff --git a/core/combo/arch/arm/armv7-a.mk b/core/combo/arch/arm/armv7-a.mk index 0ca3ec6..220f7ec 100644 --- a/core/combo/arch/arm/armv7-a.mk +++ b/core/combo/arch/arm/armv7-a.mk @@ -8,6 +8,7 @@ ARCH_ARM_HAVE_HALFWORD_MULTIPLY := true ARCH_ARM_HAVE_CLZ := true ARCH_ARM_HAVE_FFS := true ARCH_ARM_HAVE_ARMV7A := true +ARCH_ARM_HAVE_TLS_REGISTER := true ARCH_ARM_HAVE_VFP := true # Note: Hard coding the 'tune' value here is probably not ideal, diff --git a/core/combo/arch/x86/x86-atom.mk b/core/combo/arch/x86/x86-atom.mk new file mode 100644 index 0000000..85998e7 --- /dev/null +++ b/core/combo/arch/x86/x86-atom.mk @@ -0,0 +1,18 @@ +# This file contains feature macro definitions specific to the +# 'x86-atom' arch variant. This is an extension of the 'x86' base variant +# that adds Atom-specific features. +# +# See build/core/combo/arch/x86/x86.mk for differences. +# +ARCH_X86_HAVE_MMX := true +ARCH_X86_HAVE_SSE := true +ARCH_X86_HAVE_SSE2 := true +ARCH_X86_HAVE_SSE3 := true + +ARCH_X86_HAVE_SSSE3 := true +ARCH_X86_HAVE_MOVBE := true +ARCH_X86_HAVE_POPCNT := false # popcnt is not supported by current Atom CPUs + +# This flag is used to enabled Atom-specific optimizations with our toolchain +# +TARGET_GLOBAL_CFLAGS += -march=atom diff --git a/core/combo/arch/x86/x86.mk b/core/combo/arch/x86/x86.mk new file mode 100644 index 0000000..476da45 --- /dev/null +++ b/core/combo/arch/x86/x86.mk @@ -0,0 +1,35 @@ +# This file contains feature macro definitions specific to the +# base 'x86' platform ABI. This one must *strictly* match the NDK x86 ABI +# which mandates specific CPU extensions to be available. +# +# It is also used to build full_x86-eng / sdk_x86-eng platform images that +# are run in the emulator under KVM emulation (i.e. running directly on +# the host development machine's CPU). +# + +# If your target device doesn't support the four following features, then +# it cannot be compatible with the NDK x86 ABI. You should define a new +# target arch variant (e.g. "x86-mydevice") and a corresponding file +# under build/core/combo/arch/x86/ +# +ARCH_X86_HAVE_MMX := true +ARCH_X86_HAVE_SSE := true +ARCH_X86_HAVE_SSE2 := true +ARCH_X86_HAVE_SSE3 := true + +# These features are optional and shall not be included in the base platform +# Otherwise, they sdk_x86-eng system images might fail to run on some +# developer machines. +# + +ARCH_X86_HAVE_SSSE3 := false +ARCH_X86_HAVE_MOVBE := false +ARCH_X86_HAVE_POPCNT := false + + +# XXX: This flag is probably redundant, because it should be set by default +# by our toolchain binaries. However, there have been reports that this may +# not always work as intended, so keep it unless we have the time to check +# everything properly. + +TARGET_GLOBAL_CFLAGS += -march=i686 diff --git a/core/combo/select.mk b/core/combo/select.mk index cdeb68a..803cfc0 100644 --- a/core/combo/select.mk +++ b/core/combo/select.mk @@ -66,7 +66,7 @@ ifneq ($(USE_CCACHE),) ifeq ($(HOST_OS)-$(BUILD_OS),windows-linux) CCACHE_HOST_TAG := linux-$(BUILD_ARCH) endif - ccache := prebuilt/$(CCACHE_HOST_TAG)/ccache/ccache + ccache := prebuilts/misc/$(CCACHE_HOST_TAG)/ccache/ccache # Check that the executable is here. ccache := $(strip $(wildcard $(ccache))) ifdef ccache |