Index: include/__config
===================================================================
--- include/__config	(revision 188035)
+++ include/__config	(working copy)
@@ -407,6 +407,7 @@
 #define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
 #define _LIBCPP_HAS_NO_CONSTEXPR
 #define _LIBCPP_HAS_NO_UNICODE_CHARS
+#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
 #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
 #define __alignof__ __alignof
 #define _LIBCPP_NORETURN __declspec(noreturn)
Index: include/cmath
===================================================================
--- include/cmath	(revision 188035)
+++ include/cmath	(working copy)
@@ -1678,11 +1678,8 @@
 using ::tgammal;
 using ::truncl;
 #endif // !_LIBCPP_MSVCRT
-
-#else 
 using ::lgamma;
 using ::lgammaf;
 #endif // __sun__
 _LIBCPP_END_NAMESPACE_STD
-
 #endif  // _LIBCPP_CMATH
Index: include/support/win32/limits_win32.h
===================================================================
--- include/support/win32/limits_win32.h	(revision 188035)
+++ include/support/win32/limits_win32.h	(working copy)
@@ -15,11 +15,15 @@
 #error "This header complements Microsoft's C Runtime library, and should not be included otherwise."
 #else
 
+#if defined(_MSC_VER)
+
 #ifndef NOMINMAX
 #define NOMINMAX
 #endif
+
+// These are built-in's for clang etc. Provide them for the genuine ms compiler.
+
 #include <windows.h> // ymath.h works correctly
-
 #include <float.h> // limit constants
 
 #define __FLT_MANT_DIG__   FLT_MANT_DIG
@@ -74,6 +78,6 @@
 #define __builtin_nansf(__dummy) _FSnan._Float
 #define __builtin_nansl(__dummy) _LSnan._Long_double
 
+#endif // ! _MSC_VER
 #endif // _LIBCPP_MSVCRT
-
 #endif // _LIBCPP_SUPPORT_WIN32_LIMITS_WIN32_H
Index: include/support/win32/math_win32.h
===================================================================
--- include/support/win32/math_win32.h	(revision 188035)
+++ include/support/win32/math_win32.h	(working copy)
@@ -15,7 +15,8 @@
 #error "This header complements Microsoft's C Runtime library, and should not be included otherwise."
 #else
 
-#include <math.h>
+#if defined(_MSC_VER)
+// These are built-in's for clang etc. Provide them for the genuine ms compiler.
 
 typedef float float_t;
 typedef double double_t;
@@ -107,7 +108,6 @@
 {
     return _fpclass(num);
 }
-
+#endif // _MSC_VER
 #endif // _LIBCPP_MSVCRT
-
 #endif // _LIBCPP_SUPPORT_WIN32_MATH_WIN32_H
Index: include/support/win32/support.h
===================================================================
--- include/support/win32/support.h	(revision 188035)
+++ include/support/win32/support.h	(working copy)
@@ -17,9 +17,12 @@
 
 #include <cwchar>  // mbstate_t
 #include <cstdarg> // va_ macros
-#define swprintf _snwprintf
-#define vswprintf _vsnwprintf
 
+#if defined(_MSC_VER_) && !defined(__clang__)
+#include <xlocinfo.h>
+#include <intrin.h>
+#endif
+
 extern "C" {
 
 int vasprintf( char **sptr, const char *__restrict fmt, va_list ap );
@@ -30,26 +33,16 @@
                    size_t nwc, size_t len, mbstate_t *__restrict ps );
 }
 
-#if defined(_LIBCPP_MSVCRT)
+#if defined(_MSC_VER_) && !defined(__clang__)
+#define swprintf _snwprintf
+#define vswprintf _vsnwprintf
 #define snprintf _snprintf
-#include <xlocinfo.h>
 #define atoll _atoi64
 #define strtoll _strtoi64
 #define strtoull _strtoui64
 #define wcstoll _wcstoi64
 #define wcstoull _wcstoui64
-_LIBCPP_ALWAYS_INLINE float strtof( const char *nptr, char **endptr )
-{ return _Stof(nptr, endptr, 0); }
-_LIBCPP_ALWAYS_INLINE double strtod( const char *nptr, char **endptr )
-{ return _Stod(nptr, endptr, 0); }
-_LIBCPP_ALWAYS_INLINE long double strtold( const char *nptr, char **endptr )
-{ return _Stold(nptr, endptr, 0); }
 
-#define _Exit _exit
-
-#ifndef __clang__ // MSVC-based Clang also defines _MSC_VER
-#include <intrin.h>
-
 _LIBCPP_ALWAYS_INLINE int __builtin_popcount(unsigned int x) {
    static const unsigned int m1 = 0x55555555; //binary: 0101...
    static const unsigned int m2 = 0x33333333; //binary: 00110011..
@@ -108,7 +101,6 @@
     _BitScanForward64(&r, x);
     return static_cast<int>(r);
 }
-#endif // !__clang__
-#endif // _LIBCPP_MSVCRT
+#endif
+#endif // _LIBCPP_SUPPORT_WIN32_SUPPORT_H
 
-#endif // _LIBCPP_SUPPORT_WIN32_SUPPORT_H
Index: src/debug.cpp
===================================================================
--- src/debug.cpp	(revision 188035)
+++ src/debug.cpp	(working copy)
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-#define _LIBCPP_DEBUG2 1
 #include "__config"
 #include "__debug"
 #include "functional"
@@ -17,6 +16,8 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+#if _LIBCPP_DEBUG_LEVEL >= 2
+
 _LIBCPP_FUNC_VIS
 __libcpp_db*
 __get_db()
@@ -503,4 +504,6 @@
         memmove(r, r+1, static_cast<size_t>(end_ - r)*sizeof(__i_node*));
 }
 
+#endif
+
 _LIBCPP_END_NAMESPACE_STD
