Merge "Re-implement mma/mmma using make goals."
diff --git a/core/binary.mk b/core/binary.mk
index 38fcacc..093cc38 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -412,19 +412,6 @@
 endif
 endif
 
-# Target modules shouldn't re-export libgcc.a because we don't want other
-# binaries importing them when they should be getting their own copy of the
-# builtins.
-#
-# Unfortunately --exclude-libs always overrides all other attempts to make a
-# symbol visible, and libc needs to make sure some of these symbols are
-# available for binary compatibility, so libc needs a way to disable this.
-ifndef LOCAL_IS_HOST_MODULE
-  ifneq ($(strip $(LOCAL_NO_EXCLUDE_LIBS)),true)
-    my_ldflags += -Wl,--exclude-libs,libgcc.a
-  endif
-endif
-
 ifeq (true,$(LOCAL_GROUP_STATIC_LIBRARIES))
 $(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := true
 else
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index 649fbe5..d0d4ff9 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -190,7 +190,6 @@
 LOCAL_DBUS_PROXY_PREFIX:=
 LOCAL_INIT_RC:=
 LOCAL_MODULE_HOST_OS:=
-LOCAL_NO_EXCLUDE_LIBS:=
 
 # arch specific variables
 LOCAL_SRC_FILES_$(TARGET_ARCH):=
diff --git a/core/combo/HOST_linux-x86.mk b/core/combo/HOST_linux-x86.mk
index 6ea526c..4caf607 100644
--- a/core/combo/HOST_linux-x86.mk
+++ b/core/combo/HOST_linux-x86.mk
@@ -25,7 +25,7 @@
 $(combo_2nd_arch_prefix)HOST_AR  := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)ar
 
 # gcc location for clang; to be updated when clang is updated
