From 4570fdbb4c9c9fb0730b85a9a38cf5725bf070b0 Mon Sep 17 00:00:00 2001 From: bowen_lai Date: Wed, 16 Aug 2017 16:28:05 +0800 Subject: [PATCH] Create symbolic boot vdex files for different ISAs Create only one vdex file and share between different ISAs. By sharing vdex file, zygote32 and zygote64 can share the same file and the system partition size is reduced by about 32MB. Test: make framework & check boot.vdex and boot-*.vdex files Test: test system boots with no selinux violations Bug: 64211239 Change-Id: I31ede4b6aa342f2047d9309b8c631217e6699202 --- core/dex_preopt_libart.mk | 24 +++++++++++++++++++++--- core/dex_preopt_libart_boot.mk | 4 +++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/core/dex_preopt_libart.mk b/core/dex_preopt_libart.mk index 0fa4b8cc0..f289c2233 100644 --- a/core/dex_preopt_libart.mk +++ b/core/dex_preopt_libart.mk @@ -90,8 +90,10 @@ LIBART_TARGET_BOOT_DEX_FILES := $(foreach jar,$(LIBART_TARGET_BOOT_JARS),$(call # is converted into to boot.art (to match the legacy assumption that boot.art # exists), and the rest are converted to boot-.art. # In addition, each .art file has an associated .oat file. -LIBART_TARGET_BOOT_ART_EXTRA_FILES := $(foreach jar,$(wordlist 2,999,$(LIBART_TARGET_BOOT_JARS)),boot-$(jar).art boot-$(jar).art.rel boot-$(jar).oat boot-$(jar).vdex) -LIBART_TARGET_BOOT_ART_EXTRA_FILES += boot.art.rel boot.oat boot.vdex +LIBART_TARGET_BOOT_ART_EXTRA_FILES := $(foreach jar,$(wordlist 2,999,$(LIBART_TARGET_BOOT_JARS)),boot-$(jar).art boot-$(jar).art.rel boot-$(jar).oat) +LIBART_TARGET_BOOT_ART_EXTRA_FILES += boot.art.rel boot.oat +LIBART_TARGET_BOOT_ART_VDEX_FILES := $(foreach jar,$(wordlist 2,999,$(LIBART_TARGET_BOOT_JARS)),boot-$(jar).vdex) +LIBART_TARGET_BOOT_ART_VDEX_FILES += boot.vdex # If we use a boot image profile. my_use_profile_for_boot_image := $(PRODUCT_USE_PROFILE_FOR_BOOT_IMAGE) @@ -133,6 +135,8 @@ ALL_DEFAULT_INSTALLED_MODULES += $(my_installed_profile) endif +LIBART_TARGET_BOOT_ART_VDEX_INSTALLED_SHARED_FILES := $(addprefix $(PRODUCT_OUT)/$(DEXPREOPT_BOOT_JAR_DIR)/,$(LIBART_TARGET_BOOT_ART_VDEX_FILES)) + my_2nd_arch_prefix := include $(BUILD_SYSTEM)/dex_preopt_libart_boot.mk @@ -140,10 +144,24 @@ ifneq ($(TARGET_TRANSLATE_2ND_ARCH),true) ifdef TARGET_2ND_ARCH my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX) include $(BUILD_SYSTEM)/dex_preopt_libart_boot.mk -my_2nd_arch_prefix := endif endif +# Copy shared vdex to the directory and create corresponding symlinks in primary and secondary arch. +$(LIBART_TARGET_BOOT_ART_VDEX_INSTALLED_SHARED_FILES) : PRIMARY_ARCH_DIR := $(dir $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE)) +$(LIBART_TARGET_BOOT_ART_VDEX_INSTALLED_SHARED_FILES) : SECOND_ARCH_DIR := $(dir $($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE)) +$(LIBART_TARGET_BOOT_ART_VDEX_INSTALLED_SHARED_FILES) : $(DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME) + @echo "Install: $@" + @mkdir -p $(dir $@) + @rm -f $@ + $(hide) cp "$(dir $<)$(notdir $@)" "$@" + # Make symlink for both the archs. In the case its single arch the symlink will just get overridden. + @mkdir -p $(PRIMARY_ARCH_DIR) + $(hide) ln -sf /$(DEXPREOPT_BOOT_JAR_DIR)/$(notdir $@) $(PRIMARY_ARCH_DIR)$(notdir $@) + @mkdir -p $(SECOND_ARCH_DIR) + $(hide) ln -sf /$(DEXPREOPT_BOOT_JAR_DIR)/$(notdir $@) $(SECOND_ARCH_DIR)$(notdir $@) + +my_2nd_arch_prefix := ######################################################################## # For a single jar or APK diff --git a/core/dex_preopt_libart_boot.mk b/core/dex_preopt_libart_boot.mk index ad8f18d66..8db942818 100644 --- a/core/dex_preopt_libart_boot.mk +++ b/core/dex_preopt_libart_boot.mk @@ -30,6 +30,8 @@ $(my_2nd_arch_prefix)LIBART_TARGET_BOOT_OAT_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPE $(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE := $(PRODUCT_OUT)$($(my_2nd_arch_prefix)LIBART_BOOT_IMAGE_FILENAME) $(my_2nd_arch_prefix)LIBART_TARGET_BOOT_ART_EXTRA_INSTALLED_FILES := $(addprefix $(dir $($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE)),\ $(LIBART_TARGET_BOOT_ART_EXTRA_FILES)) +$(my_2nd_arch_prefix)LIBART_TARGET_BOOT_ART_VDEX_INSTALLED_FILES := $(addprefix $(dir $($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE)),\ + $(LIBART_TARGET_BOOT_ART_VDEX_FILES)) # If we have a compiled-classes file, create a parameter. COMPILED_CLASSES_FLAGS := @@ -45,7 +47,7 @@ endif # The rule to install boot.art # Depends on installed boot.oat, boot-*.art, boot-*.oat -$($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE) : $($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME) | $(ACP) $($(my_2nd_arch_prefix)LIBART_TARGET_BOOT_ART_EXTRA_INSTALLED_FILES) +$($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE) : $($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME) | $(ACP) $($(my_2nd_arch_prefix)LIBART_TARGET_BOOT_ART_EXTRA_INSTALLED_FILES) $($(my_2nd_arch_prefix)LIBART_TARGET_BOOT_ART_VDEX_INSTALLED_SHARED_FILES) @echo "Install: $@" $(copy-file-to-target)