Fix `check-mlir` target when the host target isn't configured
authorMehdi Amini <joker.eph@gmail.com>
Fri, 19 Jun 2020 03:21:36 +0000 (03:21 +0000)
committerMehdi Amini <joker.eph@gmail.com>
Fri, 19 Jun 2020 06:36:20 +0000 (06:36 +0000)
This patch adds the `default_triple` feature to MLIR test suite.
This feature was added to LLVM in d178f4fc8 in order to be able to
run the LLVM tests without having the host targets configured in.
With this change, `ninja check-mlir` passes without the host
target, i.e. this config:

  cmake ../llvm -DLLVM_TARGETS_TO_BUILD="" -DLLVM_DEFAULT_TARGET_TRIPLE="" -DLLVM_ENABLE_PROJECTS=mlir -GNinja

Differential Revision: https://reviews.llvm.org/D82142

mlir/test/lit.cfg.py
mlir/test/mlir-cpu-runner/lit.local.cfg

index 8c556e2..bb0850e 100644 (file)
@@ -81,3 +81,11 @@ llvm_config.add_tool_substitutions(tools, tool_dirs)
 # This option avoids to accidentally reuse variable across -LABEL match,
 # it can be explicitly opted-in by prefixing the variable name with $
 config.environment['FILECHECK_OPTS'] = "-enable-var-scope"
+
+
+# LLVM can be configured with an empty default triple
+# by passing ` -DLLVM_DEFAULT_TARGET_TRIPLE="" `.
+# This is how LLVM filters tests that require the host target
+# to be available for JIT tests.
+if config.target_triple:
+    config.available_features.add('default_triple')
index 7fd56a7..012da91 100644 (file)
@@ -2,4 +2,13 @@ import sys
 
 # FIXME: llvm orc does not support the COFF rtld.
 if sys.platform == 'win32':
-    config.unsupported = True
\ No newline at end of file
+    config.unsupported = True
+
+# Requires a non-empty default triple for these tests.
+# Passing ` -DLLVM_DEFAULT_TARGET_TRIPLE="" ` when the
+# host target isn't available is how LLVM filters
+# tests that require the host target to be available
+# for JIT tests.
+if 'default_triple' not in config.available_features:
+    config.unsupported = True
+