Always link binaries to libsupc++.a by default.
To make it slightly easier to use exceptions and RTTI.
Change-Id: I340dce19c9613e1e39dca0d1f193c8bb8a605773
diff --git a/tests/device/test-basic-exceptions/jni/Android.mk b/tests/device/test-basic-exceptions/jni/Android.mk
index 5afbbdd..462b9de 100644
--- a/tests/device/test-basic-exceptions/jni/Android.mk
+++ b/tests/device/test-basic-exceptions/jni/Android.mk
@@ -4,5 +4,4 @@
LOCAL_MODULE := test_basic_exceptions
LOCAL_SRC_FILES := test_basic_exceptions.cpp
LOCAL_CPPFLAGS := -fexceptions
-LOCAL_LDLIBS := -lsupc++
include $(BUILD_EXECUTABLE)
diff --git a/tests/device/test-basic-rtti/jni/Android.mk b/tests/device/test-basic-rtti/jni/Android.mk
index e562c87..5664ab5 100644
--- a/tests/device/test-basic-rtti/jni/Android.mk
+++ b/tests/device/test-basic-rtti/jni/Android.mk
@@ -4,5 +4,4 @@
LOCAL_MODULE := test_basic_rtti
LOCAL_SRC_FILES := test_basic_rtti.cpp
LOCAL_CPPFLAGS := -frtti
-LOCAL_LDLIBS := -lsupc++
include $(BUILD_EXECUTABLE)
diff --git a/toolchains/arm-linux-androideabi-4.4.3/setup.mk b/toolchains/arm-linux-androideabi-4.4.3/setup.mk
index 052253d..ce35edd 100644
--- a/toolchains/arm-linux-androideabi-4.4.3/setup.mk
+++ b/toolchains/arm-linux-androideabi-4.4.3/setup.mk
@@ -110,4 +110,39 @@
$(call set-src-files-text,$(__arm_sources),arm$(space)$(space)) \
$(call set-src-files-text,$(__thumb_sources),thumb)
-TARGET_LIBGCC := $(shell $(TARGET_CC) -mthumb-interwork -print-libgcc-file-name)
+#
+# We need to add -lsupc++ to the final link command to make exceptions
+# and RTTI work properly (when -fexceptions and -frtti are used).
+#
+# Normally, the toolchain should be configured to do that automatically,
+# this will be debugged later.
+#
+define cmd-build-shared-library
+$(TARGET_CXX) \
+ -Wl,-soname,$(notdir $@) \
+ -shared \
+ $(call host-path, $(PRIVATE_OBJECTS)) \
+ $(call whole-archive-list-flags,$(PRIVATE_WHOLE_STATIC_LIBRARIES)) \
+ $(call host-path,\
+ $(PRIVATE_STATIC_LIBRARIES) \
+ $(PRIVATE_SHARED_LIBRARIES)) \
+ $(PRIVATE_LDFLAGS) \
+ $(PRIVATE_LDLIBS) \
+ -lsupc++ \
+ -o $(call host-path,$@)
+endef
+
+define cmd-build-executable
+$(TARGET_CC) \
+ -Wl,--gc-sections \
+ -Wl,-z,nocopyreloc \
+ $(call host-path, $(PRIVATE_OBJECTS)) \
+ $(call whole-archive-list-flags,$(PRIVATE_WHOLE_STATIC_LIBRARIES)) \
+ $(call host-path,\
+ $(PRIVATE_STATIC_LIBRARIES) \
+ $(PRIVATE_SHARED_LIBRARIES)) \
+ $(PRIVATE_LDFLAGS) \
+ $(PRIVATE_LDLIBS) \
+ -lsupc++ \
+ -o $(call host-path,$@)
+endef