[libcxx] [llvm] [libc++][CI] Tests the no RTTI configuration. (PR #65518)
Mark de Wever via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 24 10:49:51 PST 2023
https://github.com/mordante updated https://github.com/llvm/llvm-project/pull/65518
>From 1be6dfe103b3a01236696f62d27ec8f9f1b08f36 Mon Sep 17 00:00:00 2001
From: Mark de Wever <koraq at xs4all.nl>
Date: Wed, 6 Sep 2023 20:59:55 +0200
Subject: [PATCH] [libc++][CI] Tests the no RTTI configuration.
There are a few drive-by fixes:
- Since the combination RTTI disabled and exceptions enabled do not
work, this combination is prohibited.
- A small NFC in any fixing clang-tidy.
The code in the Buildkite configuration is prepared for using the std
module. There are more fixes needed for that configuration which will be
done in a separate commit.
---
.github/workflows/libcxx-build-and-test.yaml | 1 +
libcxx/CMakeLists.txt | 9 ++++++++-
libcxx/cmake/caches/Generic-no-rtti.cmake | 4 ++++
libcxx/docs/BuildingLibcxx.rst | 1 +
libcxx/include/any | 4 +---
libcxx/utils/ci/run-buildbot | 5 +++++
6 files changed, 20 insertions(+), 4 deletions(-)
create mode 100644 libcxx/cmake/caches/Generic-no-rtti.cmake
diff --git a/.github/workflows/libcxx-build-and-test.yaml b/.github/workflows/libcxx-build-and-test.yaml
index dccfe54d4646767..2f7458fe9db4338 100644
--- a/.github/workflows/libcxx-build-and-test.yaml
+++ b/.github/workflows/libcxx-build-and-test.yaml
@@ -156,6 +156,7 @@ jobs:
'generic-no-tzdb',
'generic-no-unicode',
'generic-no-wide-characters',
+ 'generic-no-rtti',
'generic-static',
'generic-with_llvm_unwinder'
]
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 843ccbd0ed92edb..77384f526b22282 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -284,7 +284,9 @@ endif()
# Feature options -------------------------------------------------------------
option(LIBCXX_ENABLE_EXCEPTIONS "Use exceptions." ON)
-option(LIBCXX_ENABLE_RTTI "Use run time type information." ON)
+option(LIBCXX_ENABLE_RTTI
+ "Use run time type information.
+ This option may only be set to OFF when LIBCXX_ENABLE_EXCEPTIONS=OFF." ON)
option(LIBCXX_ENABLE_THREADS "Build libc++ with support for threads." ON)
option(LIBCXX_ENABLE_MONOTONIC_CLOCK
"Build libc++ with support for a monotonic clock.
@@ -374,6 +376,11 @@ if (LIBCXX_HAS_PTHREAD_API)
endif()
endif()
+if (NOT LIBCXX_ENABLE_RTTI AND LIBCXX_ENABLE_EXCEPTIONS)
+ message(FATAL_ERROR "The option LIBCXX_ENABLE_RTTI can not be turned off"
+ " when LIBCXX_ENABLE_EXCEPTIONS is turned on.")
+endif()
+
# Ensure LLVM_USE_SANITIZER is not specified when LIBCXX_GENERATE_COVERAGE
# is ON.
if (LLVM_USE_SANITIZER AND LIBCXX_GENERATE_COVERAGE)
diff --git a/libcxx/cmake/caches/Generic-no-rtti.cmake b/libcxx/cmake/caches/Generic-no-rtti.cmake
new file mode 100644
index 000000000000000..c62ddcec90149b4
--- /dev/null
+++ b/libcxx/cmake/caches/Generic-no-rtti.cmake
@@ -0,0 +1,4 @@
+set(LIBCXX_ENABLE_RTTI OFF CACHE BOOL "")
+set(LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
+set(LIBCXXABI_ENABLE_RTTI OFF CACHE BOOL "")
+set(LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
diff --git a/libcxx/docs/BuildingLibcxx.rst b/libcxx/docs/BuildingLibcxx.rst
index 2cee97c03ced089..0b4d42052865121 100644
--- a/libcxx/docs/BuildingLibcxx.rst
+++ b/libcxx/docs/BuildingLibcxx.rst
@@ -369,6 +369,7 @@ libc++ Feature Options
**Default**: ``ON``
Build libc++ with run time type information.
+ This option may only be set to OFF when LIBCXX_ENABLE_EXCEPTIONS=OFF.
.. option:: LIBCXX_INCLUDE_TESTS:BOOL
diff --git a/libcxx/include/any b/libcxx/include/any
index 86dd43cf80764ab..c35353906a4091c 100644
--- a/libcxx/include/any
+++ b/libcxx/include/any
@@ -194,9 +194,7 @@ namespace __any_imp
if (__id && *__id == typeid(_Tp))
return true;
#endif
- if (!__id && __fallback_id == __any_imp::__get_fallback_typeid<_Tp>())
- return true;
- return false;
+ return !__id && __fallback_id == __any_imp::__get_fallback_typeid<_Tp>();
}
template <class _Tp>
diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index 58c4c2a1021b600..864eb84d1492905 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -472,6 +472,11 @@ generic-no-exceptions)
check-runtimes
check-abi-list
;;
+generic-no-rtti)
+ clean
+ generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-rtti.cmake"
+ check-runtimes
+;;
#
# Other miscellaneous jobs
#
More information about the llvm-commits
mailing list