Merge "Updating document for C++ exception support."
diff --git a/build/core/add-application.mk b/build/core/add-application.mk
index acf76bb..f33d327 100644
--- a/build/core/add-application.mk
+++ b/build/core/add-application.mk
@@ -231,15 +231,7 @@
     endif
 endif
 
-# set release/debug build flags. We always use the -g flag because
-# we generate symbol versions of the binaries that are later stripped
-# when they are copied to the final project's libs/<abi> directory.
-#
-ifeq ($(APP_OPTIM),debug)
-  APP_CFLAGS := -O0 -g $(APP_CFLAGS)
-else
-  APP_CFLAGS := -O2 -DNDEBUG -g $(APP_CFLAGS)
-endif
+APP_CFLAGS := $(strip $(APP_CFLAGS))
 
 # Check that APP_STL is defined. If not, use the default value (system)
 # otherwise, check that the name is correct.
@@ -250,8 +242,6 @@
     $(call ndk-stl-check,$(APP_STL))
 endif
 
-
-
 $(if $(call get,$(_map),defined),\
   $(call __ndk_info,Weird, the application $(_app) is already defined by $(call get,$(_map),defined))\
   $(call __ndk_error,Aborting)\
diff --git a/build/core/build-binary.mk b/build/core/build-binary.mk
index bfc2aed..982648a 100644
--- a/build/core/build-binary.mk
+++ b/build/core/build-binary.mk
@@ -203,6 +203,12 @@
 endif
 $(call tag-src-files,$(arm_sources),arm)
 
+# tag debug if APP_OPTIM is 'debug'
+#
+ifeq ($(APP_OPTIM),debug)
+    $(call tag-src-files,$(LOCAL_SRC_FILES),debug)
+endif
+
 # Process all source file tags to determine toolchain-specific
 # target compiler flags, and text.
 #
diff --git a/build/core/init.mk b/build/core/init.mk
index 23981a0..d33dd0f 100644
--- a/build/core/init.mk
+++ b/build/core/init.mk
@@ -281,20 +281,29 @@
 # Check for NDK-specific versions of our host tools
 HOST_PREBUILT_ROOT := $(call host-prebuilt-tag, $(NDK_ROOT))
 HOST_PREBUILT := $(strip $(wildcard $(HOST_PREBUILT_ROOT)/bin))
+HOST_AWK := $(strip $(NDK_HOST_AWK))
+HOST_SED  := $(strip $(NDK_HOST_SED))
+HOST_MAKE := $(strip $(NDK_HOST_MAKE))
 ifdef HOST_PREBUILT
     $(call ndk_log,Host tools prebuilt directory: $(HOST_PREBUILT))
     # The windows prebuilt binaries are for ndk-build.cmd
     # On cygwin, we must use the Cygwin version of these tools instead.
     ifneq ($(HOST_OS),cygwin)
-        HOST_AWK := $(wildcard $(HOST_PREBUILT)/awk$(HOST_EXEEXT))
-        HOST_SED  := $(wildcard $(HOST_PREBUILT)/sed$(HOST_EXEEXT))
-        HOST_MAKE := $(wildcard $(HOST_PREBUILT)/make$(HOST_EXEEXT))
+        ifndef HOST_AWK
+            HOST_AWK := $(wildcard $(HOST_PREBUILT)/awk$(HOST_EXEEXT))
+        endif
+        ifndef HOST_SED
+            HOST_SED  := $(wildcard $(HOST_PREBUILT)/sed$(HOST_EXEEXT))
+        endif
+        ifndef HOST_MAKE
+            HOST_MAKE := $(wildcard $(HOST_PREBUILT)/make$(HOST_EXEEXT))
+        endif
     endif
 else
     $(call ndk_log,Host tools prebuilt directory not found, using system tools)
 endif
 
-HOST_ECHO := $(strip $(HOST_ECHO))
+HOST_ECHO := $(strip $(NDK_HOST_ECHO))
 ifdef HOST_PREBUILT
     ifndef HOST_ECHO
         # Special case, on Cygwin, always use the host echo, not our prebuilt one
@@ -319,7 +328,7 @@
 endif
 $(call ndk_log,Host 'echo -n' tool: $(HOST_ECHO_N))
 
-HOST_CMP := $(strip $(HOST_CMP))
+HOST_CMP := $(strip $(NDK_HOST_CMP))
 ifdef HOST_PREBUILT
     ifndef HOST_CMP
         HOST_CMP := $(strip $(wildcard $(HOST_PREBUILT)/cmp$(HOST_EXEEXT)))
@@ -346,7 +355,7 @@
 AWK_TEST := $(shell $(HOST_AWK) -f $(BUILD_AWK)/check-awk.awk)
 $(call ndk_log,Host 'awk' test returned: $(AWK_TEST))
 ifneq ($(AWK_TEST),Pass)
-    $(call __ndk_info,Host 'awk' tool is outdated. Please define HOST_AWK to point to Gawk or Nawk !)
+    $(call __ndk_info,Host 'awk' tool is outdated. Please define NDK_HOST_AWK to point to Gawk or Nawk !)
     $(call __ndk_error,Aborting.)
 endif
 
diff --git a/build/tools/package-release.sh b/build/tools/package-release.sh
index 5fc1d61..5899506 100755
--- a/build/tools/package-release.sh
+++ b/build/tools/package-release.sh
@@ -248,17 +248,24 @@
 # ensure that the generated files are ug+rx
 umask 0022
 
-# Unpack a prebuilt into the destination directory ($DSTDIR)
+# Unpack a prebuilt into the default destination directory $DSTDIR
+# Also unpack 64-bit version if exists
 # $1: prebuilt name, relative to $PREBUILT_DIR
 # $2: optional, destination directory
 unpack_prebuilt ()
 {
-    local PREBUILT=$1
+    local PREBUILT=${1}.tar.bz2
+    local PREBUILT64=${1}_64.tar.bz2
     local DDIR="${2:-$DSTDIR}"
     echo "Unpacking $PREBUILT"
     if [ -f "$PREBUILT_DIR/$PREBUILT" ] ; then
         unpack_archive "$PREBUILT_DIR/$PREBUILT" "$DDIR"
         fail_panic "Could not unpack prebuilt $PREBUILT. Aborting."
+        if [ -f "$PREBUILT_DIR/$PREBUILT64" ] ; then
+            echo "Unpacking $PREBUILT64"
+            unpack_archive "$PREBUILT_DIR/$PREBUILT64" "$DDIR"
+            fail_panic "Could not unpack prebuilt $PREBUILT64. Aborting."
+        fi
     else
         echo "WARNING: Could not find $PREBUILT in $PREBUILT_DIR"
     fi
@@ -340,17 +347,17 @@
 if [ -z "$PREBUILT_NDK" ]; then
     # Unpack gdbserver
     for ARCH in $ARCHS; do
-        unpack_prebuilt $ARCH-gdbserver.tar.bz2 "$REFERENCE"
+        unpack_prebuilt $ARCH-gdbserver "$REFERENCE"
     done
     # Unpack C++ runtimes
     for VERSION in $DEFAULT_GCC_VERSION_LIST; do
-        unpack_prebuilt gnu-libstdc++-headers-$VERSION.tar.bz2 "$REFERENCE"
+        unpack_prebuilt gnu-libstdc++-headers-$VERSION "$REFERENCE"
     done
     for ABI in $ABIS; do
-        unpack_prebuilt gabixx-libs-$ABI.tar.bz2 "$REFERENCE"
-        unpack_prebuilt stlport-libs-$ABI.tar.bz2 "$REFERENCE"
+        unpack_prebuilt gabixx-libs-$ABI "$REFERENCE"
+        unpack_prebuilt stlport-libs-$ABI "$REFERENCE"
         for VERSION in $DEFAULT_GCC_VERSION_LIST; do
-            unpack_prebuilt gnu-libstdc++-libs-$VERSION-$ABI.tar.bz2 "$REFERENCE"
+            unpack_prebuilt gnu-libstdc++-libs-$VERSION-$ABI "$REFERENCE"
         done
     done
 fi
@@ -404,26 +411,27 @@
             done
         done
     else
-        # Unpack gdbserver
+        # Unpack toolchains
         for TC in $TOOLCHAINS; do
-            unpack_prebuilt $TC-$SYSTEM.tar.bz2
+            unpack_prebuilt $TC-$SYSTEM
             echo "Removing sysroot for $TC"
             rm -rf $DSTDIR/toolchains/$TC/prebuilt/$SYSTEM/sysroot
+            rm -rf $DSTDIR/toolchains/$TC/prebuilt/${SYSTEM}_64/sysroot
         done
 
         # Unpack llvm and clang
         for LLVM_VERSION in $LLVM_VERSION_LIST; do
-            unpack_prebuilt llvm-$LLVM_VERSION-$SYSTEM.tar.bz2
+            unpack_prebuilt llvm-$LLVM_VERSION-$SYSTEM
         done
 
         # Unpack prebuilt ndk-stack and other host tools
-        unpack_prebuilt ndk-stack-$SYSTEM.tar.bz2
-        unpack_prebuilt ndk-make-$SYSTEM.tar.bz2
-        unpack_prebuilt ndk-sed-$SYSTEM.tar.bz2
-        unpack_prebuilt ndk-awk-$SYSTEM.tar.bz2
+        unpack_prebuilt ndk-stack-$SYSTEM
+        unpack_prebuilt ndk-make-$SYSTEM
+        unpack_prebuilt ndk-sed-$SYSTEM
+        unpack_prebuilt ndk-awk-$SYSTEM
 
         if [ "$SYSTEM" = "windows" ]; then
-            unpack_prebuilt toolbox-$SYSTEM.tar.bz2
+            unpack_prebuilt toolbox-$SYSTEM
         fi
     fi
 
diff --git a/docs/NDK-BUILD.html b/docs/NDK-BUILD.html
index 5376fe9..d2f7786 100644
--- a/docs/NDK-BUILD.html
+++ b/docs/NDK-BUILD.html
@@ -97,7 +97,7 @@
 
 
 V. Requirements:
------------------
+----------------
 
 You need GNU Make 3.81 or later to use 'ndk-build' or the NDK in general.
 The build scripts will detect that you're using a non-compliant Make tool
@@ -116,6 +116,15 @@
 
 Adapt to your shell and GNU Make 3.81 installation location.
 
+You may override other host prebuilt tools in $NDK/prebuilt/&lt;OS&gt;/bin
+with the following environment variables
+
+    NDK_HOST_AWK=&lt;path-to-awk&gt;
+
+    NDK_HOST_ECHO=&lt;path-to-echo&gt;
+
+    NDK_HOST_CMP=&lt;path-to-cmp&gt;
+
 
 VI. Internals:
 --------------
diff --git a/toolchains/arm-linux-androideabi-4.4.3/setup.mk b/toolchains/arm-linux-androideabi-4.4.3/setup.mk
index 80302e7..01cfdb8 100644
--- a/toolchains/arm-linux-androideabi-4.4.3/setup.mk
+++ b/toolchains/arm-linux-androideabi-4.4.3/setup.mk
@@ -29,7 +29,7 @@
     -funwind-tables \
     -fstack-protector \
     -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ \
-    -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ \
+    -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__
 
 TARGET_LDFLAGS :=
 
@@ -52,6 +52,8 @@
 TARGET_CFLAGS.neon := -mfpu=neon
 
 TARGET_arm_release_CFLAGS :=  -O2 \
+                              -g \
+                              -DNDEBUG \
                               -fomit-frame-pointer \
                               -fstrict-aliasing    \
                               -funswitch-loops     \
@@ -59,16 +61,22 @@
 
 TARGET_thumb_release_CFLAGS := -mthumb \
                                -Os \
+                               -g \
+                               -DNDEBUG \
                                -fomit-frame-pointer \
                                -fno-strict-aliasing \
                                -finline-limit=64
 
 # When building for debug, compile everything as arm.
 TARGET_arm_debug_CFLAGS := $(TARGET_arm_release_CFLAGS) \
+                           -O0 \
+                           -UNDEBUG \
                            -fno-omit-frame-pointer \
                            -fno-strict-aliasing
 
 TARGET_thumb_debug_CFLAGS := $(TARGET_thumb_release_CFLAGS) \
+                             -O0 \
+                             -UNDEBUG \
                              -marm \
                              -fno-omit-frame-pointer
 
diff --git a/toolchains/arm-linux-androideabi-4.6/setup.mk b/toolchains/arm-linux-androideabi-4.6/setup.mk
index 6c9d516..3c2f017 100644
--- a/toolchains/arm-linux-androideabi-4.6/setup.mk
+++ b/toolchains/arm-linux-androideabi-4.6/setup.mk
@@ -29,7 +29,7 @@
     -funwind-tables \
     -fstack-protector \
     -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ \
-    -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ \
+    -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__
 
 TARGET_LDFLAGS :=
 
@@ -52,6 +52,8 @@
 TARGET_CFLAGS.neon := -mfpu=neon
 
 TARGET_arm_release_CFLAGS :=  -O2 \
+                              -g \
+                              -DNDEBUG \
                               -fomit-frame-pointer \
                               -fstrict-aliasing    \
                               -funswitch-loops     \
@@ -59,16 +61,22 @@
 
 TARGET_thumb_release_CFLAGS := -mthumb \
                                -Os \
+                               -g \
+                               -DNDEBUG \
                                -fomit-frame-pointer \
                                -fno-strict-aliasing \
                                -finline-limit=64
 
 # When building for debug, compile everything as arm.
 TARGET_arm_debug_CFLAGS := $(TARGET_arm_release_CFLAGS) \
+                           -O0 \
+                           -UNDEBUG \
                            -fno-omit-frame-pointer \
                            -fno-strict-aliasing
 
 TARGET_thumb_debug_CFLAGS := $(TARGET_thumb_release_CFLAGS) \
+                             -O0 \
+                             -UNDEBUG \
                              -marm \
                              -fno-omit-frame-pointer
 
diff --git a/toolchains/arm-linux-androideabi-4.7/setup.mk b/toolchains/arm-linux-androideabi-4.7/setup.mk
index bd756af..aaa1f08 100644
--- a/toolchains/arm-linux-androideabi-4.7/setup.mk
+++ b/toolchains/arm-linux-androideabi-4.7/setup.mk
@@ -29,7 +29,7 @@
     -funwind-tables \
     -fstack-protector \
     -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ \
-    -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ \
+    -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__
 
 TARGET_LDFLAGS :=
 
@@ -52,6 +52,8 @@
 TARGET_CFLAGS.neon := -mfpu=neon
 
 TARGET_arm_release_CFLAGS :=  -O2 \
+                              -g \
+                              -DNDEBUG \
                               -fomit-frame-pointer \
                               -fstrict-aliasing    \
                               -funswitch-loops     \
@@ -59,16 +61,22 @@
 
 TARGET_thumb_release_CFLAGS := -mthumb \
                                -Os \
+                               -g \
+                               -DNDEBUG \
                                -fomit-frame-pointer \
                                -fno-strict-aliasing \
                                -finline-limit=64
 
 # When building for debug, compile everything as arm.
 TARGET_arm_debug_CFLAGS := $(TARGET_arm_release_CFLAGS) \
+                           -O0 \
+                           -UNDEBUG \
                            -fno-omit-frame-pointer \
                            -fno-strict-aliasing
 
 TARGET_thumb_debug_CFLAGS := $(TARGET_thumb_release_CFLAGS) \
+                             -O0 \
+                             -UNDEBUG \
                              -marm \
                              -fno-omit-frame-pointer
 
diff --git a/toolchains/arm-linux-androideabi-clang3.1/setup.mk b/toolchains/arm-linux-androideabi-clang3.1/setup.mk
index 482d8f8..282e2ed 100644
--- a/toolchains/arm-linux-androideabi-clang3.1/setup.mk
+++ b/toolchains/arm-linux-androideabi-clang3.1/setup.mk
@@ -85,20 +85,28 @@
 TARGET_CFLAGS.neon := -mfpu=neon
 
 TARGET_arm_release_CFLAGS :=  -O2 \
+                              -g \
+                              -DNDEBUG \
                               -fomit-frame-pointer \
                               -fstrict-aliasing
 
 TARGET_thumb_release_CFLAGS := -mthumb \
                                -Os \
+                               -g \
+                               -DNDEBUG \
                                -fomit-frame-pointer \
                                -fno-strict-aliasing
 
 # When building for debug, compile everything as arm.
 TARGET_arm_debug_CFLAGS := $(TARGET_arm_release_CFLAGS) \
+                           -O0 \
+                           -UNDEBUG \
                            -fno-omit-frame-pointer \
                            -fno-strict-aliasing
 
 TARGET_thumb_debug_CFLAGS := $(TARGET_thumb_release_CFLAGS) \
+                             -O0 \
+                             -UNDEBUG \
                              -marm \
                              -fno-omit-frame-pointer
 
diff --git a/toolchains/mipsel-linux-android-4.4.3/setup.mk b/toolchains/mipsel-linux-android-4.4.3/setup.mk
index 8bf6ed1..38d114d 100644
--- a/toolchains/mipsel-linux-android-4.4.3/setup.mk
+++ b/toolchains/mipsel-linux-android-4.4.3/setup.mk
@@ -40,12 +40,15 @@
 TARGET_C_INCLUDES := \
     $(SYSROOT)/usr/include
 
-TARGET_mips_release_CFLAGS :=  -O2 \
-                               -fomit-frame-pointer \
-                               -funswitch-loops     \
-                               -finline-limit=300
+TARGET_mips_release_CFLAGS := -O2 \
+                              -g \
+                              -DNDEBUG \
+                              -fomit-frame-pointer \
+                              -funswitch-loops     \
+                              -finline-limit=300
 
-TARGET_mips_debug_CFLAGS := -O0 -g \
+TARGET_mips_debug_CFLAGS := -O0 \
+                            -g \
                             -fno-omit-frame-pointer
 
 
diff --git a/toolchains/mipsel-linux-android-4.6/setup.mk b/toolchains/mipsel-linux-android-4.6/setup.mk
index 9a58728..5aa74f9 100644
--- a/toolchains/mipsel-linux-android-4.6/setup.mk
+++ b/toolchains/mipsel-linux-android-4.6/setup.mk
@@ -40,12 +40,15 @@
 TARGET_C_INCLUDES := \
     $(SYSROOT)/usr/include
 
-TARGET_mips_release_CFLAGS :=  -O2 \
-                               -fomit-frame-pointer \
-                               -funswitch-loops     \
-                               -finline-limit=300
+TARGET_mips_release_CFLAGS := -O2 \
+                              -g \
+                              -DNDEBUG \
+                              -fomit-frame-pointer \
+                              -funswitch-loops     \
+                              -finline-limit=300
 
-TARGET_mips_debug_CFLAGS := -O0 -g \
+TARGET_mips_debug_CFLAGS := -O0 \
+                            -g \
                             -fno-omit-frame-pointer
 
 
diff --git a/toolchains/mipsel-linux-android-4.7/setup.mk b/toolchains/mipsel-linux-android-4.7/setup.mk
index e24eda6..6cdc1de 100644
--- a/toolchains/mipsel-linux-android-4.7/setup.mk
+++ b/toolchains/mipsel-linux-android-4.7/setup.mk
@@ -40,12 +40,15 @@
 TARGET_C_INCLUDES := \
     $(SYSROOT)/usr/include
 
-TARGET_mips_release_CFLAGS :=  -O2 \
-                               -fomit-frame-pointer \
-                               -funswitch-loops     \
-                               -finline-limit=300
+TARGET_mips_release_CFLAGS := -O2 \
+                              -g \
+                              -DNDEBUG \
+                              -fomit-frame-pointer \
+                              -funswitch-loops     \
+                              -finline-limit=300
 
-TARGET_mips_debug_CFLAGS := -O0 -g \
+TARGET_mips_debug_CFLAGS := -O0 \
+                            -g \
                             -fno-omit-frame-pointer
 
 
diff --git a/toolchains/mipsel-linux-android-clang3.1/setup.mk b/toolchains/mipsel-linux-android-clang3.1/setup.mk
index 5922a80..b61b38c 100644
--- a/toolchains/mipsel-linux-android-clang3.1/setup.mk
+++ b/toolchains/mipsel-linux-android-clang3.1/setup.mk
@@ -66,9 +66,12 @@
     $(SYSROOT)/usr/include
 
 TARGET_mips_release_CFLAGS := -O2 \
+                              -g \
+                              -DNDEBUG \
                               -fomit-frame-pointer
 
-TARGET_mips_debug_CFLAGS := -O0 -g \
+TARGET_mips_debug_CFLAGS := -O0 \
+                            -g \
                             -fno-omit-frame-pointer
 
 
diff --git a/toolchains/x86-4.4.3/setup.mk b/toolchains/x86-4.4.3/setup.mk
index 8280589..6de857e 100644
--- a/toolchains/x86-4.4.3/setup.mk
+++ b/toolchains/x86-4.4.3/setup.mk
@@ -38,14 +38,18 @@
 
 TARGET_CFLAGS += -fstack-protector
 
-TARGET_x86_release_CFLAGS :=  -O2 \
-                              -fomit-frame-pointer \
-                              -fstrict-aliasing    \
-                              -funswitch-loops     \
-                              -finline-limit=300
+TARGET_x86_release_CFLAGS := -O2 \
+                             -g \
+                             -DNDEBUG \
+                             -fomit-frame-pointer \
+                             -fstrict-aliasing    \
+                             -funswitch-loops     \
+                             -finline-limit=300
 
 # When building for debug, compile everything as x86.
 TARGET_x86_debug_CFLAGS := $(TARGET_x86_release_CFLAGS) \
+                           -O0 \
+                           -UNDEBUG \
                            -fno-omit-frame-pointer \
                            -fno-strict-aliasing
 
diff --git a/toolchains/x86-4.6/setup.mk b/toolchains/x86-4.6/setup.mk
index 05c9b27..4b9b53f 100644
--- a/toolchains/x86-4.6/setup.mk
+++ b/toolchains/x86-4.6/setup.mk
@@ -38,14 +38,18 @@
 
 TARGET_CFLAGS += -fstack-protector
 
-TARGET_x86_release_CFLAGS :=  -O2 \
-                              -fomit-frame-pointer \
-                              -fstrict-aliasing    \
-                              -funswitch-loops     \
-                              -finline-limit=300
+TARGET_x86_release_CFLAGS := -O2 \
+                             -g \
+                             -DNDEBUG \
+                             -fomit-frame-pointer \
+                             -fstrict-aliasing    \
+                             -funswitch-loops     \
+                             -finline-limit=300
 
 # When building for debug, compile everything as x86.
 TARGET_x86_debug_CFLAGS := $(TARGET_x86_release_CFLAGS) \
+                           -O0 \
+                           -UNDEBUG \
                            -fno-omit-frame-pointer \
                            -fno-strict-aliasing
 
diff --git a/toolchains/x86-4.7/setup.mk b/toolchains/x86-4.7/setup.mk
index 94bd6df..46f2eb7 100644
--- a/toolchains/x86-4.7/setup.mk
+++ b/toolchains/x86-4.7/setup.mk
@@ -38,14 +38,18 @@
 
 TARGET_CFLAGS += -fstack-protector
 
-TARGET_x86_release_CFLAGS :=  -O2 \
-                              -fomit-frame-pointer \
-                              -fstrict-aliasing    \
-                              -funswitch-loops     \
-                              -finline-limit=300
+TARGET_x86_release_CFLAGS := -O2 \
+                             -g \
+                             -DNDEBUG \
+                             -fomit-frame-pointer \
+                             -fstrict-aliasing    \
+                             -funswitch-loops     \
+                             -finline-limit=300
 
 # When building for debug, compile everything as x86.
 TARGET_x86_debug_CFLAGS := $(TARGET_x86_release_CFLAGS) \
+                           -O0 \
+                           -UNDEBUG \
                            -fno-omit-frame-pointer \
                            -fno-strict-aliasing
 
diff --git a/toolchains/x86-clang3.1/setup.mk b/toolchains/x86-clang3.1/setup.mk
index 602af5f..ccfdbda 100644
--- a/toolchains/x86-clang3.1/setup.mk
+++ b/toolchains/x86-clang3.1/setup.mk
@@ -60,12 +60,16 @@
     -gcc-toolchain $(call host-path,$(TOOLCHAIN_PREBUILT_ROOT)) \
     -target $(LLVM_TRIPLE)
 
-TARGET_x86_release_CFLAGS :=  -O2 \
-                              -fomit-frame-pointer \
-                              -fstrict-aliasing
+TARGET_x86_release_CFLAGS := -O2 \
+                             -g \
+                             -DNDEBUG \
+                             -fomit-frame-pointer \
+                             -fstrict-aliasing
 
 # When building for debug, compile everything as x86.
 TARGET_x86_debug_CFLAGS := $(TARGET_x86_release_CFLAGS) \
+                           -O0 \
+                           -UNDEBUG \
                            -fno-omit-frame-pointer \
                            -fno-strict-aliasing