From 964935b8a6ef52f090eb6f48875db5ebb32962cf Mon Sep 17 00:00:00 2001 From: Igor Murashkin Date: Thu, 30 Oct 2014 16:08:07 -0700 Subject: [PATCH] core: Use WITH_DEXPREOPT_PIC=true to have dex2oat build pic oat files When WITH_DEXPREOPT=true is set, if we also set WITH_DEXPREOPT_PIC=true then the build will generate position-independent OAT images. This means that all the system applications no longer need to be relocated into /data/dalvik-cache and this can achieve saving disk space at the cost of slightly slower running code. Bug: 18035729 (cherry picked from commit da9f1a7e82b7e6d0677553f211835625078347f2) Change-Id: I9d5f12bbe7d0287784ac7e941fba090fce3ce3df --- core/dex_preopt_libart_boot.mk | 5 +++++ core/dex_preopt_odex_install.mk | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/core/dex_preopt_libart_boot.mk b/core/dex_preopt_libart_boot.mk index 620b46435..0714c7330 100644 --- a/core/dex_preopt_libart_boot.mk +++ b/core/dex_preopt_libart_boot.mk @@ -32,6 +32,11 @@ ifneq ($(PRODUCT_DEX_PREOPT_IMAGE_IN_DATA),true) $(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE := $(PRODUCT_OUT)$($(my_2nd_arch_prefix)LIBART_BOOT_IMAGE_FILENAME) endif +# Compile boot.oat as position-independent code if WITH_DEXPREOPT_PIC=true +ifeq (true,$(WITH_DEXPREOPT_PIC)) + PRODUCT_DEX_PREOPT_BOOT_FLAGS += --compile-pic +endif + # The rule to install boot.art and boot.oat $($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE) : $($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME) | $(ACP) $(call copy-file-to-target) diff --git a/core/dex_preopt_odex_install.mk b/core/dex_preopt_odex_install.mk index 90ae08fd0..cb38261ab 100644 --- a/core/dex_preopt_odex_install.mk +++ b/core/dex_preopt_odex_install.mk @@ -105,6 +105,12 @@ ifndef LOCAL_DEX_PREOPT_FLAGS LOCAL_DEX_PREOPT_FLAGS := $(PRODUCT_DEX_PREOPT_DEFAULT_FLAGS) endif endif + +# Compile apps with position-independent code if WITH_DEXPREOPT_PIC=true +ifeq (true,$(WITH_DEXPREOPT_PIC)) + LOCAL_DEX_PREOPT_FLAGS += --compile-pic +endif + $(built_odex): PRIVATE_DEX_PREOPT_FLAGS := $(LOCAL_DEX_PREOPT_FLAGS) # Use pattern rule - we may have multiple installed odex files. -- 2.11.0