Skip to content

Commit 772f7b8

Browse files
committed
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
1 parent d3e49a4 commit 772f7b8

File tree

5 files changed

+39
-24
lines changed

5 files changed

+39
-24
lines changed

mlir/lib/CAPI/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@ endfunction()
1010
add_subdirectory(Debug)
1111
add_subdirectory(Dialect)
1212
add_subdirectory(Conversion)
13-
add_subdirectory(ExecutionEngine)
1413
add_subdirectory(Interfaces)
1514
add_subdirectory(IR)
1615
add_subdirectory(Registration)
1716
add_subdirectory(Transforms)
1817

18+
# Only enable the ExecutionEngine if the native target is configured in.
19+
if(TARGET ${LLVM_NATIVE_ARCH})
20+
add_subdirectory(ExecutionEngine)
21+
endif()
22+
1923
# Build the optional CAPI dylib.
2024
if(MLIR_BUILD_MLIR_C_DYLIB)
2125
message(STATUS "Building MLIR-C dylib")
@@ -33,3 +37,4 @@ if(MLIR_BUILD_MLIR_C_DYLIB)
3337
endif()
3438
endif()
3539
endif()
40+

mlir/lib/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ add_flag_if_supported("-Werror=global-constructors" WERROR_GLOBAL_CONSTRUCTOR)
44
add_subdirectory(Analysis)
55
add_subdirectory(Conversion)
66
add_subdirectory(Dialect)
7-
add_subdirectory(ExecutionEngine)
87
add_subdirectory(IR)
98
add_subdirectory(Interfaces)
109
add_subdirectory(Parser)
@@ -17,3 +16,8 @@ add_subdirectory(Target)
1716
add_subdirectory(Tools)
1817
add_subdirectory(Transforms)
1918
add_subdirectory(Translation)
19+
20+
# Only enable the ExecutionEngine if the native target is configured in.
21+
if(TARGET ${LLVM_NATIVE_ARCH})
22+
add_subdirectory(ExecutionEngine)
23+
endif()

mlir/python/CMakeLists.txt

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -292,17 +292,20 @@ declare_mlir_python_extension(MLIRPythonExtension.Conversions
292292
MLIRCAPIConversion
293293
)
294294

295-
declare_mlir_python_extension(MLIRPythonExtension.ExecutionEngine
296-
MODULE_NAME _mlirExecutionEngine
297-
ADD_TO_PARENT MLIRPythonSources.ExecutionEngine
298-
ROOT_DIR "${PYTHON_SOURCE_DIR}"
299-
SOURCES
300-
ExecutionEngineModule.cpp
301-
PRIVATE_LINK_LIBS
302-
LLVMSupport
303-
EMBED_CAPI_LINK_LIBS
304-
MLIRCAPIExecutionEngine
305-
)
295+
# Only enable the ExecutionEngine if the native target is configured in.
296+
if(TARGET ${LLVM_NATIVE_ARCH})
297+
declare_mlir_python_extension(MLIRPythonExtension.ExecutionEngine
298+
MODULE_NAME _mlirExecutionEngine
299+
ADD_TO_PARENT MLIRPythonSources.ExecutionEngine
300+
ROOT_DIR "${PYTHON_SOURCE_DIR}"
301+
SOURCES
302+
ExecutionEngineModule.cpp
303+
PRIVATE_LINK_LIBS
304+
LLVMSupport
305+
EMBED_CAPI_LINK_LIBS
306+
MLIRCAPIExecutionEngine
307+
)
308+
endif()
306309

307310
declare_mlir_python_extension(MLIRPythonExtension.GPUDialectPasses
308311
MODULE_NAME _mlirGPUPasses

mlir/test/CAPI/CMakeLists.txt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@ function(_add_capi_test_executable name)
1919
endif()
2020
endfunction(_add_capi_test_executable)
2121

22-
_add_capi_test_executable(mlir-capi-execution-engine-test
23-
execution_engine.c
24-
LINK_LIBS PRIVATE
25-
MLIRCAPIConversion
26-
MLIRCAPIExecutionEngine
27-
MLIRCAPIRegistration
28-
)
22+
# Only enable the ExecutionEngine if the native target is configured in.
23+
if(TARGET ${LLVM_NATIVE_ARCH})
24+
_add_capi_test_executable(mlir-capi-execution-engine-test
25+
execution_engine.c
26+
LINK_LIBS PRIVATE
27+
MLIRCAPIConversion
28+
MLIRCAPIExecutionEngine
29+
MLIRCAPIRegistration
30+
)
31+
endif()
2932

3033
_add_capi_test_executable(mlir-capi-ir-test
3134
ir.c

mlir/test/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ configure_lit_site_cfg(
7575

7676
set(MLIR_TEST_DEPENDS
7777
FileCheck count not split-file
78-
mlir-capi-execution-engine-test
7978
mlir-capi-ir-test
8079
mlir-capi-llvm-test
8180
mlir-capi-pass-test
@@ -89,9 +88,6 @@ set(MLIR_TEST_DEPENDS
8988
mlir-reduce
9089
mlir-tblgen
9190
mlir-translate
92-
mlir_runner_utils
93-
mlir_c_runner_utils
94-
mlir_async_runtime
9591
)
9692

9793
# The native target may not be enabled, in this case we won't
@@ -101,6 +97,10 @@ if(TARGET ${LLVM_NATIVE_ARCH})
10197
list(APPEND MLIR_TEST_DEPENDS
10298
mlir-cpu-runner
10399
llc
100+
mlir_async_runtime
101+
mlir-capi-execution-engine-test
102+
mlir_c_runner_utils
103+
mlir_runner_utils
104104
)
105105
endif()
106106

0 commit comments

Comments
 (0)