Set pools manually for rules that can run in RBE or goma
Use .KATI_NINJA_POOL := none to mark rules that can run in RBE or
goma when they are enabled, which along with passing
--default_pool=local_pool will allow moving remoteable jobs into
the remote pool without relying on hacks in kati.
Fixes: 143938974
Test: inspect pools in build-${TARGET-PRODUCT}.ninja for m USE_RBE=true
Test: inspect pools in build-${TARGET-PRODUCT}.ninja for m USE_GOMA=true
Change-Id: I08615ae1f2eaef9ff0ba253b8aa3d83ab57ebb27
diff --git a/core/binary.mk b/core/binary.mk
index 51259b2..b22c030 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -64,6 +64,13 @@
my_export_c_include_deps := $(LOCAL_EXPORT_C_INCLUDE_DEPS)
my_arflags :=
+# Configure the pool to use for clang rules.
+# If LOCAL_CC or LOCAL_CXX is set don't use goma or RBE.
+my_pool :=
+ifeq (,$(strip $(my_cc))$(strip $(my_cxx)))
+ my_pool := $(GOMA_OR_RBE_POOL)
+endif
+
ifneq (,$(strip $(foreach dir,$(COVERAGE_PATHS),$(filter $(dir)%,$(LOCAL_PATH)))))
ifeq (,$(strip $(foreach dir,$(COVERAGE_EXCLUDE_PATHS),$(filter $(dir)%,$(LOCAL_PATH)))))
my_native_coverage := true
@@ -469,8 +476,8 @@
endif
# Disable ccache (or other compiler wrapper) except gomacc, which
# can handle -fprofile-use properly.
- my_cc_wrapper := $(filter $(GOMA_CC),$(my_cc_wrapper))
- my_cxx_wrapper := $(filter $(GOMA_CC),$(my_cxx_wrapper))
+ my_cc_wrapper := $(filter $(GOMA_CC) $(RBE_WRAPPER),$(my_cc_wrapper))
+ my_cxx_wrapper := $(filter $(GOMA_CC) $(RBE_WRAPPER),$(my_cxx_wrapper))
endif
###########################################################
@@ -874,7 +881,8 @@
$(foreach s,$(dotdot_sources),\
$(eval $(call compile-dotdot-cpp-file,$(s),\
$(my_additional_dependencies),\
- dotdot_objects)))
+ dotdot_objects,\
+ $(my_pool))))
$(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects))
cpp_normal_sources := $(filter-out ../%,$(filter %$(LOCAL_CPP_EXTENSION),$(my_src_files)))
@@ -885,6 +893,7 @@
$(dotdot_objects) $(cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
ifneq ($(strip $(cpp_objects)),)
+$(cpp_objects): .KATI_NINJA_POOL := $(my_pool)
$(cpp_objects): $(intermediates)/%.o: \
$(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \
$(my_additional_dependencies) $(CLANG_CXX)
@@ -904,6 +913,7 @@
ifneq ($(strip $(gen_cpp_objects)),)
# Compile all generated files as thumb.
+$(gen_cpp_objects): .KATI_NINJA_POOL := $(my_pool)
$(gen_cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
$(gen_cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
$(gen_cpp_objects): $(intermediates)/%.o: \
@@ -922,6 +932,7 @@
$(call track-gen-file-obj,$(gen_S_sources),$(gen_S_objects))
ifneq ($(strip $(gen_S_sources)),)
+$(gen_S_objects): .KATI_NINJA_POOL := $(my_pool)
$(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S \
$(my_additional_dependencies) $(CLANG)
$(transform-$(PRIVATE_HOST)s-to-o)
@@ -933,6 +944,7 @@
$(call track-gen-file-obj,$(gen_s_sources),$(gen_s_objects))
ifneq ($(strip $(gen_s_objects)),)
+$(gen_s_objects): .KATI_NINJA_POOL := $(my_pool)
$(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s \
$(my_additional_dependencies) $(CLANG)
$(transform-$(PRIVATE_HOST)s-to-o)
@@ -960,7 +972,8 @@
$(foreach s, $(dotdot_sources),\
$(eval $(call compile-dotdot-c-file,$(s),\
$(my_additional_dependencies),\
- dotdot_objects)))
+ dotdot_objects,\
+ $(my_pool))))
$(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects))
c_normal_sources := $(filter-out ../%,$(filter %.c,$(my_src_files)))
@@ -971,6 +984,7 @@
$(dotdot_objects) $(c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
ifneq ($(strip $(c_objects)),)
+$(c_objects): .KATI_NINJA_POOL := $(my_pool)
$(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c \
$(my_additional_dependencies) $(CLANG)
$(transform-$(PRIVATE_HOST)c-to-o)
@@ -989,6 +1003,7 @@
ifneq ($(strip $(gen_c_objects)),)
# Compile all generated files as thumb.
+$(gen_c_objects): .KATI_NINJA_POOL := $(my_pool)
$(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
$(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
$(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c \
@@ -1007,6 +1022,7 @@
ifneq ($(strip $(objc_objects)),)
my_soong_problems += objc
+$(objc_objects): .KATI_NINJA_POOL := $(my_pool)
$(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m \
$(my_additional_dependencies) $(CLANG)
$(transform-$(PRIVATE_HOST)m-to-o)
@@ -1022,6 +1038,7 @@
$(call track-src-file-obj,$(objcpp_sources),$(objcpp_objects))
ifneq ($(strip $(objcpp_objects)),)
+$(objcpp_objects): .KATI_NINJA_POOL := $(my_pool)
$(objcpp_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.mm \
$(my_additional_dependencies) $(CLANG_CXX)
$(transform-$(PRIVATE_HOST)mm-to-o)
@@ -1042,10 +1059,12 @@
$(foreach s,$(dotdot_sources),\
$(eval $(call compile-dotdot-s-file,$(s),\
$(my_additional_dependencies),\
- dotdot_objects_S)))
+ dotdot_objects_S,\
+ $(my_pool))))
$(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects_S))
ifneq ($(strip $(asm_objects_S)),)
+$(asm_objects_S): .KATI_NINJA_POOL := $(my_pool)
$(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S \
$(my_additional_dependencies) $(CLANG)
$(transform-$(PRIVATE_HOST)s-to-o)
@@ -1062,10 +1081,12 @@
$(foreach s,$(dotdot_sources),\
$(eval $(call compile-dotdot-s-file-no-deps,$(s),\
$(my_additional_dependencies),\
- dotdot_objects_s)))
+ dotdot_objects_s,\
+ $(my_pool))))
$(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects_s))
ifneq ($(strip $(asm_objects_s)),)
+$(asm_objects_s): .KATI_NINJA_POOL := $(my_pool)
$(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s \
$(my_additional_dependencies) $(CLANG)
$(transform-$(PRIVATE_HOST)s-to-o)
diff --git a/core/config.mk b/core/config.mk
index a1bbe18..9ab3fff 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -1150,6 +1150,21 @@
$(filter $(ANDROID_WARNING_ALLOWED_PROJECTS),$(1)/)
endef
+GOMA_POOL :=
+RBE_POOL :=
+GOMA_OR_RBE_POOL :=
+# When goma or RBE are enabled, kati will be passed --default_pool=local_pool to put
+# most rules into the local pool. Explicitly set the pool to "none" for rules that
+# should be run outside the local pool, i.e. with -j500.
+ifneq (,$(filter-out false,$(USE_GOMA)))
+ GOMA_POOL := none
+ GOMA_OR_RBE_POOL := none
+else ifneq (,$(filter-out false,$(USE_RBE)))
+ RBE_POOL := none
+ GOMA_OR_RBE_POOL := none
+endif
+.KATI_READONLY := GOMA_POOL RBE_POOL GOMA_OR_RBE_POOL
+
# These goals don't need to collect and include Android.mks/CleanSpec.mks
# in the source tree.
dont_bother_goals := out \
diff --git a/core/definitions.mk b/core/definitions.mk
index 8eb1142..b419aae 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -1363,8 +1363,10 @@
# $(1): the C++ source file in LOCAL_SRC_FILES.
# $(2): the additional dependencies.
# $(3): the variable name to collect the output object file.
+# $(4): the ninja pool to use for the rule
define compile-dotdot-cpp-file
o := $(intermediates)/$(patsubst %$(LOCAL_CPP_EXTENSION),%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1)))
+$$(o) : .KATI_NINJA_POOL := $(4)
$$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2) $(CLANG_CXX)
$$(transform-$$(PRIVATE_HOST)cpp-to-o)
$$(call include-depfiles-for-objs, $$(o))
@@ -1376,8 +1378,10 @@
# $(1): the C source file in LOCAL_SRC_FILES.
# $(2): the additional dependencies.
# $(3): the variable name to collect the output object file.
+# $(4): the ninja pool to use for the rule
define compile-dotdot-c-file
o := $(intermediates)/$(patsubst %.c,%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1)))
+$$(o) : .KATI_NINJA_POOL := $(4)
$$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2) $(CLANG)
$$(transform-$$(PRIVATE_HOST)c-to-o)
$$(call include-depfiles-for-objs, $$(o))
@@ -1389,8 +1393,10 @@
# $(1): the .S source file in LOCAL_SRC_FILES.
# $(2): the additional dependencies.
# $(3): the variable name to collect the output object file.
+# $(4): the ninja pool to use for the rule
define compile-dotdot-s-file
o := $(intermediates)/$(patsubst %.S,%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1)))
+$$(o) : .KATI_NINJA_POOL := $(4)
$$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2) $(CLANG)
$$(transform-$$(PRIVATE_HOST)s-to-o)
$$(call include-depfiles-for-objs, $$(o))
@@ -1402,8 +1408,10 @@
# $(1): the .s source file in LOCAL_SRC_FILES.
# $(2): the additional dependencies.
# $(3): the variable name to collect the output object file.
+# $(4): the ninja pool to use for the rule
define compile-dotdot-s-file-no-deps
o := $(intermediates)/$(patsubst %.s,%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1)))
+$$(o) : .KATI_NINJA_POOL := $(4)
$$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2) $(CLANG)
$$(transform-$$(PRIVATE_HOST)s-to-o)
$(3) += $$(o)
diff --git a/core/host_dalvik_java_library.mk b/core/host_dalvik_java_library.mk
index 8e655ff..882fe3a 100644
--- a/core/host_dalvik_java_library.mk
+++ b/core/host_dalvik_java_library.mk
@@ -79,6 +79,7 @@
$(java_source_list_file): $(java_sources_deps)
$(write-java-source-list)
+$(full_classes_compiled_jar): .KATI_NINJA_POOL := $(GOMA_POOL)
$(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file)
$(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) $(annotation_processor_flags)
$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES :=
diff --git a/core/host_java_library.mk b/core/host_java_library.mk
index 6c23789..beaea2a 100644
--- a/core/host_java_library.mk
+++ b/core/host_java_library.mk
@@ -70,6 +70,7 @@
$(java_source_list_file): $(java_sources_deps)
$(write-java-source-list)
+$(full_classes_compiled_jar): .KATI_NINJA_POOL := $(GOMA_POOL)
$(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file)
$(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) $(annotation_processor_flags)
$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES :=
diff --git a/core/java.mk b/core/java.mk
index 99774cf..cbcd1b5 100644
--- a/core/java.mk
+++ b/core/java.mk
@@ -274,6 +274,7 @@
endif # TURBINE_ENABLED != false
+$(full_classes_compiled_jar): .KATI_NINJA_POOL := $(GOMA_POOL)
$(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) $(annotation_processor_flags)
$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES := $(LOCAL_JAR_EXCLUDE_FILES)
$(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES := $(LOCAL_JAR_PACKAGES)