Index: libcxx/CMakeLists.txt =================================================================== --- libcxx/CMakeLists.txt +++ libcxx/CMakeLists.txt @@ -648,6 +648,9 @@ # functions never throw a C++ exception. target_add_compile_flags_if_supported(${target} PUBLIC -EHsc) else() + if (LIBCXX_TARGETING_MSVC) + target_compile_definitions(${target} PUBLIC -D_HAS_EXCEPTIONS=0) + endif() target_add_compile_flags_if_supported(${target} PUBLIC -EHs- -EHa-) target_add_compile_flags_if_supported(${target} PUBLIC -fno-exceptions) endif() Index: libcxx/include/__format/format_error.h =================================================================== --- libcxx/include/__format/format_error.h +++ libcxx/include/__format/format_error.h @@ -28,6 +28,7 @@ #if _LIBCPP_STD_VER > 17 +#ifndef _LIBCPP_NO_EXCEPTIONS class _LIBCPP_EXCEPTION_ABI format_error : public runtime_error { public: _LIBCPP_HIDE_FROM_ABI explicit format_error(const string& __s) @@ -36,6 +37,7 @@ : runtime_error(__s) {} virtual ~format_error() noexcept; }; +#endif _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_format_error(const char* __s) { Index: libcxx/include/filesystem =================================================================== --- libcxx/include/filesystem +++ libcxx/include/filesystem @@ -1683,6 +1683,7 @@ // filesystem_error to work around PR41078. _LIBCPP_AVAILABILITY_FILESYSTEM_POP +#ifndef _LIBCPP_NO_EXCEPTIONS class _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_EXCEPTION_ABI filesystem_error : public system_error { public: _LIBCPP_INLINE_VISIBILITY @@ -1734,6 +1735,7 @@ }; shared_ptr<_Storage> __storage_; }; +#endif _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH Index: libcxx/include/future =================================================================== --- libcxx/include/future +++ libcxx/include/future @@ -500,6 +500,7 @@ return error_condition(static_cast(__e), future_category()); } +#ifndef _LIBCPP_NO_EXCEPTIONS class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_FUTURE_ERROR future_error : public logic_error { @@ -513,6 +514,7 @@ future_error(const future_error&) _NOEXCEPT = default; virtual ~future_error() _NOEXCEPT; }; +#endif _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY #ifndef _LIBCPP_NO_EXCEPTIONS @@ -1340,10 +1342,12 @@ { if (__state_) { +#ifndef _LIBCPP_NO_EXCEPTIONS if (!__state_->__has_value() && __state_->use_count() > 1) __state_->set_exception(make_exception_ptr( future_error(make_error_code(future_errc::broken_promise)) )); +#endif // _LIBCPP_NO_EXCEPTIONS __state_->__release_shared(); } } @@ -1483,10 +1487,12 @@ { if (__state_) { +#ifndef _LIBCPP_NO_EXCEPTIONS if (!__state_->__has_value() && __state_->use_count() > 1) __state_->set_exception(make_exception_ptr( future_error(make_error_code(future_errc::broken_promise)) )); +#endif // _LIBCPP_NO_EXCEPTIONS __state_->__release_shared(); } } Index: libcxx/include/ios =================================================================== --- libcxx/include/ios +++ libcxx/include/ios @@ -425,6 +425,7 @@ return error_condition(static_cast(__e), iostream_category()); } +#ifndef _LIBCPP_NO_EXCEPTIONS class _LIBCPP_EXCEPTION_ABI ios_base::failure : public system_error { @@ -434,6 +435,7 @@ failure(const failure&) _NOEXCEPT = default; virtual ~failure() _NOEXCEPT; }; +#endif _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY void __throw_failure(char const* __msg) { Index: libcxx/include/regex =================================================================== --- libcxx/include/regex +++ libcxx/include/regex @@ -980,6 +980,7 @@ } // regex_constants +#ifndef _LIBCPP_NO_EXCEPTIONS class _LIBCPP_EXCEPTION_ABI regex_error : public runtime_error { @@ -991,6 +992,7 @@ _LIBCPP_INLINE_VISIBILITY regex_constants::error_type code() const {return __code_;} }; +#endif template _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY Index: libcxx/include/stdexcept =================================================================== --- libcxx/include/stdexcept +++ libcxx/include/stdexcept @@ -73,6 +73,7 @@ namespace std // purposefully not using versioning namespace { +#ifndef _LIBCPP_NO_EXCEPTIONS class _LIBCPP_EXCEPTION_ABI logic_error : public exception { @@ -208,6 +209,7 @@ virtual ~underflow_error() _NOEXCEPT; #endif }; +#endif // _LIBCPP_NO_EXCEPTIONS } // std Index: libcxx/include/system_error =================================================================== --- libcxx/include/system_error +++ libcxx/include/system_error @@ -459,6 +459,7 @@ // system_error +#ifndef _LIBCPP_NO_EXCEPTIONS class _LIBCPP_TYPE_VIS system_error : public runtime_error { @@ -479,6 +480,7 @@ private: static string __init(const error_code&, string); }; +#endif _LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_system_error(int ev, const char* what_arg); Index: libcxx/src/filesystem/operations.cpp =================================================================== --- libcxx/src/filesystem/operations.cpp +++ libcxx/src/filesystem/operations.cpp @@ -665,6 +665,7 @@ #endif // CLOCK_REALTIME } +#ifndef _LIBCPP_NO_EXCEPTIONS filesystem_error::~filesystem_error() {} void filesystem_error::__create_what(int __num_paths) { @@ -683,6 +684,7 @@ _LIBCPP_UNREACHABLE(); }(); } +#endif static path __do_absolute(const path& p, path* cwd, error_code* ec) { if (ec) Index: libcxx/src/format.cpp =================================================================== --- libcxx/src/format.cpp +++ libcxx/src/format.cpp @@ -12,8 +12,12 @@ #if _LIBCPP_STD_VER > 17 +#ifndef _LIBCPP_NO_EXCEPTIONS + format_error::~format_error() noexcept = default; -#endif //_LIBCPP_STD_VER > 17 +#endif // _LIBCPP_NO_EXCEPTIONS + +#endif // _LIBCPP_STD_VER > 17 _LIBCPP_END_NAMESPACE_STD Index: libcxx/src/future.cpp =================================================================== --- libcxx/src/future.cpp +++ libcxx/src/future.cpp @@ -71,6 +71,7 @@ return __f; } +#ifndef _LIBCPP_NO_EXCEPTIONS future_error::future_error(error_code __ec) : logic_error(__ec.message()), __ec_(__ec) @@ -80,6 +81,7 @@ future_error::~future_error() noexcept { } +#endif // _LIBCPP_NO_EXCEPTIONS void __assoc_sub_state::__on_zero_shared() noexcept Index: libcxx/src/ios.cpp =================================================================== --- libcxx/src/ios.cpp +++ libcxx/src/ios.cpp @@ -58,6 +58,8 @@ // ios_base::failure +#ifndef _LIBCPP_NO_EXCEPTIONS + ios_base::failure::failure(const string& msg, const error_code& ec) : system_error(ec, msg) { @@ -72,6 +74,8 @@ { } +#endif // _LIBCPP_NO_EXCEPTIONS + // ios_base locale const ios_base::fmtflags ios_base::boolalpha; Index: libcxx/src/optional.cpp =================================================================== --- libcxx/src/optional.cpp +++ libcxx/src/optional.cpp @@ -27,6 +27,7 @@ // Even though it no longer exists in a header file _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL +#ifndef _LIBCPP_NO_EXCEPTIONS class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optional_access : public std::logic_error { @@ -38,5 +39,6 @@ }; bad_optional_access::~bad_optional_access() noexcept = default; +#endif // _LIBCPP_NO_EXCEPTIONS _LIBCPP_END_NAMESPACE_EXPERIMENTAL Index: libcxx/src/regex.cpp =================================================================== --- libcxx/src/regex.cpp +++ libcxx/src/regex.cpp @@ -12,6 +12,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD +#ifndef _LIBCPP_NO_EXCEPTIONS + static const char* make_error_type_string(regex_constants::error_type ecode) @@ -68,6 +70,8 @@ regex_error::~regex_error() throw() {} +#endif // _LIBCPP_NO_EXCEPTIONS + namespace { struct collationnames Index: libcxx/src/string.cpp =================================================================== --- libcxx/src/string.cpp +++ libcxx/src/string.cpp @@ -50,13 +50,17 @@ inline void throw_from_string_out_of_range( const string& func ) { +#ifndef _LIBCPP_NO_EXCEPTIONS throw_helper(func + ": out of range"); +#endif } inline void throw_from_string_invalid_arg( const string& func ) { +#ifndef _LIBCPP_NO_EXCEPTIONS throw_helper(func + ": no conversion"); +#endif } // as_integer Index: libcxx/src/support/runtime/stdexcept_default.ipp =================================================================== --- libcxx/src/support/runtime/stdexcept_default.ipp +++ libcxx/src/support/runtime/stdexcept_default.ipp @@ -19,6 +19,8 @@ namespace std // purposefully not using versioning namespace { +#ifndef _LIBCPP_NO_EXCEPTIONS + logic_error::logic_error(const string& msg) : __imp_(msg.c_str()) {} logic_error::logic_error(const char* msg) : __imp_(msg) {} @@ -59,6 +61,8 @@ overflow_error::~overflow_error() noexcept {} underflow_error::~underflow_error() noexcept {} -#endif +#endif // !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX) + +#endif // _LIBCPP_NO_EXCEPTIONS } // namespace std Index: libcxx/src/system_error.cpp =================================================================== --- libcxx/src/system_error.cpp +++ libcxx/src/system_error.cpp @@ -228,6 +228,8 @@ // system_error +#ifndef _LIBCPP_NO_EXCEPTIONS + string system_error::__init(const error_code& ec, string what_arg) { @@ -280,6 +282,8 @@ { } +#endif // _LIBCPP_NO_EXCEPTIONS + void __throw_system_error(int ev, const char* what_arg) { Index: libcxx/utils/ci/buildkite-pipeline.yml =================================================================== --- libcxx/utils/ci/buildkite-pipeline.yml +++ libcxx/utils/ci/buildkite-pipeline.yml @@ -450,6 +450,17 @@ - exit_status: -1 # Agent was lost limit: 2 + - label: "Windows -EHs- -EHa-" + command: "bash libcxx/utils/ci/run-buildbot windows-noexceptions" + artifact_paths: + - "**/test-results.xml" + agents: + queue: "windows" + retry: + automatic: + - exit_status: -1 # Agent was lost + limit: 2 + - label: "32 bit" command: "libcxx/utils/ci/run-buildbot generic-32bit" artifact_paths: Index: libcxx/utils/ci/run-buildbot =================================================================== --- libcxx/utils/ci/run-buildbot +++ libcxx/utils/ci/run-buildbot @@ -546,6 +546,12 @@ echo "+++ Running the libc++ tests" ${NINJA} -vC "${BUILD_DIR}" check-cxx ;; +windows-noexceptions) + clean + generate-cmake-libcxx-win -DLIBCXX_ENABLE_EXCEPTIONS=OFF -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF + echo "+++ Running the libc++ tests" + ${NINJA} -vC "${BUILD_DIR}" check-cxx +;; ################################################################# # Insert vendor-specific internal configurations below. # Index: libcxxabi/src/stdlib_stdexcept.cpp =================================================================== --- libcxxabi/src/stdlib_stdexcept.cpp +++ libcxxabi/src/stdlib_stdexcept.cpp @@ -21,6 +21,8 @@ namespace std // purposefully not using versioning namespace { +#ifndef _LIBCPP_NO_EXCEPTIONS + logic_error::~logic_error() noexcept {} const char* @@ -46,4 +48,6 @@ overflow_error::~overflow_error() noexcept {} underflow_error::~underflow_error() noexcept {} +#endif // _LIBCPP_NO_EXCEPTIONS + } // std