[libcxx-commits] [libcxx] 70eb30c - [libc++] Move availability-related Lit configuration to the DSL

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Nov 4 11:56:27 PST 2020


Author: Louis Dionne
Date: 2020-11-04T14:56:08-05:00
New Revision: 70eb30cc81eeb6f569ecf155197e14fb37263b7e

URL: https://github.com/llvm/llvm-project/commit/70eb30cc81eeb6f569ecf155197e14fb37263b7e
DIFF: https://github.com/llvm/llvm-project/commit/70eb30cc81eeb6f569ecf155197e14fb37263b7e.diff

LOG: [libc++] Move availability-related Lit configuration to the DSL

The implementation is not really satisfactory, but it's better than
being in the legacy config, which causes other issues.

Added: 
    

Modified: 
    libcxx/utils/libcxx/test/config.py
    libcxx/utils/libcxx/test/features.py
    libcxx/utils/libcxx/test/params.py

Removed: 
    


################################################################################
diff  --git a/libcxx/utils/libcxx/test/config.py b/libcxx/utils/libcxx/test/config.py
index f6ff8b153080..1c51acdf65f2 100644
--- a/libcxx/utils/libcxx/test/config.py
+++ b/libcxx/utils/libcxx/test/config.py
@@ -239,18 +239,6 @@ def configure_features(self):
             for f in additional_features.split(','):
                 self.config.available_features.add(f.strip())
 
-        # Write an "available feature" that combines the triple when
-        # use_system_cxx_lib is enabled. This is so that we can easily write
-        # XFAIL markers for tests that are known to fail with versions of
-        # libc++ as were shipped with a particular triple.
-        if self.use_system_cxx_lib:
-            (arch, vendor, platform) = self.config.target_triple.split('-', 2)
-            (sysname, version) = re.match(r'([^0-9]+)([0-9\.]*)', platform).groups()
-
-            self.config.available_features.add('with_system_cxx_lib={}-{}-{}{}'.format(arch, vendor, sysname, version))
-            self.config.available_features.add('with_system_cxx_lib={}{}'.format(sysname, version))
-            self.config.available_features.add('with_system_cxx_lib={}'.format(sysname))
-
         if self.target_info.is_windows():
             if self.cxx_stdlib_under_test == 'libc++':
                 # LIBCXX-WINDOWS-FIXME is the feature name used to XFAIL the
@@ -329,11 +317,6 @@ def configure_default_compile_flags(self):
         support_path = os.path.join(self.libcxx_src_root, 'test/support')
         self.cxx.compile_flags += ['-I' + support_path]
 
-        # If we're testing the upstream LLVM libc++, disable availability markup,
-        # which is not relevant for non-shipped flavors of libc++.
-        if not self.use_system_cxx_lib:
-            self.cxx.compile_flags += ['-D_LIBCPP_DISABLE_AVAILABILITY']
-
         # On GCC, the libc++ headers cause errors due to throw() decorators
         # on operator new clashing with those from the test suite, so we
         # don't enable warnings in system headers on GCC.

diff  --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py
index cacbf6dac0ea..efafd871af74 100644
--- a/libcxx/utils/libcxx/test/features.py
+++ b/libcxx/utils/libcxx/test/features.py
@@ -7,6 +7,7 @@
 #===----------------------------------------------------------------------===##
 
 from libcxx.test.dsl import *
+import re
 import sys
 
 _isClang      = lambda cfg: '__clang__' in compilerMacros(cfg) and '__apple_build_version__' not in compilerMacros(cfg)
@@ -128,3 +129,27 @@
   Feature(name='linux', when=lambda cfg: '__linux__' in compilerMacros(cfg)),
   Feature(name='netbsd', when=lambda cfg: '__NetBSD__' in compilerMacros(cfg))
 ]
+
+
+# When vendor-specific availability annotations are enabled, add Lit features
+# with various forms of the target triple to make it easier to write XFAIL or
+# UNSUPPORTED markup for tests that are known to fail on a particular triple.
+#
+# TODO: This is very unclean -- we assume that the 'use_system_cxx_lib' parameter
+#       is set before this feature gets detected, and we also set a dummy name
+#       for the main feature. We also take for granted that `target_triple`
+#       exists in the config object. This should be refactored so that the
+#       'use_system_cxx_lib' Parameter can set these features itself.
+def _addSystemCxxLibDeclinations(cfg):
+  (arch, vendor, platform) = cfg.target_triple.split('-', 2)
+  (sysname, version) = re.match(r'([^0-9]+)([0-9\.]*)', platform).groups()
+  return [
+    AddFeature('with_system_cxx_lib={}-{}-{}{}'.format(arch, vendor, sysname, version)),
+    AddFeature('with_system_cxx_lib={}{}'.format(sysname, version)),
+    AddFeature('with_system_cxx_lib={}'.format(sysname)),
+  ]
+DEFAULT_FEATURES += [
+  Feature(name='__dummy_use_system_cxx_lib',
+          when=lambda cfg: 'use_system_cxx_lib' in cfg.available_features,
+          actions=_addSystemCxxLibDeclinations)
+]

diff  --git a/libcxx/utils/libcxx/test/params.py b/libcxx/utils/libcxx/test/params.py
index e9c0f73077fa..d8dc01203146 100644
--- a/libcxx/utils/libcxx/test/params.py
+++ b/libcxx/utils/libcxx/test/params.py
@@ -73,6 +73,18 @@
               AddOptionalWarningFlag(w) for w in _warningFlags
             ]),
 
+  Parameter(name='use_system_cxx_lib', choices=[True, False], type=bool, default=False,
+            help="Whether the test suite is being *run* against the library shipped on "
+                 "the target triple in use, as opposed to the trunk library.",
+            actions=lambda useSystem: [
+              # TODO: Remove this, see comment in features.py
+              AddFeature('use_system_cxx_lib')
+            ] if useSystem else [
+              # If we're testing upstream libc++, disable availability markup,
+              # which is not relevant for non-shipped flabors of libc++.
+              AddCompileFlag('-D_LIBCPP_DISABLE_AVAILABILITY')
+            ]),
+
   # Parameters to enable or disable parts of the test suite
   Parameter(name='enable_filesystem', choices=[True, False], type=bool, default=True,
             help="Whether to enable tests for the C++ <filesystem> library.",


        


More information about the libcxx-commits mailing list