Commit 71d88ceb authored by Louis Dionne's avatar Louis Dionne
Browse files

[libc++/libc++abi] Automatically detect whether exceptions are enabled

Instead of detecting it automatically (in libc++) and relying on
_LIBCXXABI_NO_EXCEPTIONS being set explicitly (in libc++abi), always
detect whether exceptions are enabled automatically.

This commit also removes support for specifying -D_LIBCPP_NO_EXCEPTIONS
and -D_LIBCXXABI_NO_EXCEPTIONS explicitly -- those should just be inferred
from using -fno-exceptions (or an equivalent flag).

Allowing both -D_FOO_NO_EXCEPTIONS to be provided explicitly and trying
to detect it automatically is just confusing, especially since we did
specify it explicitly when building libc++abi. We should have only one
way to detect whether exceptions are enabled, but it should be robust.
parent 35808ab8
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -628,7 +628,6 @@ function(cxx_add_exception_flags target)
    # functions never throw a C++ exception.
    target_add_compile_flags_if_supported(${target} PUBLIC -EHsc)
  else()
    target_compile_definitions(${target} PUBLIC -D_LIBCPP_NO_EXCEPTIONS)
    target_add_compile_flags_if_supported(${target} PUBLIC -EHs- -EHa-)
    target_add_compile_flags_if_supported(${target} PUBLIC -fno-exceptions)
  endif()
+4 −4
Original line number Diff line number Diff line
@@ -419,7 +419,7 @@ typedef __char16_t char16_t;
typedef __char32_t char32_t;
#endif

#if !(__has_feature(cxx_exceptions)) && !defined(_LIBCPP_NO_EXCEPTIONS)
#if !__has_feature(cxx_exceptions)
#  define _LIBCPP_NO_EXCEPTIONS
#endif

@@ -528,7 +528,7 @@ typedef __char32_t char32_t;

#define _LIBCPP_NORETURN __attribute__((noreturn))

#if !__EXCEPTIONS && !defined(_LIBCPP_NO_EXCEPTIONS)
#if !__EXCEPTIONS
#  define _LIBCPP_NO_EXCEPTIONS
#endif

+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@
// When exceptions are disabled, all iterators should get this "fast path"
//

// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_NO_EXCEPTIONS
// ADDITIONAL_COMPILE_FLAGS: -fno-exceptions

#include <iterator>
#include <cassert>
+0 −1
Original line number Diff line number Diff line
@@ -307,7 +307,6 @@ if (LIBCXXABI_ENABLE_EXCEPTIONS)
  # Do we really need to be run through the C compiler ?
  add_c_compile_flags_if_supported(-funwind-tables)
else()
  add_definitions(-D_LIBCXXABI_NO_EXCEPTIONS)
  add_compile_flags_if_supported(-fno-exceptions)
  add_compile_flags_if_supported(-EHs-)
  add_compile_flags_if_supported(-EHa-)
+8 −0
Original line number Diff line number Diff line
@@ -76,4 +76,12 @@
#  define _LIBCXXABI_GUARD_ABI_ARM
#endif

#if defined(_LIBCXXABI_COMPILER_CLANG)
#  if !__has_feature(cxx_exceptions)
#    define _LIBCXXABI_NO_EXCEPTIONS
#  endif
#elif defined(_LIBCXXABI_COMPILER_GCC) && !__EXCEPTIONS
#  define _LIBCXXABI_NO_EXCEPTIONS
#endif

#endif // ____CXXABI_CONFIG_H
Loading