From 2ca0e49f61ed4f575a51c5573b422b37f3884eac Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Fri, 18 Oct 2019 14:47:19 +0100 Subject: [PATCH] Remove support for stripping dex. Stripping is incompatible with ART module updatability. Bug: 65154345 Bug: 138851227 Test: build and observe no change in output (stripping is not used by default). Change-Id: Ic2d9738ef393814c3af3cad116071f7b5938aa84 --- core/Makefile | 4 ++-- core/app_prebuilt_internal.mk | 23 ----------------------- core/clear_vars.mk | 2 +- core/dex_preopt_config.mk | 11 ----------- core/dex_preopt_odex_install.mk | 13 +++---------- core/java_library.mk | 11 ----------- core/java_prebuilt_internal.mk | 11 ----------- core/package_internal.mk | 19 +------------------ core/soong_app_prebuilt.mk | 4 ---- 9 files changed, 7 insertions(+), 91 deletions(-) diff --git a/core/Makefile b/core/Makefile index 368624f99..5c214d920 100644 --- a/core/Makefile +++ b/core/Makefile @@ -2557,7 +2557,7 @@ pdk_odex_apps := $(strip $(foreach m,$(DEXPREOPT.MODULES.APPS),\ $(if $(filter $(DEXPREOPT.$(m).INSTALLED_STRIPPED),$(ALL_DEFAULT_INSTALLED_MODULES)),$(m)))) pdk_classes_dex := $(strip \ $(foreach m,$(pdk_odex_javalibs),$(call intermediates-dir-for,JAVA_LIBRARIES,$(m),,COMMON)/javalib.jar) \ - $(foreach m,$(pdk_odex_apps),$(call intermediates-dir-for,APPS,$(m))/package.dex.apk)) + $(foreach m,$(pdk_odex_apps),$(call intermediates-dir-for,APPS,$(m))/package.apk)) pdk_odex_config_mk := $(PRODUCT_OUT)/pdk_dexpreopt_config.mk $(pdk_odex_config_mk): PRIVATE_JAVA_LIBRARIES := $(pdk_odex_javalibs) @@ -2575,7 +2575,7 @@ $(pdk_odex_config_mk) : $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\ ) $(foreach m,$(PRIVATE_APPS),\ - $(hide) echo "PDK.DEXPREOPT.$(m).SRC:=$(patsubst $(OUT_DIR)/%,%,$(call intermediates-dir-for,APPS,$(m))/package.dex.apk)" >> $@$(newline)\ + $(hide) echo "PDK.DEXPREOPT.$(m).SRC:=$(patsubst $(OUT_DIR)/%,%,$(call intermediates-dir-for,APPS,$(m))/package.apk)" >> $@$(newline)\ $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT:=$(DEXPREOPT.$(m).DEX_PREOPT)" >> $@$(newline)\ $(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\ $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\ diff --git a/core/app_prebuilt_internal.mk b/core/app_prebuilt_internal.mk index 399d173bf..ce554c9ad 100644 --- a/core/app_prebuilt_internal.mk +++ b/core/app_prebuilt_internal.mk @@ -215,17 +215,6 @@ $(built_module) : $(appcompat-files) $(LOCAL_BUILT_MODULE): PRIVATE_INSTALLED_MODULE := $(LOCAL_INSTALLED_MODULE) endif -ifneq ($(BUILD_PLATFORM_ZIP),) -$(built_module) : .KATI_IMPLICIT_OUTPUTS := $(dir $(LOCAL_BUILT_MODULE))package.dex.apk -endif -ifneq ($(LOCAL_CERTIFICATE),PRESIGNED) -ifdef LOCAL_DEX_PREOPT -$(built_module) : PRIVATE_STRIP_SCRIPT := $(intermediates)/strip.sh -$(built_module) : $(intermediates)/strip.sh -$(built_module) : | $(DEXPREOPT_STRIP_DEPS) -$(built_module) : .KATI_DEPFILE := $(built_module).d -endif -endif ifeq ($(module_run_appcompat),true) $(built_module) : $(AAPT2) endif @@ -235,23 +224,11 @@ $(built_module) : $(my_prebuilt_src_file) | $(ZIPALIGN) $(ZIP2ZIP) $(SIGNAPK_JAR ifeq (true, $(LOCAL_UNCOMPRESS_DEX)) $(uncompress-dexs) endif # LOCAL_UNCOMPRESS_DEX -ifdef LOCAL_DEX_PREOPT -ifneq ($(BUILD_PLATFORM_ZIP),) - @# Keep a copy of apk with classes.dex unstripped - $(hide) cp -f $@ $(dir $@)package.dex.apk -endif # BUILD_PLATFORM_ZIP -endif # LOCAL_DEX_PREOPT ifneq ($(LOCAL_CERTIFICATE),PRESIGNED) - @# Only strip out files if we can re-sign the package. -# Run appcompat before stripping the classes.dex file. ifeq ($(module_run_appcompat),true) $(call appcompat-header, aapt2) $(run-appcompat) endif # module_run_appcompat -ifdef LOCAL_DEX_PREOPT - mv -f $@ $@.tmp - $(PRIVATE_STRIP_SCRIPT) $@.tmp $@ -endif # LOCAL_DEX_PREOPT $(sign-package) # No need for align-package because sign-package takes care of alignment else # LOCAL_CERTIFICATE == PRESIGNED diff --git a/core/clear_vars.mk b/core/clear_vars.mk index 24cca5aa4..e130257bb 100644 --- a/core/clear_vars.mk +++ b/core/clear_vars.mk @@ -56,7 +56,7 @@ LOCAL_DEX_PREOPT_APP_IMAGE:= LOCAL_DEX_PREOPT_FLAGS:= LOCAL_DEX_PREOPT_GENERATE_PROFILE:= LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING:= -LOCAL_DEX_PREOPT:= # '',true,false,nostripping +LOCAL_DEX_PREOPT:= # '',true,false LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG:= LOCAL_DISABLE_RESOLVE_SUPPORT_LIBRARIES:= LOCAL_DONT_CHECK_MODULE:= diff --git a/core/dex_preopt_config.mk b/core/dex_preopt_config.mk index 69eaea1d7..d03be8690 100644 --- a/core/dex_preopt_config.mk +++ b/core/dex_preopt_config.mk @@ -13,16 +13,9 @@ SYSTEM_OTHER_ODEX_FILTER ?= \ product/app/% \ product/priv-app/% \ -# The default values for pre-opting. To support the runtime module we ensure no dex files -# get stripped. -ifeq ($(PRODUCT_DEX_PREOPT_NEVER_ALLOW_STRIPPING),) - PRODUCT_DEX_PREOPT_NEVER_ALLOW_STRIPPING := true -endif # Conditional to building on linux, as dex2oat currently does not work on darwin. ifeq ($(HOST_OS),linux) ifeq (eng,$(TARGET_BUILD_VARIANT)) - # Don't strip for quick development turnarounds. - DEX_PREOPT_DEFAULT := nostripping # For an eng build only pre-opt the boot image and system server. This gives reasonable performance # and still allows a simple workflow: building in frameworks/base and syncing. WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY ?= true @@ -86,7 +79,6 @@ ifeq ($(WRITE_SOONG_VARIABLES),true) $(call json_start) - $(call add_json_bool, DefaultNoStripping, $(filter nostripping,$(DEX_PREOPT_DEFAULT))) $(call add_json_bool, DisablePreopt, $(call invert_bool,$(filter true,$(WITH_DEXPREOPT)))) $(call add_json_list, DisablePreoptModules, $(DEXPREOPT_DISABLED_MODULES)) $(call add_json_bool, OnlyPreoptBootImageAndSystemServer, $(filter true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY))) @@ -173,6 +165,3 @@ DEXPREOPT_GEN_DEPS := \ $(SOONG_ZIP) \ $(ZIP2ZIP) \ $(BUILD_SYSTEM)/construct_context.sh \ - -DEXPREOPT_STRIP_DEPS := \ - $(ZIP2ZIP) \ diff --git a/core/dex_preopt_odex_install.mk b/core/dex_preopt_odex_install.mk index 50e922e36..6705c8246 100644 --- a/core/dex_preopt_odex_install.mk +++ b/core/dex_preopt_odex_install.mk @@ -207,8 +207,7 @@ ifdef LOCAL_DEX_PREOPT $(call json_start) - # DexPath, StripInputPath, and StripOutputPath are not set, they will - # be filled in by dexpreopt_gen. + # DexPath is not set: it will be filled in by dexpreopt_gen. $(call add_json_str, Name, $(LOCAL_MODULE)) $(call add_json_str, DexLocation, $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))) @@ -237,13 +236,10 @@ ifdef LOCAL_DEX_PREOPT $(call add_json_bool, ForceCreateAppImage, $(filter true,$(LOCAL_DEX_PREOPT_APP_IMAGE))) $(call add_json_bool, PresignedPrebuilt, $(filter PRESIGNED,$(LOCAL_CERTIFICATE))) - $(call add_json_bool, NoStripping, $(filter nostripping,$(LOCAL_DEX_PREOPT))) - $(call json_end) my_dexpreopt_config := $(intermediates)/dexpreopt.config my_dexpreopt_script := $(intermediates)/dexpreopt.sh - my_strip_script := $(intermediates)/strip.sh my_dexpreopt_zip := $(intermediates)/dexpreopt.zip $(my_dexpreopt_config): PRIVATE_MODULE := $(LOCAL_MODULE) @@ -252,17 +248,15 @@ ifdef LOCAL_DEX_PREOPT @echo "$(PRIVATE_MODULE) dexpreopt.config" echo -e -n '$(subst $(newline),\n,$(subst ','\'',$(subst \,\\,$(PRIVATE_CONTENTS))))' > $@ - .KATI_RESTAT: $(my_dexpreopt_script) $(my_strip_script) + .KATI_RESTAT: $(my_dexpreopt_script) $(my_dexpreopt_script): PRIVATE_MODULE := $(LOCAL_MODULE) $(my_dexpreopt_script): PRIVATE_GLOBAL_CONFIG := $(DEX_PREOPT_CONFIG_FOR_MAKE) $(my_dexpreopt_script): PRIVATE_MODULE_CONFIG := $(my_dexpreopt_config) - $(my_dexpreopt_script): PRIVATE_STRIP_SCRIPT := $(my_strip_script) - $(my_dexpreopt_script): .KATI_IMPLICIT_OUTPUTS := $(my_strip_script) $(my_dexpreopt_script): $(DEXPREOPT_GEN) $(my_dexpreopt_script): $(my_dexpreopt_config) $(DEX_PREOPT_CONFIG_FOR_MAKE) @echo "$(PRIVATE_MODULE) dexpreopt gen" $(DEXPREOPT_GEN) -global $(PRIVATE_GLOBAL_CONFIG) -module $(PRIVATE_MODULE_CONFIG) \ - -dexpreopt_script $@ -strip_script $(PRIVATE_STRIP_SCRIPT) \ + -dexpreopt_script $@ \ -out_dir $(OUT_DIR) my_dexpreopt_deps := $(my_dex_jar) @@ -302,6 +296,5 @@ ifdef LOCAL_DEX_PREOPT my_dexpreopt_config := my_dexpreopt_script := - my_strip_script := my_dexpreopt_zip := endif # LOCAL_DEX_PREOPT diff --git a/core/java_library.mk b/core/java_library.mk index 4734eaf23..3ac03dc08 100644 --- a/core/java_library.mk +++ b/core/java_library.mk @@ -85,17 +85,6 @@ endif # LOCAL_UNCOMPRESS_DEX .KATI_RESTAT: $(common_javalib.jar) -ifdef LOCAL_DEX_PREOPT - -$(LOCAL_BUILT_MODULE): PRIVATE_STRIP_SCRIPT := $(intermediates)/strip.sh -$(LOCAL_BUILT_MODULE): $(intermediates)/strip.sh -$(LOCAL_BUILT_MODULE): | $(DEXPREOPT_STRIP_DEPS) -$(LOCAL_BUILT_MODULE): .KATI_DEPFILE := $(LOCAL_BUILT_MODULE).d -$(LOCAL_BUILT_MODULE): $(common_javalib.jar) - $(PRIVATE_STRIP_SCRIPT) $< $@ - -else # LOCAL_DEX_PREOPT $(eval $(call copy-one-file,$(common_javalib.jar),$(LOCAL_BUILT_MODULE))) -endif # LOCAL_DEX_PREOPT endif # !LOCAL_IS_STATIC_JAVA_LIBRARY diff --git a/core/java_prebuilt_internal.mk b/core/java_prebuilt_internal.mk index 5b7e9db94..8a2091e7e 100644 --- a/core/java_prebuilt_internal.mk +++ b/core/java_prebuilt_internal.mk @@ -45,19 +45,8 @@ ALL_MODULES.$(my_register_name).CLASSES_JAR := $(common_classes_jar) # defines built_odex along with rule to install odex include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk ####################################### -ifdef LOCAL_DEX_PREOPT - -$(built_module): PRIVATE_STRIP_SCRIPT := $(intermediates)/strip.sh -$(built_module): $(intermediates)/strip.sh -$(built_module): | $(DEXPREOPT_STRIP_DEPS) -$(built_module): .KATI_DEPFILE := $(built_module).d -$(built_module): $(my_prebuilt_src_file) - $(PRIVATE_STRIP_SCRIPT) $< $@ - -else # ! LOCAL_DEX_PREOPT $(built_module) : $(my_prebuilt_src_file) $(call copy-file-to-target) -endif # LOCAL_DEX_PREOPT else # ! prebuilt_module_is_dex_javalib $(built_module) : $(my_prebuilt_src_file) diff --git a/core/package_internal.mk b/core/package_internal.mk index eb3c67d80..7bbaeb6da 100644 --- a/core/package_internal.mk +++ b/core/package_internal.mk @@ -538,15 +538,6 @@ endif ifeq (true, $(LOCAL_UNCOMPRESS_DEX)) $(LOCAL_BUILT_MODULE) : $(ZIP2ZIP) endif -ifneq ($(BUILD_PLATFORM_ZIP),) -$(LOCAL_BUILT_MODULE) : .KATI_IMPLICIT_OUTPUTS := $(dir $(LOCAL_BUILT_MODULE))package.dex.apk -endif -ifdef LOCAL_DEX_PREOPT -$(LOCAL_BUILT_MODULE) : PRIVATE_STRIP_SCRIPT := $(intermediates)/strip.sh -$(LOCAL_BUILT_MODULE) : $(intermediates)/strip.sh -$(LOCAL_BUILT_MODULE) : | $(DEXPREOPT_STRIP_DEPS) -$(LOCAL_BUILT_MODULE): .KATI_DEPFILE := $(LOCAL_BUILT_MODULE).d -endif $(LOCAL_BUILT_MODULE): PRIVATE_USE_EMBEDDED_NATIVE_LIBS := $(LOCAL_USE_EMBEDDED_NATIVE_LIBS) $(LOCAL_BUILT_MODULE): @echo "target Package: $(PRIVATE_MODULE) ($@)" @@ -569,19 +560,11 @@ ifeq (true, $(LOCAL_UNCOMPRESS_DEX)) @# No need to align, sign-package below will do it. $(uncompress-dexs) endif -# Run appcompat before stripping the classes.dex file. +# Run appcompat before signing. ifeq ($(module_run_appcompat),true) $(appcompat-header) $(run-appcompat) endif # module_run_appcompat -ifdef LOCAL_DEX_PREOPT -ifneq ($(BUILD_PLATFORM_ZIP),) - @# Keep a copy of apk with classes.dex unstripped - $(hide) cp -f $@ $(dir $@)package.dex.apk -endif # BUILD_PLATFORM_ZIP - mv -f $@ $@.tmp - $(PRIVATE_STRIP_SCRIPT) $@.tmp $@ -endif # LOCAL_DEX_PREOPT $(sign-package) ifdef LOCAL_COMPRESSED_MODULE $(compress-package) diff --git a/core/soong_app_prebuilt.mk b/core/soong_app_prebuilt.mk index 8fc2e4caa..c40271781 100644 --- a/core/soong_app_prebuilt.mk +++ b/core/soong_app_prebuilt.mk @@ -97,10 +97,6 @@ endif # LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE java-dex: $(LOCAL_SOONG_DEX_JAR) -ifneq ($(BUILD_PLATFORM_ZIP),) - $(eval $(call copy-one-file,$(LOCAL_SOONG_DEX_JAR),$(dir $(LOCAL_BUILT_MODULE))package.dex.apk)) -endif - my_built_installed := $(foreach f,$(LOCAL_SOONG_BUILT_INSTALLED),\ $(call word-colon,1,$(f)):$(PRODUCT_OUT)$(call word-colon,2,$(f))) my_installed := $(call copy-many-files, $(my_built_installed))