Merge "Correct the size of _Unwind_Exception."
diff --git a/build/core/setup-toolchain.mk b/build/core/setup-toolchain.mk
index 685c0bd..fe4ba7e 100644
--- a/build/core/setup-toolchain.mk
+++ b/build/core/setup-toolchain.mk
@@ -68,7 +68,7 @@
         TARGET_TOOLCHAIN_BASE := $(subst $(space),-,$(call chop,$(subst -,$(space),$(TARGET_TOOLCHAIN))))
         # if TARGET_TOOLCHAIN_BASE is llvm, remove clang from NDK_TOOLCHAIN_VERSION
         ifeq ($(TARGET_TOOLCHAIN_BASE),llvm)
-            NDK_TOOLCHAIN_VERSION := $(subst clang,,$(NDK_TOOLCHAIN_VERSION))
+            override NDK_TOOLCHAIN_VERSION := $(subst clang,,$(NDK_TOOLCHAIN_VERSION))
         endif
         TARGET_TOOLCHAIN := $(TARGET_TOOLCHAIN_BASE)-$(NDK_TOOLCHAIN_VERSION)
         $(call ndk_log,Using target toolchain '$(TARGET_TOOLCHAIN)' for '$(TARGET_ARCH_ABI)' ABI (through NDK_TOOLCHAIN_VERSION))
diff --git a/build/tools/build-llvm.sh b/build/tools/build-llvm.sh
index c6acd3b..6edb9cc 100755
--- a/build/tools/build-llvm.sh
+++ b/build/tools/build-llvm.sh
@@ -155,6 +155,11 @@
 CFLAGS_FOR_BUILD="-O2 -I$TOOLCHAIN_BUILD_PREFIX/include"
 LDFLAGS_FOR_BUILD="-L$TOOLCHAIN_BUILD_PREFIX/lib"
 
+# Eliminate dependency on libgcc_s_sjlj-1.dll and libstdc++-6.dll on cross builds
+if [ "$DARWIN" = "yes" -o "$MINGW" = "yes" ]; then
+    LDFLAGS_FOR_BUILD=$LDFLAGS_FOR_BUILD" -static-libgcc -static-libstdc++"
+fi
+
 CFLAGS="$CFLAGS $CFLAGS_FOR_BUILD $HOST_CFLAGS"
 CXXFLAGS="$CXXFLAGS $CFLAGS_FOR_BUILD $HOST_CFLAGS"  # polly doesn't look at CFLAGS !
 LDFLAGS="$LDFLAGS $LDFLAGS_FOR_BUILD $HOST_LDFLAGS"
diff --git a/sources/cxx-stl/gnu-libstdc++/Android.mk b/sources/cxx-stl/gnu-libstdc++/Android.mk
index 98e1a2d..65c911b 100644
--- a/sources/cxx-stl/gnu-libstdc++/Android.mk
+++ b/sources/cxx-stl/gnu-libstdc++/Android.mk
@@ -9,7 +9,10 @@
   $(if $(filter rtti,$(APP_GNUSTL_FORCE_CPP_FEATURES)),-frtti))
 
 # Include path to export
-gnustl_exported_c_includes := $(LOCAL_PATH)/$(TOOLCHAIN_VERSION)/include $(LOCAL_PATH)/$(TOOLCHAIN_VERSION)/libs/$(TARGET_ARCH_ABI)/include
+gnustl_exported_c_includes := \
+  $(LOCAL_PATH)/$(TOOLCHAIN_VERSION)/include \
+  $(LOCAL_PATH)/$(TOOLCHAIN_VERSION)/libs/$(TARGET_ARCH_ABI)/include \
+  $(LOCAL_PATH)/$(TOOLCHAIN_VERSION)/include/backward
 
 include $(CLEAR_VARS)
 LOCAL_MODULE := gnustl_static
diff --git a/tests/build/issue53404-backward-compatibility/jni/Android.mk b/tests/build/issue53404-backward-compatibility/jni/Android.mk
new file mode 100644
index 0000000..3bbc4f8
--- /dev/null
+++ b/tests/build/issue53404-backward-compatibility/jni/Android.mk
@@ -0,0 +1,7 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := issue53404-backward-compatibility
+LOCAL_SRC_FILES := issue53404-backward-compatibility.cpp
+LOCAL_CFLAGS := -Wno-deprecated
+include $(BUILD_EXECUTABLE)
diff --git a/tests/build/issue53404-backward-compatibility/jni/Application.mk b/tests/build/issue53404-backward-compatibility/jni/Application.mk
new file mode 100644
index 0000000..d736092
--- /dev/null
+++ b/tests/build/issue53404-backward-compatibility/jni/Application.mk
@@ -0,0 +1,2 @@
+APP_ABI := all
+APP_STL := gnustl_static
\ No newline at end of file
diff --git a/tests/build/issue53404-backward-compatibility/jni/issue53404-backward-compatibility.cpp b/tests/build/issue53404-backward-compatibility/jni/issue53404-backward-compatibility.cpp
new file mode 100644
index 0000000..131986d
--- /dev/null
+++ b/tests/build/issue53404-backward-compatibility/jni/issue53404-backward-compatibility.cpp
@@ -0,0 +1,5 @@
+#include <ext/hash_map>
+int main()
+{
+    return 0;
+}