Work around the fact that Linux and Mac OS have opposite requirements for libgtest.

This should let us keep the working Mac build without breaking the Linux build!

Change-Id: I2ec44b7043c8ac9be49f0068d9eb7e18e9c88c7d
diff --git a/build/Android.common.mk b/build/Android.common.mk
index 7c53206..a404231 100644
--- a/build/Android.common.mk
+++ b/build/Android.common.mk
@@ -72,7 +72,7 @@
 
 ifneq ($(HOST_OS),linux)
   # Some Mac OS pthread header files are broken with -fkeep-inline-functions.
-  ART_HOST_DEBUG_CFLAGS := $(filter-out -fkeep-inline-functions,)
+  ART_HOST_DEBUG_CFLAGS := $(filter-out -fkeep-inline-functions,$(ART_HOST_DEBUG_CFLAGS))
 endif
 
 ART_TARGET_DEBUG_CFLAGS := $(art_debug_cflags)
diff --git a/build/Android.gtest.mk b/build/Android.gtest.mk
index 6425209..1efb030 100644
--- a/build/Android.gtest.mk
+++ b/build/Android.gtest.mk
@@ -57,6 +57,11 @@
     LOCAL_CFLAGS := $(ART_HOST_CFLAGS) $(ART_HOST_DEBUG_CFLAGS)
     LOCAL_SHARED_LIBRARIES += libicuuc-host libicui18n-host libnativehelper libz-host
     LOCAL_WHOLE_STATIC_LIBRARIES := libgtest_host libgtest_main_host
+    ifeq ($(HOST_OS),linux)
+      # glibc complains about double frees if you include both, but Mac OS
+      # complains about unresolved symbols if you don't!
+      LOCAL_WHOLE_STATIC_LIBRARIES := $(filter-out libgtest_host,$(LOCAL_WHOLE_STATIC_LIBRARIES))
+    endif
     include $(BUILD_HOST_EXECUTABLE)
     art_gtest_exe := $(HOST_OUT_EXECUTABLES)/$$(LOCAL_MODULE)
     ART_HOST_TEST_EXECUTABLES += $$(art_gtest_exe)