[Mlir-commits] [mlir] 772f7b8 - Disable the MLIR ExecutionEngine library when the native target is not configured

Mehdi Amini llvmlistbot at llvm.org
Sat Jan 15 11:36:42 PST 2022


Author: Mehdi Amini
Date: 2022-01-15T19:36:27Z
New Revision: 772f7b87f8cc040203476e3cc6e6164473349a26

URL: https://github.com/llvm/llvm-project/commit/772f7b87f8cc040203476e3cc6e6164473349a26
DIFF: https://github.com/llvm/llvm-project/commit/772f7b87f8cc040203476e3cc6e6164473349a26.diff

LOG: Disable the MLIR ExecutionEngine library when the native target is not configured

The execution engine would not be functional anyway, we're already
disabling the tests, this also disable the rest of the code.

Anecdotally this reduces the number of static library built when the
builtin target is disabled goes from 236 to 218.

Here is the complete list of LLVM targets built when running
`ninja check-mlir`:

libLLVMAggressiveInstCombine.a
libLLVMAnalysis.a
libLLVMAsmParser.a
libLLVMBinaryFormat.a
libLLVMBitReader.a
libLLVMBitstreamReader.a
libLLVMBitWriter.a
libLLVMCore.a
libLLVMDebugInfoCodeView.a
libLLVMDebugInfoDWARF.a
libLLVMDemangle.a
libLLVMFileCheck.a
libLLVMFrontendOpenMP.a
libLLVMInstCombine.a
libLLVMIRReader.a
libLLVMMC.a
libLLVMMCParser.a
libLLVMObject.a
libLLVMProfileData.a
libLLVMRemarks.a
libLLVMScalarOpts.a
libLLVMSupport.a
libLLVMTableGen.a
libLLVMTableGenGlobalISel.a
libLLVMTextAPI.a
libLLVMTransformUtils.a

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

Added: 
    

Modified: 
    mlir/lib/CAPI/CMakeLists.txt
    mlir/lib/CMakeLists.txt
    mlir/python/CMakeLists.txt
    mlir/test/CAPI/CMakeLists.txt
    mlir/test/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/mlir/lib/CAPI/CMakeLists.txt b/mlir/lib/CAPI/CMakeLists.txt
index 5545de691f697..393b49ecb43f8 100644
--- a/mlir/lib/CAPI/CMakeLists.txt
+++ b/mlir/lib/CAPI/CMakeLists.txt
@@ -10,12 +10,16 @@ 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")
@@ -33,3 +37,4 @@ if(MLIR_BUILD_MLIR_C_DYLIB)
     endif()
   endif()
 endif()
+

diff  --git a/mlir/lib/CMakeLists.txt b/mlir/lib/CMakeLists.txt
index 8b9a00e1dc918..467b0ae33dd87 100644
--- a/mlir/lib/CMakeLists.txt
+++ b/mlir/lib/CMakeLists.txt
@@ -4,7 +4,6 @@ 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)
@@ -17,3 +16,8 @@ add_subdirectory(Target)
 add_subdirectory(Tools)
 add_subdirectory(Transforms)
 add_subdirectory(Translation)
+
+# Only enable the ExecutionEngine if the native target is configured in.
+if(TARGET ${LLVM_NATIVE_ARCH})
+  add_subdirectory(ExecutionEngine)
+endif()
\ No newline at end of file

diff  --git a/mlir/python/CMakeLists.txt b/mlir/python/CMakeLists.txt
index 60d60d4aff71e..2a9d7a7f47be1 100644
--- a/mlir/python/CMakeLists.txt
+++ b/mlir/python/CMakeLists.txt
@@ -292,17 +292,20 @@ declare_mlir_python_extension(MLIRPythonExtension.Conversions
   MLIRCAPIConversion
 )
 
-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
-)
+# 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.GPUDialectPasses
   MODULE_NAME _mlirGPUPasses

diff  --git a/mlir/test/CAPI/CMakeLists.txt b/mlir/test/CAPI/CMakeLists.txt
index 8228bbb7d26f8..9610df62457e1 100644
--- a/mlir/test/CAPI/CMakeLists.txt
+++ b/mlir/test/CAPI/CMakeLists.txt
@@ -19,13 +19,16 @@ function(_add_capi_test_executable name)
   endif()
 endfunction(_add_capi_test_executable)
 
-_add_capi_test_executable(mlir-capi-execution-engine-test
-  execution_engine.c
-LINK_LIBS PRIVATE
-  MLIRCAPIConversion
-  MLIRCAPIExecutionEngine
-  MLIRCAPIRegistration
-)
+# 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-ir-test
   ir.c

diff  --git a/mlir/test/CMakeLists.txt b/mlir/test/CMakeLists.txt
index 415f0bb50cec1..8e44a9c37cf13 100644
--- a/mlir/test/CMakeLists.txt
+++ b/mlir/test/CMakeLists.txt
@@ -75,7 +75,6 @@ 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
@@ -89,9 +88,6 @@ 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
@@ -101,6 +97,10 @@ 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()
 


        


More information about the Mlir-commits mailing list