Fix using libc++_static in dynamic binaries.

Change-Id: I89bacfbf270d2d1bc1b9b2fa6951b355a67b808c
diff --git a/core/cxx_stl_setup.mk b/core/cxx_stl_setup.mk
index 630fe4e..c59cd34 100644
--- a/core/cxx_stl_setup.mk
+++ b/core/cxx_stl_setup.mk
@@ -50,8 +50,14 @@
     my_cflags += -D_USING_LIBCXX
     my_c_includes += external/libcxx/include
 
+    # Note that the structure of this means that LOCAL_CXX_STL := libc++ will
+    # use the static libc++ for static executables.
     ifeq ($(my_link_type),dynamic)
-        my_shared_libraries += libc++
+        ifeq ($(my_cxx_stl),libc++)
+            my_shared_libraries += libc++
+        else
+            my_static_libraries += libc++_static
+        endif
     else
         my_static_libraries += libc++_static
     endif