-$(combo_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG := prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/
+$(combo_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG := prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8
 
 # We expect SSE3 floating point math.
 $(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -msse3 -mfpmath=sse -m32 -Wa,--noexecstack -march=prescott
diff --git a/core/combo/HOST_linux-x86_64.mk b/core/combo/HOST_linux-x86_64.mk
index 13e1e8a..3708137 100644
--- a/core/combo/HOST_linux-x86_64.mk
+++ b/core/combo/HOST_linux-x86_64.mk
@@ -25,7 +25,7 @@
 HOST_AR  := $(HOST_TOOLCHAIN_PREFIX)ar
 
 # gcc location for clang; to be updated when clang is updated
-HOST_TOOLCHAIN_FOR_CLANG := prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/
+HOST_TOOLCHAIN_FOR_CLANG := prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8
 
 HOST_GLOBAL_CFLAGS += -m64 -Wa,--noexecstack
 HOST_GLOBAL_LDFLAGS += -m64 -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now
diff --git a/core/config.mk b/core/config.mk
index dd0dfc2..a7517f3 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -120,8 +120,8 @@
 COMMON_GLOBAL_CFLAGS:= -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith
 COMMON_RELEASE_CFLAGS:= -DNDEBUG -UDEBUG
 
-COMMON_GLOBAL_CPPFLAGS:= $(COMMON_GLOBAL_CFLAGS) -Wsign-promo
-COMMON_RELEASE_CPPFLAGS:= $(COMMON_RELEASE_CFLAGS)
+COMMON_GLOBAL_CPPFLAGS:= -Wsign-promo
+COMMON_RELEASE_CPPFLAGS:=
 
 GLOBAL_CFLAGS_NO_OVERRIDE := \
     -Werror=int-to-pointer-cast \
@@ -181,7 +181,6 @@
 
 ifeq ($(OVERRIDE_C_DATE_TIME),true)
 COMMON_GLOBAL_CFLAGS += -Wno-builtin-macro-redefined -D__DATE__="\"$(BUILD_DATETIME_C_DATE)\"" -D__TIME__=\"$(BUILD_DATETIME_C_TIME)\"
-COMMON_GLOBAL_CPPFLAGS += -Wno-builtin-macro-redefined -D__DATE__="\"$(BUILD_DATETIME_C_DATE)\"" -D__TIME__=\"$(BUILD_DATETIME_C_TIME)\"
 endif
 
 # The build system exposes several variables for where to find the kernel
@@ -582,7 +581,6 @@
 # sure to only specify them for the target compilers checked in to
 # the source tree.
 TARGET_GLOBAL_CFLAGS += $(TARGET_ERROR_FLAGS)
-TARGET_GLOBAL_CPPFLAGS += $(TARGET_ERROR_FLAGS)
 
 HOST_GLOBAL_CFLAGS += $(HOST_RELEASE_CFLAGS)
 HOST_GLOBAL_CPPFLAGS += $(HOST_RELEASE_CPPFLAGS)
@@ -598,7 +596,6 @@
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LD_DIRS += -L$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_PROJECT_INCLUDES := $(TARGET_PROJECT_INCLUDES)
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS += $(TARGET_ERROR_FLAGS)
-$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS += $(TARGET_ERROR_FLAGS)
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS += $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_RELEASE_CFLAGS)
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS += $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_RELEASE_CPPFLAGS)
 endif
diff --git a/core/definitions.mk b/core/definitions.mk
index 57b0af0..af3929e 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -187,10 +187,10 @@
 ###########################################################
 
 define all-java-files-under
-$(patsubst ./%,%, \
+$(sort $(patsubst ./%,%, \
   $(shell cd $(LOCAL_PATH) ; \
           find -L $(1) -name "*.java" -and -not -name ".*") \
- )
+ ))
 endef
 
 ###########################################################
@@ -209,10 +209,10 @@
 ###########################################################
 
 define all-c-files-under
-$(patsubst ./%,%, \
+$(sort $(patsubst ./%,%, \
   $(shell cd $(LOCAL_PATH) ; \
           find -L $(1) -name "*.c" -and -not -name ".*") \
- )
+ ))
 endef
 
 ###########################################################
@@ -231,10 +231,10 @@
 ###########################################################
 
 define all-Iaidl-files-under
-$(patsubst ./%,%, \
+$(sort $(patsubst ./%,%, \
   $(shell cd $(LOCAL_PATH) ; \
           find -L $(1) -name "I*.aidl" -and -not -name ".*") \
- )
+ ))
 endef
 
 ###########################################################
@@ -252,10 +252,10 @@
 ###########################################################
 
 define all-logtags-files-under
-$(patsubst ./%,%, \
+$(sort $(patsubst ./%,%, \
   $(shell cd $(LOCAL_PATH) ; \
           find -L $(1) -name "*.logtags" -and -not -name ".*") \
-  )
+  ))
 endef
 
 ###########################################################
@@ -265,10 +265,10 @@
 ###########################################################
 
 define all-proto-files-under
-$(patsubst ./%,%, \
+$(sort $(patsubst ./%,%, \
   $(shell cd $(LOCAL_PATH) ; \
           find -L $(1) -name "*.proto" -and -not -name ".*") \
-  )
+  ))
 endef
 
 ###########################################################
@@ -278,10 +278,10 @@
 ###########################################################
 
 define all-renderscript-files-under
-$(patsubst ./%,%, \
+$(sort $(patsubst ./%,%, \
   $(shell cd $(LOCAL_PATH) ; \
           find -L $(1) \( -name "*.rs" -or -name "*.fs" \) -and -not -name ".*") \
-  )
+  ))
 endef
 
 ###########################################################
@@ -291,10 +291,10 @@
 ###########################################################
 
 define all-S-files-under
-$(patsubst ./%,%, \
+$(sort $(patsubst ./%,%, \
   $(shell cd $(LOCAL_PATH) ; \
           find -L $(1) -name "*.S" -and -not -name ".*") \
- )
+ ))
 endef
 
 ###########################################################
@@ -304,10 +304,10 @@
 ###########################################################
 
 define all-html-files-under
-$(patsubst ./%,%, \
+$(sort $(patsubst ./%,%, \
   $(shell cd $(LOCAL_PATH) ; \
           find -L $(1) -name "*.html" -and -not -name ".*") \
- )
+ ))
 endef
 
 ###########################################################
@@ -325,7 +325,7 @@
 ###########################################################
 
 define find-subdir-files
-$(patsubst ./%,%,$(shell cd $(LOCAL_PATH) ; find -L $(1)))
+$(sort $(patsubst ./%,%,$(shell cd $(LOCAL_PATH) ; find -L $(1))))
 endef
 
 ###########################################################
@@ -337,8 +337,8 @@
 ###########################################################
 
 define find-subdir-subdir-files
-$(filter-out $(patsubst %,$(1)/%,$(3)),$(patsubst ./%,%,$(shell cd \
-            $(LOCAL_PATH) ; find -L $(1) -maxdepth 1 -name $(2))))
+$(sort $(filter-out $(patsubst %,$(1)/%,$(3)),$(patsubst ./%,%,$(shell cd \
+            $(LOCAL_PATH) ; find -L $(1) -maxdepth 1 -name $(2)))))
 endef
 
 ###########################################################
@@ -347,10 +347,10 @@
 ###########################################################
 
 define find-subdir-assets
-$(if $(1),$(patsubst ./%,%, \
+$(sort $(if $(1),$(patsubst ./%,%, \
 	$(shell if [ -d $(1) ] ; then cd $(1) ; find ./ -not -name '.*' -and -type f -and -not -type l ; fi)), \
 	$(warning Empty argument supplied to find-subdir-assets) \
-)
+))
 endef
 
 ###########################################################
@@ -375,10 +375,10 @@
 ###########################################################
 
 define find-files-in-subdirs
-$(patsubst ./%,%, \
+$(sort $(patsubst ./%,%, \
   $(shell cd $(1) ; \
           find -L $(3) -name $(2) -and -not -name ".*") \
- )
+ ))
 endef
 
 ###########################################################
diff --git a/core/ninja.mk b/core/ninja.mk
index 2aa0b28..c469e02 100644
--- a/core/ninja.mk
+++ b/core/ninja.mk
@@ -135,7 +135,7 @@
 	@echo Running kati to generate build$(KATI_NINJA_SUFFIX).ninja...
 	+$(hide) $(KATI_MAKEPARALLEL) $(KATI) --ninja --ninja_dir=$(PRODUCT_OUT) --ninja_suffix=$(KATI_NINJA_SUFFIX) --regen --ignore_dirty=$(OUT_DIR)/% --ignore_optional_include=$(OUT_DIR)/%.P --detect_android_echo --use_find_emulator $(KATI_REMOTE_NUM_JOBS_FLAG) -f build/core/main.mk $(or $(KATI_TARGETS),--gen_all_phony_targets) USE_NINJA=false
 
-KATI_CXX := $(CLANG_CXX) $(CLANG_HOST_GLOBAL_CPPFLAGS)
+KATI_CXX := $(CLANG_CXX) $(CLANG_HOST_GLOBAL_CFLAGS) $(CLANG_HOST_GLOBAL_CPPFLAGS)
 KATI_LD := $(CLANG_CXX) $(CLANG_HOST_GLOBAL_LDFLAGS)
 # Build static ckati. Unfortunately Mac OS X doesn't officially support static exectuables.
 ifeq ($(BUILD_OS),linux)