summaryrefslogtreecommitdiff
path: root/mlir/CMakeLists.txt
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2024-12-12 14:59:34 +0100
committerGitHub <noreply@github.com>2024-12-12 14:59:34 +0100
commit10ef20f6a629797d81252de143117e2a0bc6556d (patch)
tree171bd4060bb4237bd5a7613253492a2ae6edf556 /mlir/CMakeLists.txt
parent34d244a94195dbeb626573c9b2e388dc574f9300 (diff)
[mlir] Add support for MLIR_LINK_MLIR_DYLIB (#119408)
While MLIR currently supports building a libMLIR.so, it does not support actually linking against it for its own tools. When building with LTO, this means we have to relink the world for every tool, and the resulting binaries are large. This adds basic support for MLIR_LINK_MLIR_DYLIB, modelled after how CLANG_LINK_CLANG_DYLIB is implemented: Libraries that are part of libMLIR.so should be added via mlir_target_link_libraries instead of target_link_libraries. This will replace them with libMLIR.so if MLIR_LINK_MLIR_DYLIB is enabled. This adds basic support, I think there are two more things that can be done here: * C API unit tests should link against libMLIR-C.so. Currently these still link statically. * Linking the test libs (not part of libMLIR.so) still pulls in dependencies statically that should come from libMLIR.so.
Diffstat (limited to 'mlir/CMakeLists.txt')
-rw-r--r--mlir/CMakeLists.txt3
1 files changed, 3 insertions, 0 deletions
diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index 82bfbe56f083..0608eef15c5a 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -153,6 +153,9 @@ set(MLIR_INSTALL_AGGREGATE_OBJECTS 1 CACHE BOOL
set(MLIR_BUILD_MLIR_C_DYLIB 0 CACHE BOOL "Builds libMLIR-C shared library.")
+set(MLIR_LINK_MLIR_DYLIB ${LLVM_LINK_LLVM_DYLIB} CACHE BOOL
+ "Link tools against libMLIR.so")
+
configure_file(
${MLIR_MAIN_INCLUDE_DIR}/mlir/Config/mlir-config.h.cmake
${MLIR_INCLUDE_DIR}/mlir/Config/mlir-config.h)