Fix compilation issues with new gcc

(cherry picked from commit efad79fa4121e20ab613e31bde44cc3120f23832)

Conflicts:

	src/compiler/codegen/mips/Mips32/Factory.cc
	src/compiler/codegen/x86/X86/Factory.cc

Change-Id: I5e0e9dc48ba76092cccc70b25668978a08a5449b
diff --git a/build/Android.common.mk b/build/Android.common.mk
index 8e0fd51..201d028 100644
--- a/build/Android.common.mk
+++ b/build/Android.common.mk
@@ -95,8 +95,9 @@
 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
+# TODO: move -fkeep-inline-functions to art_debug_cflags when target gcc > 4.4 (and -lsupc++)
 ART_HOST_DEBUG_CFLAGS := $(art_debug_cflags) -fkeep-inline-functions
+ART_HOST_DEBUG_LDLIBS := -lsupc++
 
 ifneq ($(HOST_OS),linux)
   # Some Mac OS pthread header files are broken with -fkeep-inline-functions.
diff --git a/build/Android.libart.mk b/build/Android.libart.mk
index 2683f14..4ca9937 100644
--- a/build/Android.libart.mk
+++ b/build/Android.libart.mk
@@ -83,6 +83,7 @@
       LOCAL_CFLAGS += $(ART_TARGET_DEBUG_CFLAGS)
     else # host
       LOCAL_CFLAGS += $(ART_HOST_DEBUG_CFLAGS)
+      LOCAL_LDLIBS += $(ART_HOST_DEBUG_LDLIBS)
       LOCAL_STATIC_LIBRARIES := libgtest_host
     endif
   else
@@ -109,7 +110,7 @@
     LOCAL_STATIC_LIBRARIES += libcutils
     LOCAL_SHARED_LIBRARIES += libz-host
     LOCAL_SHARED_LIBRARIES += libdynamic_annotations-host # tsan support
-    LOCAL_LDLIBS := -ldl -lpthread
+    LOCAL_LDLIBS += -ldl -lpthread
     ifeq ($(HOST_OS),linux)
       LOCAL_LDLIBS += -lrt
     endif