Commit eaca1e4e authored by Louis Dionne's avatar Louis Dionne
Browse files

[libc++] Automatically detect whether RTTI is enabled

Instead of detecting it automatically but also allowing for the setting
to be specified explicitly, always detect whether exceptions are enabled
based on whether -fno-rtti (or equivalent) is used. It's less confusing
to have a single way of tweaking that knob.

This change follows the lead of 71d88ceb.
parent b71ef0c5
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -639,7 +639,6 @@ endfunction()
# RTTI flags ==================================================================
function(cxx_add_rtti_flags target)
  if (NOT LIBCXX_ENABLE_RTTI)
    target_compile_definitions(${target} PUBLIC -D_LIBCPP_NO_RTTI)
    target_add_compile_flags_if_supported(${target} PUBLIC -GR-)
    target_add_compile_flags_if_supported(${target} PUBLIC -fno-rtti)
  endif()
+6 −11
Original line number Diff line number Diff line
@@ -423,10 +423,6 @@ typedef __char32_t char32_t;
#  define _LIBCPP_NO_EXCEPTIONS
#endif

#if !(__has_feature(cxx_rtti)) && !defined(_LIBCPP_NO_RTTI)
#define _LIBCPP_NO_RTTI
#endif

#if !(__has_feature(cxx_strong_enums))
#define _LIBCPP_HAS_NO_STRONG_ENUMS
#endif
@@ -1109,14 +1105,13 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
#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.
#if !defined(_LIBCPP_NO_RTTI)
#  if defined(__GNUC__) && !defined(__GXX_RTTI)
#if defined(_LIBCPP_COMPILER_CLANG) && !__has_feature(cxx_rtti)
#  define _LIBCPP_NO_RTTI
#elif defined(__GNUC__) && !defined(__GXX_RTTI)
#  define _LIBCPP_NO_RTTI
#elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI)
#  define _LIBCPP_NO_RTTI
#endif
#endif

#ifndef _LIBCPP_WEAK
#define _LIBCPP_WEAK __attribute__((__weak__))
+1 −1
Original line number Diff line number Diff line
@@ -410,7 +410,7 @@ class Configuration(object):
        enable_rtti = self.get_lit_bool('enable_rtti', True)
        if not enable_rtti:
            self.config.available_features.add('-fno-rtti')
            self.cxx.compile_flags += ['-fno-rtti', '-D_LIBCPP_NO_RTTI']
            self.cxx.compile_flags += ['-fno-rtti']

    def configure_link_flags(self):
        # Configure library path
+0 −1
Original line number Diff line number Diff line
@@ -102,7 +102,6 @@ config("cxx_config") {
    } else {
      cflags_cc += [ "-fno-rtti" ]
    }
    defines += [ "_LIBCPP_NO_RTTI" ]
  }
}