Allow changing the optimization level of a build with env variable.

This is useful for debugging.

Change-Id: I60e61cdb53a00d74cf619d56991f9d11ab9ae0c4
diff --git a/build/Android.common_build.mk b/build/Android.common_build.mk
index b507124..b3d246c 100644
--- a/build/Android.common_build.mk
+++ b/build/Android.common_build.mk
@@ -34,6 +34,10 @@
 ART_BUILD_HOST_NDEBUG ?= true
 ART_BUILD_HOST_DEBUG ?= true
 
+# Set this to change what opt level Art is built at.
+ART_DEBUG_OPT_FLAG ?= -O2
+ART_NDEBUG_OPT_FLAG ?= -O3
+
 # Enable the static builds only for checkbuilds.
 ifneq (,$(filter checkbuild,$(MAKECMDGOALS)))
   ART_BUILD_HOST_STATIC ?= true
@@ -319,11 +323,11 @@
 
 # Cflags for non-debug ART and ART tools.
 art_non_debug_cflags := \
-  -O3
+  $(ART_NDEBUG_OPT_FLAG)
 
 # Cflags for debug ART and ART tools.
 art_debug_cflags := \
-  -O2 \
+  $(ART_DEBUG_OPT_FLAG) \
   -DDYNAMIC_ANNOTATIONS_ENABLED=1 \
   -DVIXL_DEBUG \
   -UNDEBUG