Merge "Remove support for building Windows modules in Make"
diff --git a/CleanSpec.mk b/CleanSpec.mk
index f09b892..f05410d 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -540,6 +540,10 @@
 $(call add-clean-step, rm -f $(PRODUCT_OUT)/system/lib*/libopenjdk.so)
 $(call add-clean-step, rm -f $(PRODUCT_OUT)/system/lib*/libexpat.so)
 
+# Merge product_services into product
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/product_services)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/product_services)
+
 
 # ************************************************
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
diff --git a/core/aux_config.mk b/core/aux_config.mk
index d382ff5..a508a2d 100644
--- a/core/aux_config.mk
+++ b/core/aux_config.mk
@@ -181,5 +181,3 @@
 endif
 
 INSTALLED_AUX_TARGETS :=
-
-droidcore: auxiliary
diff --git a/core/config_sanitizers.mk b/core/config_sanitizers.mk
index bbf3b7d..2b182f5 100644
--- a/core/config_sanitizers.mk
+++ b/core/config_sanitizers.mk
@@ -213,6 +213,11 @@
   my_sanitize := $(filter-out scudo,$(my_sanitize))
 endif
 
+# Or if disabled globally.
+ifeq ($(strip $(PRODUCT_DISABLE_SCUDO)),true)
+  my_sanitize := $(filter-out scudo,$(my_sanitize))
+endif
+
 # Undefined symbols can occur if a non-sanitized library links
 # sanitized static libraries. That's OK, because the executable
 # always depends on the ASan runtime library, which defines these
diff --git a/core/envsetup.mk b/core/envsetup.mk
index 1426935..e62636e 100644
--- a/core/envsetup.mk
+++ b/core/envsetup.mk
@@ -443,7 +443,8 @@
 # Now we can substitute with the real value of TARGET_COPY_OUT_PRODUCT_SERVICES
 MERGE_PRODUCT_SERVICES_INTO_PRODUCT :=
 ifeq ($(TARGET_COPY_OUT_PRODUCT_SERVICES),$(_product_services_path_placeholder))
-  TARGET_COPY_OUT_PRODUCT_SERVICES := system/product_services
+  TARGET_COPY_OUT_PRODUCT_SERVICES := $(TARGET_COPY_OUT_PRODUCT)
+  MERGE_PRODUCT_SERVICES_INTO_PRODUCT := true
 else ifeq ($(TARGET_COPY_OUT_PRODUCT),$(TARGET_COPY_OUT_PRODUCT_SERVICES))
   MERGE_PRODUCT_SERVICES_INTO_PRODUCT := true
 else ifeq ($(filter product_services system/product_services,$(TARGET_COPY_OUT_PRODUCT_SERVICES)),)
diff --git a/core/main.mk b/core/main.mk
index 67cd3ac..71b6ed7 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -1388,6 +1388,7 @@
     $(INSTALLED_FILES_FILE_RECOVERY) \
     $(INSTALLED_FILES_JSON_RECOVERY) \
     $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
+    auxiliary \
     soong_docs
 
 # dist_files only for putting your library into the dist directory with a full build.
diff --git a/core/product.mk b/core/product.mk
index c3cbb0c..d249adf 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -201,6 +201,7 @@
     PRODUCT_ADB_KEYS \
     PRODUCT_CFI_INCLUDE_PATHS \
     PRODUCT_CFI_EXCLUDE_PATHS \
+    PRODUCT_DISABLE_SCUDO \
     PRODUCT_COMPATIBLE_PROPERTY_OVERRIDE \
     PRODUCT_ACTIONABLE_COMPATIBLE_PROPERTY_DISABLE \
     PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS \
diff --git a/core/product_config.mk b/core/product_config.mk
index 1f44692..4823e24 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -512,6 +512,10 @@
 PRODUCT_CFI_INCLUDE_PATHS := \
     $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_CFI_INCLUDE_PATHS))
 
+# Whether the Scudo hardened allocator is disabled platform-wide
+PRODUCT_DISABLE_SCUDO := \
+    $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DISABLE_SCUDO))
+
 # Whether any paths are excluded from being set XOM when ENABLE_XOM=true
 PRODUCT_XOM_EXCLUDE_PATHS := \
     $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_XOM_EXCLUDE_PATHS))
diff --git a/core/soong_config.mk b/core/soong_config.mk
index cd8cd7f..ccfcf87 100644
--- a/core/soong_config.mk
+++ b/core/soong_config.mk
@@ -87,6 +87,8 @@
 $(call add_json_list, XOMExcludePaths,                   $(XOM_EXCLUDE_PATHS) $(PRODUCT_XOM_EXCLUDE_PATHS))
 $(call add_json_list, IntegerOverflowExcludePaths,       $(INTEGER_OVERFLOW_EXCLUDE_PATHS) $(PRODUCT_INTEGER_OVERFLOW_EXCLUDE_PATHS))
 
+$(call add_json_bool, DisableScudo,                      $(filter true,$(PRODUCT_DISABLE_SCUDO)))
+
 $(call add_json_bool, ClangTidy,                         $(filter 1 true,$(WITH_TIDY)))
 $(call add_json_str,  TidyChecks,                        $(WITH_TIDY_CHECKS))
 
diff --git a/target/product/go_defaults_common.mk b/target/product/go_defaults_common.mk
index 06bdec9..e35bf30 100644
--- a/target/product/go_defaults_common.mk
+++ b/target/product/go_defaults_common.mk
@@ -69,3 +69,8 @@
 # the size of the system image. This has no bearing on stack traces, but will
 # leave less information available via JDWP.
 PRODUCT_MINIMIZE_JAVA_DEBUG_INFO := true
+
+# Disable Scudo outside of eng builds to save RAM.
+ifneq (,$(filter eng, $(TARGET_BUILD_VARIANT)))
+  PRODUCT_DISABLE_SCUDO := true
+endif