From 6dffa56d409151b45141161cef77c5659d2205a2 Mon Sep 17 00:00:00 2001
From: "Uwe L. Korn" <uwe.korn@quantco.com>
Date: Thu, 24 Feb 2022 16:49:26 +0100
Subject: [PATCH] Revert "Disable the MLIR ExecutionEngine library when the
 native target is not configured"

This reverts commit 772f7b87f8cc040203476e3cc6e6164473349a26.
---
 mlir/lib/CAPI/CMakeLists.txt  |  7 +------
 mlir/lib/CMakeLists.txt       |  1 +
 mlir/python/CMakeLists.txt    | 25 +++++++++++--------------
 mlir/test/CAPI/CMakeLists.txt | 17 +++++++----------
 mlir/test/CMakeLists.txt      |  8 ++++----
 5 files changed, 24 insertions(+), 34 deletions(-)

diff --git a/mlir/lib/CAPI/CMakeLists.txt b/mlir/lib/CAPI/CMakeLists.txt
index 393b49ecb43f..5545de691f69 100644
--- a/mlir/lib/CAPI/CMakeLists.txt
+++ b/mlir/lib/CAPI/CMakeLists.txt
@@ -10,16 +10,12 @@ endfunction()
 add_subdirectory(Debug)
 add_subdirectory(Dialect)
 add_subdirectory(Conversion)
+add_subdirectory(ExecutionEngine)
 add_subdirectory(Interfaces)
 add_subdirectory(IR)
 add_subdirectory(Registration)
 add_subdirectory(Transforms)
 
-# Only enable the ExecutionEngine if the native target is configured in.
-if(TARGET ${LLVM_NATIVE_ARCH})
-  add_subdirectory(ExecutionEngine)
-endif()
-
 # Build the optional CAPI dylib.
 if(MLIR_BUILD_MLIR_C_DYLIB)
   message(STATUS "Building MLIR-C dylib")
@@ -37,4 +33,3 @@ if(MLIR_BUILD_MLIR_C_DYLIB)
     endif()
   endif()
 endif()
-
diff --git a/mlir/lib/CMakeLists.txt b/mlir/lib/CMakeLists.txt
index 05bfbb47e28e..ec5c326d5d78 100644
--- a/mlir/lib/CMakeLists.txt
+++ b/mlir/lib/CMakeLists.txt
@@ -4,6 +4,7 @@ add_flag_if_supported("-Werror=global-constructors" WERROR_GLOBAL_CONSTRUCTOR)
 add_subdirectory(Analysis)
 add_subdirectory(Conversion)
 add_subdirectory(Dialect)
+add_subdirectory(ExecutionEngine)
 add_subdirectory(IR)
 add_subdirectory(Interfaces)
 add_subdirectory(Parser)
diff --git a/mlir/python/CMakeLists.txt b/mlir/python/CMakeLists.txt
index 59ddd83fb8b0..9a92bb2b378d 100644
--- a/mlir/python/CMakeLists.txt
+++ b/mlir/python/CMakeLists.txt
@@ -315,20 +315,17 @@ declare_mlir_python_extension(MLIRPythonExtension.Conversions
   MLIRCAPIConversion
 )
 
-# Only enable the ExecutionEngine if the native target is configured in.
-if(TARGET ${LLVM_NATIVE_ARCH})
-  declare_mlir_python_extension(MLIRPythonExtension.ExecutionEngine
-    MODULE_NAME _mlirExecutionEngine
-    ADD_TO_PARENT MLIRPythonSources.ExecutionEngine
-    ROOT_DIR "${PYTHON_SOURCE_DIR}"
-    SOURCES
-      ExecutionEngineModule.cpp
-    PRIVATE_LINK_LIBS
-      LLVMSupport
-    EMBED_CAPI_LINK_LIBS
-      MLIRCAPIExecutionEngine
-  )
-endif()
+declare_mlir_python_extension(MLIRPythonExtension.ExecutionEngine
+  MODULE_NAME _mlirExecutionEngine
+  ADD_TO_PARENT MLIRPythonSources.ExecutionEngine
+  ROOT_DIR "${PYTHON_SOURCE_DIR}"
+  SOURCES
+    ExecutionEngineModule.cpp
+  PRIVATE_LINK_LIBS
+    LLVMSupport
+  EMBED_CAPI_LINK_LIBS
+    MLIRCAPIExecutionEngine
+)
 
 declare_mlir_python_extension(MLIRPythonExtension.GPUDialectPasses
   MODULE_NAME _mlirGPUPasses
diff --git a/mlir/test/CAPI/CMakeLists.txt b/mlir/test/CAPI/CMakeLists.txt
index 9610df62457e..8228bbb7d26f 100644
--- a/mlir/test/CAPI/CMakeLists.txt
+++ b/mlir/test/CAPI/CMakeLists.txt
@@ -19,16 +19,13 @@ function(_add_capi_test_executable name)
   endif()
 endfunction(_add_capi_test_executable)
 
-# Only enable the ExecutionEngine if the native target is configured in.
-if(TARGET ${LLVM_NATIVE_ARCH})
-  _add_capi_test_executable(mlir-capi-execution-engine-test
-    execution_engine.c
-  LINK_LIBS PRIVATE
-    MLIRCAPIConversion
-    MLIRCAPIExecutionEngine
-    MLIRCAPIRegistration
-  )
-endif()
+_add_capi_test_executable(mlir-capi-execution-engine-test
+  execution_engine.c
+LINK_LIBS PRIVATE
+  MLIRCAPIConversion
+  MLIRCAPIExecutionEngine
+  MLIRCAPIRegistration
+)
 
 _add_capi_test_executable(mlir-capi-ir-test
   ir.c
diff --git a/mlir/test/CMakeLists.txt b/mlir/test/CMakeLists.txt
index 8e44a9c37cf1..415f0bb50cec 100644
--- a/mlir/test/CMakeLists.txt
+++ b/mlir/test/CMakeLists.txt
@@ -75,6 +75,7 @@ configure_lit_site_cfg(
 
 set(MLIR_TEST_DEPENDS
   FileCheck count not split-file
+  mlir-capi-execution-engine-test
   mlir-capi-ir-test
   mlir-capi-llvm-test
   mlir-capi-pass-test
@@ -88,6 +89,9 @@ set(MLIR_TEST_DEPENDS
   mlir-reduce
   mlir-tblgen
   mlir-translate
+  mlir_runner_utils
+  mlir_c_runner_utils
+  mlir_async_runtime
   )
 
 # The native target may not be enabled, in this case we won't
@@ -97,10 +101,6 @@ if(TARGET ${LLVM_NATIVE_ARCH})
   list(APPEND MLIR_TEST_DEPENDS
     mlir-cpu-runner
     llc
-    mlir_async_runtime
-    mlir-capi-execution-engine-test
-    mlir_c_runner_utils
-    mlir_runner_utils
   )
 endif()
 
-- 
2.35.0

