[libcxx-commits] [PATCH] D132575: [libc++] Allow specifying conditional compile flags dependent on basic Lit features

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Aug 25 05:55:17 PDT 2022


ldionne updated this revision to Diff 455554.
ldionne added a comment.

Try to fix CI on AIX.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132575/new/

https://reviews.llvm.org/D132575

Files:
  libcxx/test/libcxx/selftest/additional_compile_flags/conditional-compile-flags.sh.cpp
  libcxx/test/libcxx/selftest/additional_compile_flags/lit.local.cfg
  libcxx/utils/libcxx/test/format.py


Index: libcxx/utils/libcxx/test/format.py
===================================================================
--- libcxx/utils/libcxx/test/format.py
+++ libcxx/utils/libcxx/test/format.py
@@ -67,6 +67,15 @@
                                                    initial_value=additionalCompileFlags)
     ]
 
+    # Add conditional parsers for ADDITIONAL_COMPILE_FLAGS. This should be replaced by first
+    # class support for conditional keywords in Lit, which would allow evaluating arbitrary
+    # Lit boolean expressions instead.
+    for feature in test.config.available_features:
+        parser = lit.TestRunner.IntegratedTestKeywordParser('ADDITIONAL_COMPILE_FLAGS({}):'.format(feature),
+                                                            lit.TestRunner.ParserKind.LIST,
+                                                            initial_value=additionalCompileFlags)
+        parsers.append(parser)
+
     scriptInTest = lit.TestRunner.parseIntegratedTestScript(test, additional_parsers=parsers,
                                                             require_script=not preamble)
     if isinstance(scriptInTest, lit.Test.Result):
Index: libcxx/test/libcxx/selftest/additional_compile_flags/lit.local.cfg
===================================================================
--- /dev/null
+++ libcxx/test/libcxx/selftest/additional_compile_flags/lit.local.cfg
@@ -0,0 +1,2 @@
+# Add a Lit feature so we can test conditional addition of compile flags.
+config.available_features.add('some-defined-feature')
Index: libcxx/test/libcxx/selftest/additional_compile_flags/conditional-compile-flags.sh.cpp
===================================================================
--- /dev/null
+++ libcxx/test/libcxx/selftest/additional_compile_flags/conditional-compile-flags.sh.cpp
@@ -0,0 +1,14 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// This test ensures that we can add compile flags that are conditional on Lit features.
+
+// ADDITIONAL_COMPILE_FLAGS(some-defined-feature): -this-flag-should-be-added
+// ADDITIONAL_COMPILE_FLAGS(some-undefined-feature): -this-flag-should-not-be-added
+// RUN: echo "%{compile_flags}" | grep -e '-this-flag-should-be-added'
+// RUN: echo "%{compile_flags}" | grep -v -e '-this-flag-should-not-be-added'


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132575.455554.patch
Type: text/x-patch
Size: 2597 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220825/c1e64833/attachment.bin>


More information about the libcxx-commits mailing list