[libcxx-commits] [libcxx] e666e27 - [libc++] Move compiler-detection Lit features first (#73544)
via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Nov 27 12:53:39 PST 2023
Author: Louis Dionne
Date: 2023-11-27T15:53:35-05:00
New Revision: e666e27485d69ca60747c198418e64922c72238f
URL: https://github.com/llvm/llvm-project/commit/e666e27485d69ca60747c198418e64922c72238f
DIFF: https://github.com/llvm/llvm-project/commit/e666e27485d69ca60747c198418e64922c72238f.diff
LOG: [libc++] Move compiler-detection Lit features first (#73544)
Lit features are evaluated in order. Some checks may require the
compiler detection to have run first in order to work properly, for
example some checks being added in https://reviews.llvm.org/D154246
which require GCC to have been detected. It is kind of brittle to rely
on such ordering, but in practice moving the compiler detection first
should never hurt.
Added:
Modified:
libcxx/utils/libcxx/test/features.py
Removed:
################################################################################
diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py
index e854aed66513806..e1cfa032f1614e8 100644
--- a/libcxx/utils/libcxx/test/features.py
+++ b/libcxx/utils/libcxx/test/features.py
@@ -58,8 +58,66 @@ def _getAndroidDeviceApi(cfg):
)
)
-
+# Lit features are evaluated in order. Some checks may require the compiler detection to have
+# run first in order to work properly.
DEFAULT_FEATURES = [
+ Feature(name="apple-clang", when=_isAppleClang),
+ Feature(
+ name=lambda cfg: "apple-clang-{__clang_major__}".format(**compilerMacros(cfg)),
+ when=_isAppleClang,
+ ),
+ Feature(
+ name=lambda cfg: "apple-clang-{__clang_major__}.{__clang_minor__}".format(**compilerMacros(cfg)),
+ when=_isAppleClang,
+ ),
+ Feature(
+ name=lambda cfg: "apple-clang-{__clang_major__}.{__clang_minor__}.{__clang_patchlevel__}".format(**compilerMacros(cfg)),
+ when=_isAppleClang,
+ ),
+ Feature(name="clang", when=_isClang),
+ Feature(
+ name=lambda cfg: "clang-{__clang_major__}".format(**compilerMacros(cfg)),
+ when=_isClang,
+ ),
+ Feature(
+ name=lambda cfg: "clang-{__clang_major__}.{__clang_minor__}".format(**compilerMacros(cfg)),
+ when=_isClang,
+ ),
+ Feature(
+ name=lambda cfg: "clang-{__clang_major__}.{__clang_minor__}.{__clang_patchlevel__}".format(**compilerMacros(cfg)),
+ when=_isClang,
+ ),
+ # Note: Due to a GCC bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104760), we must disable deprecation warnings
+ # on GCC or spurious diagnostics are issued.
+ #
+ # TODO:
+ # - Enable -Wplacement-new with GCC.
+ # - Enable -Wclass-memaccess with GCC.
+ Feature(
+ name="gcc",
+ when=_isGCC,
+ actions=[
+ AddCompileFlag("-D_LIBCPP_DISABLE_DEPRECATION_WARNINGS"),
+ AddCompileFlag("-Wno-placement-new"),
+ AddCompileFlag("-Wno-class-memaccess"),
+ AddFeature("GCC-ALWAYS_INLINE-FIXME"),
+ ],
+ ),
+ Feature(
+ name=lambda cfg: "gcc-{__GNUC__}".format(**compilerMacros(cfg)), when=_isGCC
+ ),
+ Feature(
+ name=lambda cfg: "gcc-{__GNUC__}.{__GNUC_MINOR__}".format(**compilerMacros(cfg)),
+ when=_isGCC,
+ ),
+ Feature(
+ name=lambda cfg: "gcc-{__GNUC__}.{__GNUC_MINOR__}.{__GNUC_PATCHLEVEL__}".format(**compilerMacros(cfg)),
+ when=_isGCC,
+ ),
+ Feature(name="msvc", when=_isMSVC),
+ Feature(name=lambda cfg: "msvc-{}".format(*_msvcVersion(cfg)), when=_isMSVC),
+ Feature(name=lambda cfg: "msvc-{}.{}".format(*_msvcVersion(cfg)), when=_isMSVC),
+
Feature(
name="thread-safety",
when=lambda cfg: hasCompileFlag(cfg, "-Werror=thread-safety"),
@@ -231,62 +289,6 @@ def _getAndroidDeviceApi(cfg):
AddSubstitution("%{clang-tidy}", lambda cfg: _getSuitableClangTidy(cfg))
],
),
- Feature(name="apple-clang", when=_isAppleClang),
- Feature(
- name=lambda cfg: "apple-clang-{__clang_major__}".format(**compilerMacros(cfg)),
- when=_isAppleClang,
- ),
- Feature(
- name=lambda cfg: "apple-clang-{__clang_major__}.{__clang_minor__}".format(**compilerMacros(cfg)),
- when=_isAppleClang,
- ),
- Feature(
- name=lambda cfg: "apple-clang-{__clang_major__}.{__clang_minor__}.{__clang_patchlevel__}".format(**compilerMacros(cfg)),
- when=_isAppleClang,
- ),
- Feature(name="clang", when=_isClang),
- Feature(
- name=lambda cfg: "clang-{__clang_major__}".format(**compilerMacros(cfg)),
- when=_isClang,
- ),
- Feature(
- name=lambda cfg: "clang-{__clang_major__}.{__clang_minor__}".format(**compilerMacros(cfg)),
- when=_isClang,
- ),
- Feature(
- name=lambda cfg: "clang-{__clang_major__}.{__clang_minor__}.{__clang_patchlevel__}".format(**compilerMacros(cfg)),
- when=_isClang,
- ),
- # Note: Due to a GCC bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104760), we must disable deprecation warnings
- # on GCC or spurious diagnostics are issued.
- #
- # TODO:
- # - Enable -Wplacement-new with GCC.
- # - Enable -Wclass-memaccess with GCC.
- Feature(
- name="gcc",
- when=_isGCC,
- actions=[
- AddCompileFlag("-D_LIBCPP_DISABLE_DEPRECATION_WARNINGS"),
- AddCompileFlag("-Wno-placement-new"),
- AddCompileFlag("-Wno-class-memaccess"),
- AddFeature("GCC-ALWAYS_INLINE-FIXME"),
- ],
- ),
- Feature(
- name=lambda cfg: "gcc-{__GNUC__}".format(**compilerMacros(cfg)), when=_isGCC
- ),
- Feature(
- name=lambda cfg: "gcc-{__GNUC__}.{__GNUC_MINOR__}".format(**compilerMacros(cfg)),
- when=_isGCC,
- ),
- Feature(
- name=lambda cfg: "gcc-{__GNUC__}.{__GNUC_MINOR__}.{__GNUC_PATCHLEVEL__}".format(**compilerMacros(cfg)),
- when=_isGCC,
- ),
- Feature(name="msvc", when=_isMSVC),
- Feature(name=lambda cfg: "msvc-{}".format(*_msvcVersion(cfg)), when=_isMSVC),
- Feature(name=lambda cfg: "msvc-{}.{}".format(*_msvcVersion(cfg)), when=_isMSVC),
]
# Deduce and add the test features that that are implied by the #defines in
More information about the libcxx-commits
mailing list