From fd1e67b8ce041c96ddb8ca99a375182f50fad7a4 Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Mon, 8 Jun 2020 18:50:14 -0700 Subject: [PATCH] More performance improvements Instead of using `x := $(x) foo`, make sure `x` is initialized first, then use `x += foo`. For a aosp-master/aosp_crosshatch-userdebug build, this takes the build from 49s to 33s (no significant difference in peak memory) Bug: 158488548 Test: build-aosp_crosshatch.ninja is the same before/after Change-Id: I41fb7611030dd3ba824f896a9c9eadbdd218f464 --- core/binary.mk | 2 +- core/cc_prebuilt_internal.mk | 2 +- core/definitions.mk | 9 +++++++++ core/link_type.mk | 2 +- core/soong_android_app_set.mk | 2 +- core/soong_app_prebuilt.mk | 2 +- core/soong_cc_prebuilt.mk | 4 ++-- core/soong_java_prebuilt.mk | 2 +- 8 files changed, 17 insertions(+), 8 deletions(-) diff --git a/core/binary.mk b/core/binary.mk index b14d8b82b..4894bf2b6 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -1799,7 +1799,7 @@ export_include_deps += $(strip \ $(call intermediates-dir-for,HEADER_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross)))) ifneq ($(strip $(my_export_c_include_dirs)$(export_include_deps)),) - EXPORTS_LIST := $(EXPORTS_LIST) $(intermediates) + EXPORTS_LIST += $(intermediates) EXPORTS.$(intermediates).FLAGS := $(foreach d,$(my_export_c_include_dirs),-I $(call clean-path,$(d))) EXPORTS.$(intermediates).REEXPORT := $(export_include_deps) EXPORTS.$(intermediates).DEPS := $(my_export_c_include_deps) $(my_generated_sources) $(LOCAL_EXPORT_C_INCLUDE_DEPS) diff --git a/core/cc_prebuilt_internal.mk b/core/cc_prebuilt_internal.mk index 1d959b5ca..99b7d0f6a 100644 --- a/core/cc_prebuilt_internal.mk +++ b/core/cc_prebuilt_internal.mk @@ -75,7 +75,7 @@ else # my_strip_module not true built_module := $(LOCAL_BUILT_MODULE) ifdef prebuilt_module_is_a_library -EXPORTS_LIST := $(EXPORTS_LIST) $(intermediates) +EXPORTS_LIST += $(intermediates) EXPORTS.$(intermediates).FLAGS := $(foreach d,$(LOCAL_EXPORT_C_INCLUDE_DIRS),-I $(d)) EXPORTS.$(intermediates).DEPS := $(LOCAL_EXPORT_C_INCLUDE_DEPS) diff --git a/core/definitions.mk b/core/definitions.mk index 367290039..402d9197b 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -110,6 +110,15 @@ ALL_DISABLED_PRESUBMIT_TESTS := # All compatibility suites mentioned in LOCAL_COMPATIBILITY_SUITES ALL_COMPATIBILITY_SUITES := +# All LINK_TYPE entries +ALL_LINK_TYPES := + +# All exported/imported include entries +EXPORTS_LIST := + +# All modules already converted to Soong +SOONG_ALREADY_CONV := + ########################################################### ## Debugging; prints a variable list to stdout ########################################################### diff --git a/core/link_type.mk b/core/link_type.mk index ff525cb04..48cd8f3e8 100644 --- a/core/link_type.mk +++ b/core/link_type.mk @@ -12,7 +12,7 @@ my_link_prefix := LINK_TYPE:$(call find-idf-prefix,$(my_kind),$(my_host_cross)):$(if $(my_common),$(my_common):_,_:$(if $(my_2nd_arch_prefix),$(my_2nd_arch_prefix),_)) link_type := $(my_link_prefix):$(LOCAL_MODULE_CLASS):$(LOCAL_MODULE) -ALL_LINK_TYPES := $(ALL_LINK_TYPES) $(link_type) +ALL_LINK_TYPES += $(link_type) $(link_type).TYPE := $(my_link_type) $(link_type).MAKEFILE := $(LOCAL_MODULE_MAKEFILE) $(link_type).WARN := $(my_warn_types) diff --git a/core/soong_android_app_set.mk b/core/soong_android_app_set.mk index 4c27e5346..5ed9b2c29 100644 --- a/core/soong_android_app_set.mk +++ b/core/soong_android_app_set.mk @@ -31,4 +31,4 @@ LOCAL_POST_INSTALL_CMD := unzip -qo -j -d $(dir $(LOCAL_INSTALLED_MODULE)) \ $(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := $(LOCAL_POST_INSTALL_CMD) PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES)) -SOONG_ALREADY_CONV := $(SOONG_ALREADY_CONV) $(LOCAL_MODULE) +SOONG_ALREADY_CONV += $(LOCAL_MODULE) diff --git a/core/soong_app_prebuilt.mk b/core/soong_app_prebuilt.mk index 09c79f625..3549c1df5 100644 --- a/core/soong_app_prebuilt.mk +++ b/core/soong_app_prebuilt.mk @@ -218,4 +218,4 @@ ifdef LOCAL_PREBUILT_COVERAGE_ARCHIVE $(LOCAL_INSTALLED_MODULE): $(my_coverage_files) endif -SOONG_ALREADY_CONV := $(SOONG_ALREADY_CONV) $(LOCAL_MODULE) +SOONG_ALREADY_CONV += $(LOCAL_MODULE) diff --git a/core/soong_cc_prebuilt.mk b/core/soong_cc_prebuilt.mk index 6317b533f..986609b50 100644 --- a/core/soong_cc_prebuilt.mk +++ b/core/soong_cc_prebuilt.mk @@ -51,7 +51,7 @@ include $(BUILD_SYSTEM)/base_rules.mk ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES HEADER_LIBRARIES,$(LOCAL_MODULE_CLASS)),) # Soong module is a static or shared library - EXPORTS_LIST := $(EXPORTS_LIST) $(intermediates) + EXPORTS_LIST += $(intermediates) EXPORTS.$(intermediates).FLAGS := $(LOCAL_EXPORT_CFLAGS) EXPORTS.$(intermediates).DEPS := $(LOCAL_EXPORT_C_INCLUDE_DEPS) @@ -61,7 +61,7 @@ ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES HEADER_LIBRARIES,$(LOCAL_MODUL $(my_all_targets): $(LOCAL_BUILT_MODULE).toc endif - SOONG_ALREADY_CONV := $(SOONG_ALREADY_CONV) $(LOCAL_MODULE) + SOONG_ALREADY_CONV += $(LOCAL_MODULE) my_link_type := $(LOCAL_SOONG_LINK_TYPE) my_warn_types := diff --git a/core/soong_java_prebuilt.mk b/core/soong_java_prebuilt.mk index b15e7f68b..e4c84e091 100644 --- a/core/soong_java_prebuilt.mk +++ b/core/soong_java_prebuilt.mk @@ -173,4 +173,4 @@ $(my_exported_sdk_libs_file): $(hide) echo $(PRIVATE_EXPORTED_SDK_LIBS) | tr ' ' '\n' > $@,\ $(hide) touch $@) -SOONG_ALREADY_CONV := $(SOONG_ALREADY_CONV) $(LOCAL_MODULE) +SOONG_ALREADY_CONV += $(LOCAL_MODULE)