Merge "gtest needs -lpthread."
diff --git a/core/binary.mk b/core/binary.mk
index 3556b99..adc2f44 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -97,6 +97,7 @@
 my_c_includes := $(LOCAL_C_INCLUDES) $(LOCAL_C_INCLUDES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
 my_generated_sources := $(LOCAL_GENERATED_SOURCES)
 
+my_cflags := $(filter-out $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_UNSUPPORTED_CFLAGS),$(my_cflags))
 
 # The real dependency will be added after all Android.mks are loaded and the install paths
 # of the shared libraries are determined.
diff --git a/core/combo/TARGET_linux-arm64.mk b/core/combo/TARGET_linux-arm64.mk
index a175eab..76ee567 100644
--- a/core/combo/TARGET_linux-arm64.mk
+++ b/core/combo/TARGET_linux-arm64.mk
@@ -91,6 +91,9 @@
 			-include $(android_config_h) \
 			-I $(dir $(android_config_h))
 
+# HACK: globally disable -fstack-protector until the toolchain supports it
+TARGET_GLOBAL_UNSUPPORTED_CFLAGS := -fstack-protector
+
 # TODO - remove __ANDROID__ after the next aarch64 toolchain refresh
 TARGET_GLOBAL_CFLAGS += -D__ANDROID__=1
 
diff --git a/core/combo/TARGET_linux-mips.mk b/core/combo/TARGET_linux-mips.mk
index 055a886..637c8f6 100644
--- a/core/combo/TARGET_linux-mips.mk
+++ b/core/combo/TARGET_linux-mips.mk
@@ -187,7 +187,7 @@
 
 
 KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi
-KERNEL_HEADERS_ARCH   := $(libc_root)/kernel/uapi/asm-$(TARGET_ARCH)
+KERNEL_HEADERS_ARCH   := $(libc_root)/kernel/uapi/asm-mips # mips covers both mips and mips64.
 KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
 
 TARGET_C_INCLUDES := \
diff --git a/core/combo/TARGET_linux-x86.mk b/core/combo/TARGET_linux-x86.mk
index 1ed5417..801f882 100755
--- a/core/combo/TARGET_linux-x86.mk
+++ b/core/combo/TARGET_linux-x86.mk
@@ -102,7 +102,7 @@
 endif
 
 KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi
-KERNEL_HEADERS_ARCH   := $(libc_root)/kernel/uapi/asm-$(TARGET_ARCH)
+KERNEL_HEADERS_ARCH   := $(libc_root)/kernel/uapi/asm-x86 # x86 covers both x86 and x86_64.
 KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
 
 android_config_h := $(call select-android-config-h,target_linux-x86)
diff --git a/core/dex_preopt_libart.mk b/core/dex_preopt_libart.mk
index 1e7b193..fa2b7e3 100644
--- a/core/dex_preopt_libart.mk
+++ b/core/dex_preopt_libart.mk
@@ -26,12 +26,16 @@
 LIBART_BOOT_IMAGE := /$(DEXPREOPT_BOOT_JAR_DIR)/boot.art
 
 DEFAULT_DEX_PREOPT_BUILT_IMAGE := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/boot.art
+
+DEFAULT_DEX_PREOPT_INSTALLED_IMAGE :=
+ifneq ($(PRODUCT_DEX_PREOPT_IMAGE_IN_DATA),true)
 DEFAULT_DEX_PREOPT_INSTALLED_IMAGE := $(PRODUCT_OUT)$(LIBART_BOOT_IMAGE)
 
 # The rule to install boot.art and boot.oat
 $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE) : $(DEFAULT_DEX_PREOPT_BUILT_IMAGE) | $(ACP)
 	$(call copy-file-to-target)
 	$(hide) $(ACP) -fp $(patsubst %.art,%.oat,$<) $(patsubst %.art,%.oat,$@)
+endif
 
 DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := default
 ifeq ($(TARGET_CPU_VARIANT),$(filter $(TARGET_CPU_VARIANT),cortex-a15 krait))
diff --git a/core/product.mk b/core/product.mk
index a2f4abc..cf6fb9a 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -97,8 +97,8 @@
     PRODUCT_FACTORY_RAMDISK_MODULES \
     PRODUCT_FACTORY_BUNDLE_MODULES \
     PRODUCT_RUNTIMES \
-    PRODUCT_BOOT_JARS
-
+    PRODUCT_BOOT_JARS \
+    PRODUCT_DEX_PREOPT_IMAGE_IN_DATA \
 
 define dump-product
 $(info ==== $(1) ====)\
@@ -255,7 +255,7 @@
 	DEFAULT_SYSTEM_DEV_CERTIFICATE
 
 #
-# Stash vaues of the variables in _product_stash_var_list.
+# Stash values of the variables in _product_stash_var_list.
 # $(1): Renamed prefix
 #
 define stash-product-vars
diff --git a/core/product_config.mk b/core/product_config.mk
index 0574c66..7a27426 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -402,3 +402,7 @@
 
 PRODUCT_EXTRA_RECOVERY_KEYS := $(sort \
     $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_EXTRA_RECOVERY_KEYS))
+
+# If there is no room in /system for the image, place it in /data
+PRODUCT_DEX_PREOPT_IMAGE_IN_DATA := \
+    $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEX_PREOPT_IMAGE_IN_DATA))
diff --git a/target/product/core_minimal.mk b/target/product/core_minimal.mk
index 21a6e8b..79ba0d4 100644
--- a/target/product/core_minimal.mk
+++ b/target/product/core_minimal.mk
@@ -72,7 +72,7 @@
     apache-xml \
     webviewchromium
 
-PRODUCT_RUNTIMES := runtime_libdvm_default
-PRODUCT_RUNTIMES += runtime_libart
+PRODUCT_RUNTIMES := runtime_libart_default
+PRODUCT_RUNTIMES += runtime_libdvm
 
 $(call inherit-product, $(SRC_TARGET_DIR)/product/base.mk)