Index: include/__config
===================================================================
--- include/__config	(revision 191369)
+++ include/__config	(working copy)
@@ -79,6 +79,9 @@
 #  endif
 #  if defined(_MSC_VER) && !defined(__clang__)
 #    define _LIBCPP_MSVC // Using Microsoft Visual C++ compiler
+#    define _LIBCPP_TOSTRING2(x) #x
+#    define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
+#    define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
 #  endif
 #  // If mingw not explicitly detected, assume using MS C runtime only.
 #  ifndef __MINGW32__
@@ -431,6 +434,7 @@
 #define _LIBCPP_END_NAMESPACE_STD  }
 #define _VSTD std
 
+#  define _LIBCPP_WEAK
 namespace std {
 }
 
@@ -579,4 +583,20 @@
 #define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit
 #endif
 
+// Try to find out if RTTI is disabled.
+// g++ and cl.exe have RTTI on by default and define a macro when it is.
+// g++ only defines the macro in 4.3.2 and onwards.
+#if !defined(_LIBCPP_NO_RTTI)
+#  if defined(__GNUG__) && (__GNUC__ >= 4 && \
+   (__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2)) && !defined(__GXX_RTTI)
+#    define _LIBCPP_NO_RTTI
+#  elif (defined(_MSC_VER) && !defined(__clang__)) && !defined(_CPPRTTI)
+#    define _LIBCPP_NO_RTTI
+#  endif
+#endif
+
+#if ! defined(_LIBCPP_WEAK)
+#  define _LIBCPP_WEAK __attribute__((__weak__))
+#endif
+
 #endif  // _LIBCPP_CONFIG
Index: src/new.cpp
===================================================================
--- src/new.cpp	(revision 191369)
+++ src/new.cpp	(working copy)
@@ -39,7 +39,7 @@
 // in this shared library, so that they can be overriden by programs
 // that define non-weak copies of the functions.
 
-__attribute__((__weak__, __visibility__("default")))
+_LIBCPP_WEAK
 void *
 operator new(std::size_t size)
 #if !__has_feature(cxx_noexcept)
@@ -66,7 +66,7 @@
     return p;
 }
 
-__attribute__((__weak__, __visibility__("default")))
+_LIBCPP_WEAK
 void*
 operator new(size_t size, const std::nothrow_t&) _NOEXCEPT
 {
@@ -85,7 +85,7 @@
     return p;
 }
 
-__attribute__((__weak__, __visibility__("default")))
+_LIBCPP_WEAK
 void*
 operator new[](size_t size)
 #if !__has_feature(cxx_noexcept)
@@ -95,7 +95,7 @@
     return ::operator new(size);
 }
 
-__attribute__((__weak__, __visibility__("default")))
+_LIBCPP_WEAK
 void*
 operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT
 {
@@ -114,7 +114,7 @@
     return p;
 }
 
-__attribute__((__weak__, __visibility__("default")))
+_LIBCPP_WEAK
 void
 operator delete(void* ptr) _NOEXCEPT
 {
@@ -122,7 +122,7 @@
         ::free(ptr);
 }
 
-__attribute__((__weak__, __visibility__("default")))
+_LIBCPP_WEAK
 void
 operator delete(void* ptr, const std::nothrow_t&) _NOEXCEPT
 {
@@ -129,7 +129,7 @@
     ::operator delete(ptr);
 }
 
-__attribute__((__weak__, __visibility__("default")))
+_LIBCPP_WEAK
 void
 operator delete[] (void* ptr) _NOEXCEPT
 {
@@ -136,7 +136,7 @@
     ::operator delete (ptr);
 }
 
-__attribute__((__weak__, __visibility__("default")))
+_LIBCPP_WEAK
 void
 operator delete[] (void* ptr, const std::nothrow_t&) _NOEXCEPT
 {
