Bring our native stack usage down.

I'd have preferred to have a 512-byte limit, but there are some monsters
in the verifier; 2000-line functions and the like. I'm also not policing
tests (except for one silly one). They can use all the stack they like.

This fixes the IntMath test (the stack overflow test was failing because
we were using more than 4KiB to throw!).

Change-Id: I7e53e2fde2b39fde1910f8ee5b1712e8a66069c7
diff --git a/build/Android.common.mk b/build/Android.common.mk
index f72db43..d3f10f3 100644
--- a/build/Android.common.mk
+++ b/build/Android.common.mk
@@ -44,6 +44,12 @@
 	-fno-align-jumps \
 	-fstrict-aliasing
 
+art_non_debug_cflags := \
+	-Wframe-larger-than=1728
+
+art_debug_cflags := \
+	-UNDEBUG
+
 ART_HOST_CFLAGS := $(art_cflags) -DANDROID_SMP=1
 
 ART_TARGET_CFLAGS := $(art_cflags)
@@ -53,7 +59,9 @@
   ART_TARGET_CFLAGS += -DANDROID_SMP=0
 endif
 
-art_debug_cflags := -UNDEBUG
+ART_HOST_NON_DEBUG_CFLAGS := $(art_non_debug_cflags)
+ART_TARGET_NON_DEBUG_CFLAGS := $(art_non_debug_cflags)
+
 # TODO: move -fkeep-inline-functions to art_debug_cflags when target gcc > 4.4
 ART_HOST_DEBUG_CFLAGS := $(art_debug_cflags) -fkeep-inline-functions
 ART_TARGET_DEBUG_CFLAGS := $(art_debug_cflags)
diff --git a/build/Android.executable.mk b/build/Android.executable.mk
index d00002a..616c1c2 100644
--- a/build/Android.executable.mk
+++ b/build/Android.executable.mk
@@ -59,11 +59,15 @@
     LOCAL_CFLAGS := $(ART_TARGET_CFLAGS)
     ifeq ($$(art_ndebug_or_debug),debug)
       LOCAL_CFLAGS += $(ART_TARGET_DEBUG_CFLAGS)
+    else
+      LOCAL_CFLAGS += $(ART_TARGET_NON_DEBUG_CFLAGS)
     endif
   else # host
     LOCAL_CFLAGS := $(ART_HOST_CFLAGS)
     ifeq ($$(art_ndebug_or_debug),debug)
       LOCAL_CFLAGS += $(ART_HOST_DEBUG_CFLAGS)
+    else
+      LOCAL_CFLAGS += $(ART_HOST_NON_DEBUG_CFLAGS)
     endif
   endif
 
diff --git a/build/Android.libart.mk b/build/Android.libart.mk
index 6c33512..4f0efe3 100644
--- a/build/Android.libart.mk
+++ b/build/Android.libart.mk
@@ -60,6 +60,12 @@
       LOCAL_CFLAGS += $(ART_HOST_DEBUG_CFLAGS)
       LOCAL_STATIC_LIBRARIES := libgtest_host
     endif
+  else
+    ifeq ($$(art_target_or_host),target)
+      LOCAL_CFLAGS += $(ART_TARGET_NON_DEBUG_CFLAGS)
+    else # host
+      LOCAL_CFLAGS += $(ART_HOST_NON_DEBUG_CFLAGS)
+    endif
   endif
   LOCAL_C_INCLUDES += $(ART_C_INCLUDES)
   LOCAL_SHARED_LIBRARIES := liblog libnativehelper