Mark some MLIR tests as requiring the native target to be configured
authorMehdi Amini <joker.eph@gmail.com>
Fri, 14 Jan 2022 06:57:51 +0000 (06:57 +0000)
committerMehdi Amini <joker.eph@gmail.com>
Fri, 14 Jan 2022 07:23:14 +0000 (07:23 +0000)
This makes `ninja check-mlir` work without the host targets configured.

mlir/test/CAPI/execution_engine.c
mlir/test/CMakeLists.txt
mlir/test/lit.cfg.py
mlir/test/mlir-cpu-runner/lit.local.cfg
mlir/test/python/execution_engine.py
mlir/unittests/CMakeLists.txt

index a48a2e3..22922c6 100644 (file)
@@ -9,6 +9,8 @@
 
 /* RUN: mlir-capi-execution-engine-test 2>&1 | FileCheck %s
  */
+/* REQUIRES: llvm_has_native_target
+*/
 
 #include "mlir-c/Conversion.h"
 #include "mlir-c/ExecutionEngine.h"
index 0567389..0aba117 100644 (file)
@@ -29,6 +29,12 @@ if (MLIR_INCLUDE_INTEGRATION_TESTS)
   # Passed to lit.site.cfg.py.in to set up the path where to find the libraries.
   set(MLIR_INTEGRATION_TEST_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
 
+
+  # The native target may not be enabled when cross compiling, raise an error.
+  if(NOT TARGET ${LLVM_NATIVE_ARCH})
+    message(FATAL_ERROR "MLIR_INCLUDE_INTEGRATION_TESTS requires a native target")
+  endif()
+
   # Copy test data over.
   file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/Integration/data/mttkrp_b.tns
             ${CMAKE_CURRENT_SOURCE_DIR}/Integration/data/test.mtx
index 0773271..3319629 100644 (file)
@@ -107,12 +107,10 @@ llvm_config.add_tool_substitutions(tools, tool_dirs)
 config.environment['FILECHECK_OPTS'] = "-enable-var-scope --allow-unused-prefixes=false"
 
 
-# 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')
+if config.native_target in config.targets_to_build:
+    config.available_features.add('llvm_has_native_target')
+
+
 
 # Add the python path for both the source and binary tree.
 # Note that presently, the python sources come from the source tree and the
index 012da91..3a9b0ef 100644 (file)
@@ -4,11 +4,7 @@ import sys
 if sys.platform == 'win32':
     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:
+# Requires the native target to be configured in.
+if 'llvm_has_native_target' not in config.available_features:
     config.unsupported = True
 
index 3cb116b..c01614f 100644 (file)
@@ -1,5 +1,5 @@
 # RUN: %PYTHON %s 2>&1 | FileCheck %s
-
+# REQUIRES: llvm_has_native_target
 import gc, sys
 from mlir.ir import *
 from mlir.passmanager import *
index 2798c44..3ad9e84 100644 (file)
@@ -7,7 +7,6 @@ endfunction()
 add_subdirectory(Analysis)
 add_subdirectory(Conversion)
 add_subdirectory(Dialect)
-add_subdirectory(ExecutionEngine)
 add_subdirectory(Interfaces)
 add_subdirectory(IR)
 add_subdirectory(Pass)
@@ -15,3 +14,8 @@ add_subdirectory(Support)
 add_subdirectory(Rewrite)
 add_subdirectory(TableGen)
 add_subdirectory(Transforms)
+
+# The native target may not be enabled when cross compiling.
+if(TARGET ${LLVM_NATIVE_ARCH})
+  add_subdirectory(ExecutionEngine)
+endif()