Skip to content

Commit 631ae59

Browse files
authored
[MLIR][ExecutionEngine] Introduce shared library (#87067)
This commit introduces a shared library for the MLIR execution engine. This library is only built when `LLVM_BUILD_LLVM_DYLIB` is set. Having such a library allows downstream users to depend on the execution engine without giving up dynamic linkage. This is especially important for CPU runner-style tools, as they link against large parts of MLIR and LLVM. It is alternatively possible to modify the `MLIRExecutionEngine` target when `LLVM_BUILD_LLVM_DYLIB` is set, to avoid duplicated libraries.
1 parent 9525841 commit 631ae59

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

mlir/lib/ExecutionEngine/CMakeLists.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,29 @@ add_mlir_library(MLIRExecutionEngine
9797
MLIRTargetLLVMIRExport
9898
)
9999

100+
if(LLVM_BUILD_LLVM_DYLIB)
101+
# Build a shared library for the execution engine. Some downstream projects
102+
# use this library to build their own CPU runners while preserving dynamic
103+
# linkage.
104+
add_mlir_library(MLIRExecutionEngineShared
105+
ExecutionEngine.cpp
106+
SHARED
107+
108+
EXCLUDE_FROM_LIBMLIR
109+
110+
ADDITIONAL_HEADER_DIRS
111+
${MLIR_MAIN_INCLUDE_DIR}/mlir/ExecutionEngine
112+
113+
# Ensures that all necessary dependencies are resolved.
114+
DEPENDS
115+
MLIRExecutionEngine
116+
117+
LINK_LIBS PUBLIC
118+
LLVM
119+
MLIR
120+
)
121+
endif()
122+
100123
get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
101124
add_mlir_library(MLIRJitRunner
102125
JitRunner.cpp

0 commit comments

Comments
 (0)