[llvm] eaca1e4 - [libc++] Automatically detect whether RTTI is enabled
Louis Dionne via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 14 13:51:50 PDT 2020
Author: Louis Dionne
Date: 2020-07-14T16:51:37-04:00
New Revision: eaca1e4e54905815b444e1234096c70adc9812f6
URL: https://github.com/llvm/llvm-project/commit/eaca1e4e54905815b444e1234096c70adc9812f6
DIFF: https://github.com/llvm/llvm-project/commit/eaca1e4e54905815b444e1234096c70adc9812f6.diff
LOG: [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 71d88cebfb42.
Added:
Modified:
libcxx/CMakeLists.txt
libcxx/include/__config
libcxx/utils/libcxx/test/config.py
llvm/utils/gn/secondary/libcxx/src/BUILD.gn
Removed:
################################################################################
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 88dc4553069e..aabe31fa6ec1 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -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()
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 7e4c37431ea4..575147cead42 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -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,13 +1105,12 @@ _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)
-# define _LIBCPP_NO_RTTI
-# elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI)
-# define _LIBCPP_NO_RTTI
-# endif
+#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
#ifndef _LIBCPP_WEAK
diff --git a/libcxx/utils/libcxx/test/config.py b/libcxx/utils/libcxx/test/config.py
index 99a966dbfdfd..b88b085d408f 100644
--- a/libcxx/utils/libcxx/test/config.py
+++ b/libcxx/utils/libcxx/test/config.py
@@ -410,7 +410,7 @@ def configure_compile_flags_rtti(self):
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
diff --git a/llvm/utils/gn/secondary/libcxx/src/BUILD.gn b/llvm/utils/gn/secondary/libcxx/src/BUILD.gn
index 1c52d341ec82..09d850036ad1 100644
--- a/llvm/utils/gn/secondary/libcxx/src/BUILD.gn
+++ b/llvm/utils/gn/secondary/libcxx/src/BUILD.gn
@@ -102,7 +102,6 @@ config("cxx_config") {
} else {
cflags_cc += [ "-fno-rtti" ]
}
- defines += [ "_LIBCPP_NO_RTTI" ]
}
}
More information about the llvm-commits
mailing list