diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index 59d762976462..4d65d2d22af4 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -60,7 +60,7 @@ endif() include(CMakeDependentOption) # Basic options --------------------------------------------------------------- -option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON) +option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." OFF) option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON) option(LIBCXX_ENABLE_STATIC "Build libc++ as a static library." ON) option(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY "Build libc++experimental.a" ON) @@ -501,6 +501,7 @@ endif() # Assertion flags ============================================================= define_if(LIBCXX_ENABLE_ASSERTIONS -UNDEBUG) define_if_not(LIBCXX_ENABLE_ASSERTIONS -DNDEBUG) +define_if(LIBCXX_ENABLE_ASSERTIONS -D_LIBCPP_DEBUG=0) define_if(LIBCXX_DEBUG_BUILD -D_DEBUG) if (LIBCXX_ENABLE_ASSERTIONS AND NOT LIBCXX_DEBUG_BUILD) # MSVC doesn't like _DEBUG on release builds. See PR 4379. diff --git a/libcxx/include/__config b/libcxx/include/__config index 1fedc04d30a5..a70f8f0060fd 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -817,7 +817,9 @@ template struct __static_assert_check {}; # else # error Supported values for _LIBCPP_DEBUG are 0 and 1 # endif +# if !defined(_LIBCPP_BUILDING_LIBRARY) # define _LIBCPP_EXTERN_TEMPLATE(...) +# endif #endif #ifndef _LIBCPP_EXTERN_TEMPLATE diff --git a/libcxx/include/__threading_support b/libcxx/include/__threading_support index d049c9193d98..53a956ed9809 100644 --- a/libcxx/include/__threading_support +++ b/libcxx/include/__threading_support @@ -25,7 +25,6 @@ # include # include #elif defined(_LIBCPP_HAS_THREAD_API_WIN32) -#include #include #include #include diff --git a/libcxx/src/condition_variable.cpp b/libcxx/src/condition_variable.cpp index 25e66038eec0..3f607271b9eb 100644 --- a/libcxx/src/condition_variable.cpp +++ b/libcxx/src/condition_variable.cpp @@ -14,7 +14,6 @@ #include "condition_variable" #include "thread" #include "system_error" -#include "cassert" _LIBCPP_BEGIN_NAMESPACE_STD diff --git a/libcxx/src/experimental/filesystem/path.cpp b/libcxx/src/experimental/filesystem/path.cpp index 96b81f7b0a70..daf2c2bba79f 100644 --- a/libcxx/src/experimental/filesystem/path.cpp +++ b/libcxx/src/experimental/filesystem/path.cpp @@ -6,11 +6,9 @@ // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -#undef NDEBUG #include "experimental/filesystem" #include "string_view" #include "utility" -#include "cassert" namespace { namespace parser { @@ -113,7 +111,6 @@ public: void decrement() noexcept { const PosPtr REnd = &Path.front() - 1; const PosPtr RStart = getCurrentTokenStartPos() - 1; - assert(RStart != REnd); switch (State) { case PS_AtEnd: { @@ -322,7 +319,6 @@ string_view_t path::__root_path_raw() const auto NextCh = PP.peek(); if (NextCh && *NextCh == '/') { ++PP; - assert(PP.State == PathParser::PS_InRootDir); return createView(__pn_.data(), &PP.RawEntry.back()); } return PP.RawEntry; diff --git a/libcxx/src/mutex.cpp b/libcxx/src/mutex.cpp index 338b79f2feb0..b858e8877ae5 100644 --- a/libcxx/src/mutex.cpp +++ b/libcxx/src/mutex.cpp @@ -11,7 +11,6 @@ #include "mutex" #include "limits" #include "system_error" -#include "cassert" #include "include/atomic_support.h" _LIBCPP_BEGIN_NAMESPACE_STD @@ -45,7 +44,7 @@ mutex::unlock() _NOEXCEPT { int ec = __libcpp_mutex_unlock(&__m_); (void)ec; - assert(ec == 0); + _LIBCPP_ASSERT(ec == 0, "call to mutex::unlock failed"); } // recursive_mutex @@ -61,7 +60,7 @@ recursive_mutex::~recursive_mutex() { int e = __libcpp_recursive_mutex_destroy(&__m_); (void)e; - assert(e == 0); + _LIBCPP_ASSERT(e == 0, "call to ~recursive_mutex() failed"); } void @@ -77,7 +76,7 @@ recursive_mutex::unlock() _NOEXCEPT { int e = __libcpp_recursive_mutex_unlock(&__m_); (void)e; - assert(e == 0); + _LIBCPP_ASSERT(e == 0, "call to recursive_mutex::unlock() failed"); } bool diff --git a/libcxx/src/system_error.cpp b/libcxx/src/system_error.cpp index 94114992c13c..cbbbb5dcd15c 100644 --- a/libcxx/src/system_error.cpp +++ b/libcxx/src/system_error.cpp @@ -17,9 +17,9 @@ #include "cstring" #include "cstdio" #include "cstdlib" -#include "cassert" #include "string" #include "string.h" +#include "__debug" #if defined(__ANDROID__) #include @@ -96,7 +96,7 @@ string do_strerror_r(int ev) { std::snprintf(buffer, strerror_buff_size, "Unknown error %d", ev); return string(buffer); } else { - assert(new_errno == ERANGE); + _LIBCPP_ASSERT(new_errno == ERANGE, "unexpected error from ::strerr_r"); // FIXME maybe? 'strerror_buff_size' is likely to exceed the // maximum error size so ERANGE shouldn't be returned. std::abort();