-
Notifications
You must be signed in to change notification settings - Fork 12.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[mlir] Add support for MLIR_LINK_MLIR_DYLIB #119408
Conversation
@llvm/pr-subscribers-mlir Author: Nikita Popov (nikic) ChangesWhile 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:
Full diff: https://github.com/llvm/llvm-project/pull/119408.diff 11 Files Affected:
diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index 82bfbe56f08395..0608eef15c5a4b 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)
diff --git a/mlir/cmake/modules/AddMLIR.cmake b/mlir/cmake/modules/AddMLIR.cmake
index a3324705c525ce..d8f9cccd54dc6c 100644
--- a/mlir/cmake/modules/AddMLIR.cmake
+++ b/mlir/cmake/modules/AddMLIR.cmake
@@ -717,3 +717,15 @@ function(mlir_check_all_link_libraries name)
endforeach()
endif()
endfunction(mlir_check_all_link_libraries)
+
+function(mlir_target_link_libraries target type)
+ if (TARGET obj.${target})
+ target_link_libraries(obj.${target} ${ARGN})
+ endif()
+
+ if (MLIR_LINK_MLIR_DYLIB)
+ target_link_libraries(${target} ${type} MLIR)
+ else()
+ target_link_libraries(${target} ${type} ${ARGN})
+ endif()
+endfunction()
diff --git a/mlir/tools/mlir-cpu-runner/CMakeLists.txt b/mlir/tools/mlir-cpu-runner/CMakeLists.txt
index ae6dbceca855d1..811583b97bc71d 100644
--- a/mlir/tools/mlir-cpu-runner/CMakeLists.txt
+++ b/mlir/tools/mlir-cpu-runner/CMakeLists.txt
@@ -11,12 +11,10 @@ add_mlir_tool(mlir-cpu-runner
EXPORT_SYMBOLS
)
llvm_update_compile_flags(mlir-cpu-runner)
-target_link_libraries(mlir-cpu-runner PRIVATE
+mlir_target_link_libraries(mlir-cpu-runner PRIVATE
MLIRAnalysis
MLIRBuiltinToLLVMIRTranslation
- MLIRExecutionEngine
MLIRIR
- MLIRJitRunner
MLIRLLVMDialect
MLIRLLVMToLLVMIRTranslation
MLIRToLLVMIRTranslationRegistration
@@ -24,3 +22,7 @@ target_link_libraries(mlir-cpu-runner PRIVATE
MLIRTargetLLVMIRExport
MLIRSupport
)
+target_link_libraries(mlir-cpu-runner PRIVATE
+ MLIRExecutionEngine
+ MLIRJitRunner
+ )
diff --git a/mlir/tools/mlir-lsp-server/CMakeLists.txt b/mlir/tools/mlir-lsp-server/CMakeLists.txt
index 8ff9cc2f07e8eb..6932e0f3977951 100644
--- a/mlir/tools/mlir-lsp-server/CMakeLists.txt
+++ b/mlir/tools/mlir-lsp-server/CMakeLists.txt
@@ -38,7 +38,6 @@ set(LIBS
${conversion_libs}
${dialect_libs}
${extension_libs}
- ${test_libs}
MLIRAffineAnalysis
MLIRAnalysis
@@ -56,11 +55,9 @@ set(LIBS
add_mlir_tool(mlir-lsp-server
mlir-lsp-server.cpp
-
- DEPENDS
- ${LIBS}
)
-target_link_libraries(mlir-lsp-server PRIVATE ${LIBS})
+mlir_target_link_libraries(mlir-lsp-server PRIVATE ${LIBS})
+target_link_libraries(mlir-lsp-server PRIVATE ${test_libs})
llvm_update_compile_flags(mlir-lsp-server)
mlir_check_all_link_libraries(mlir-lsp-server)
diff --git a/mlir/tools/mlir-opt/CMakeLists.txt b/mlir/tools/mlir-opt/CMakeLists.txt
index 8b79de58fa1028..71ab67d94ef91f 100644
--- a/mlir/tools/mlir-opt/CMakeLists.txt
+++ b/mlir/tools/mlir-opt/CMakeLists.txt
@@ -45,6 +45,7 @@ if(MLIR_INCLUDE_TESTS)
MLIRTestReducer
MLIRTestTransforms
MLIRTilingInterfaceTestPasses
+ MLIRTosaTestPasses
MLIRVectorTestPasses
MLIRTestVectorToSPIRV
MLIRLLVMTestPasses
@@ -66,7 +67,6 @@ set(LIBS
${dialect_libs}
${conversion_libs}
${extension_libs}
- ${test_libs}
MLIRAffineAnalysis
MLIRAnalysis
@@ -99,11 +99,10 @@ add_mlir_library(MLIRMlirOptMain
add_mlir_tool(mlir-opt
mlir-opt.cpp
- DEPENDS
- ${LIBS}
SUPPORT_PLUGINS
)
-target_link_libraries(mlir-opt PRIVATE ${LIBS})
+mlir_target_link_libraries(mlir-opt PRIVATE ${LIBS})
+target_link_libraries(mlir-opt PRIVATE ${test_libs})
llvm_update_compile_flags(mlir-opt)
mlir_check_all_link_libraries(mlir-opt)
diff --git a/mlir/tools/mlir-parser-fuzzer/bytecode/CMakeLists.txt b/mlir/tools/mlir-parser-fuzzer/bytecode/CMakeLists.txt
index 7d922656ad12f4..e17b1588519898 100644
--- a/mlir/tools/mlir-parser-fuzzer/bytecode/CMakeLists.txt
+++ b/mlir/tools/mlir-parser-fuzzer/bytecode/CMakeLists.txt
@@ -6,7 +6,7 @@ add_llvm_fuzzer(mlir-bytecode-parser-fuzzer
mlir-bytecode-parser-fuzzer.cpp
DUMMY_MAIN DummyParserFuzzer.cpp
)
-target_link_libraries(mlir-bytecode-parser-fuzzer
+mlir_target_link_libraries(mlir-bytecode-parser-fuzzer
PUBLIC
MLIRIR
MLIRParser
diff --git a/mlir/tools/mlir-parser-fuzzer/text/CMakeLists.txt b/mlir/tools/mlir-parser-fuzzer/text/CMakeLists.txt
index a9c9e1047b54ef..b4a2bacc0ee0be 100644
--- a/mlir/tools/mlir-parser-fuzzer/text/CMakeLists.txt
+++ b/mlir/tools/mlir-parser-fuzzer/text/CMakeLists.txt
@@ -6,7 +6,7 @@ add_llvm_fuzzer(mlir-text-parser-fuzzer
mlir-text-parser-fuzzer.cpp
DUMMY_MAIN DummyParserFuzzer.cpp
)
-target_link_libraries(mlir-text-parser-fuzzer
+mlir_target_link_libraries(mlir-text-parser-fuzzer
PUBLIC
MLIRIR
MLIRParser
diff --git a/mlir/tools/mlir-query/CMakeLists.txt b/mlir/tools/mlir-query/CMakeLists.txt
index ef2e5a84b5569b..18263970a7bbc7 100644
--- a/mlir/tools/mlir-query/CMakeLists.txt
+++ b/mlir/tools/mlir-query/CMakeLists.txt
@@ -10,11 +10,11 @@ add_mlir_tool(mlir-query
mlir-query.cpp
)
llvm_update_compile_flags(mlir-query)
-target_link_libraries(mlir-query
+mlir_target_link_libraries(mlir-query
PRIVATE
${dialect_libs}
- ${test_libs}
MLIRQueryLib
)
+target_link_libraries(mlir-query PRIVATE ${test_libs})
mlir_check_link_libraries(mlir-query)
diff --git a/mlir/tools/mlir-reduce/CMakeLists.txt b/mlir/tools/mlir-reduce/CMakeLists.txt
index 8549dbf805f54e..d71ac861a29dca 100644
--- a/mlir/tools/mlir-reduce/CMakeLists.txt
+++ b/mlir/tools/mlir-reduce/CMakeLists.txt
@@ -10,7 +10,6 @@ endif()
set(LIBS
${conversion_libs}
${dialect_libs}
- ${test_libs}
MLIRDialect
MLIRIR
MLIRPass
@@ -19,12 +18,10 @@ set(LIBS
add_mlir_tool(mlir-reduce
mlir-reduce.cpp
-
- DEPENDS
- ${LIBS}
)
-target_link_libraries(mlir-reduce PRIVATE ${LIBS})
+mlir_target_link_libraries(mlir-reduce PRIVATE ${LIBS})
+target_link_libraries(mlir-reduce PRIVATE ${test_libs})
llvm_update_compile_flags(mlir-reduce)
mlir_check_all_link_libraries(mlir-reduce)
diff --git a/mlir/tools/mlir-rewrite/CMakeLists.txt b/mlir/tools/mlir-rewrite/CMakeLists.txt
index 5b8c1cd4553997..216491eb432af0 100644
--- a/mlir/tools/mlir-rewrite/CMakeLists.txt
+++ b/mlir/tools/mlir-rewrite/CMakeLists.txt
@@ -5,7 +5,6 @@ set(LLVM_LINK_COMPONENTS
set(LIBS
${dialect_libs}
- ${test_libs}
MLIRAffineAnalysis
MLIRAnalysis
@@ -24,11 +23,9 @@ include_directories(../../../clang/include)
add_mlir_tool(mlir-rewrite
mlir-rewrite.cpp
- DEPENDS
- ${LIBS}
SUPPORT_PLUGINS
)
-target_link_libraries(mlir-rewrite PRIVATE ${LIBS})
+mlir_target_link_libraries(mlir-rewrite PRIVATE ${LIBS})
llvm_update_compile_flags(mlir-rewrite)
mlir_check_all_link_libraries(mlir-rewrite)
diff --git a/mlir/tools/mlir-translate/CMakeLists.txt b/mlir/tools/mlir-translate/CMakeLists.txt
index a78131b8c356c0..b356e04bb1dc4a 100644
--- a/mlir/tools/mlir-translate/CMakeLists.txt
+++ b/mlir/tools/mlir-translate/CMakeLists.txt
@@ -9,11 +9,9 @@ add_mlir_tool(mlir-translate
mlir-translate.cpp
)
llvm_update_compile_flags(mlir-translate)
-target_link_libraries(mlir-translate
+mlir_target_link_libraries(mlir-translate
PRIVATE
${dialect_libs}
- ${translation_libs}
- ${test_libs}
MLIRIR
MLIRParser
MLIRPass
@@ -21,5 +19,10 @@ target_link_libraries(mlir-translate
MLIRTranslateLib
MLIRSupport
)
+target_link_libraries(mlir-translate
+ PRIVATE
+ ${translation_libs}
+ ${test_libs}
+ )
mlir_check_link_libraries(mlir-translate)
|
@llvm/pr-subscribers-mlir-core Author: Nikita Popov (nikic) ChangesWhile 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:
Full diff: https://github.com/llvm/llvm-project/pull/119408.diff 11 Files Affected:
diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index 82bfbe56f08395..0608eef15c5a4b 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)
diff --git a/mlir/cmake/modules/AddMLIR.cmake b/mlir/cmake/modules/AddMLIR.cmake
index a3324705c525ce..d8f9cccd54dc6c 100644
--- a/mlir/cmake/modules/AddMLIR.cmake
+++ b/mlir/cmake/modules/AddMLIR.cmake
@@ -717,3 +717,15 @@ function(mlir_check_all_link_libraries name)
endforeach()
endif()
endfunction(mlir_check_all_link_libraries)
+
+function(mlir_target_link_libraries target type)
+ if (TARGET obj.${target})
+ target_link_libraries(obj.${target} ${ARGN})
+ endif()
+
+ if (MLIR_LINK_MLIR_DYLIB)
+ target_link_libraries(${target} ${type} MLIR)
+ else()
+ target_link_libraries(${target} ${type} ${ARGN})
+ endif()
+endfunction()
diff --git a/mlir/tools/mlir-cpu-runner/CMakeLists.txt b/mlir/tools/mlir-cpu-runner/CMakeLists.txt
index ae6dbceca855d1..811583b97bc71d 100644
--- a/mlir/tools/mlir-cpu-runner/CMakeLists.txt
+++ b/mlir/tools/mlir-cpu-runner/CMakeLists.txt
@@ -11,12 +11,10 @@ add_mlir_tool(mlir-cpu-runner
EXPORT_SYMBOLS
)
llvm_update_compile_flags(mlir-cpu-runner)
-target_link_libraries(mlir-cpu-runner PRIVATE
+mlir_target_link_libraries(mlir-cpu-runner PRIVATE
MLIRAnalysis
MLIRBuiltinToLLVMIRTranslation
- MLIRExecutionEngine
MLIRIR
- MLIRJitRunner
MLIRLLVMDialect
MLIRLLVMToLLVMIRTranslation
MLIRToLLVMIRTranslationRegistration
@@ -24,3 +22,7 @@ target_link_libraries(mlir-cpu-runner PRIVATE
MLIRTargetLLVMIRExport
MLIRSupport
)
+target_link_libraries(mlir-cpu-runner PRIVATE
+ MLIRExecutionEngine
+ MLIRJitRunner
+ )
diff --git a/mlir/tools/mlir-lsp-server/CMakeLists.txt b/mlir/tools/mlir-lsp-server/CMakeLists.txt
index 8ff9cc2f07e8eb..6932e0f3977951 100644
--- a/mlir/tools/mlir-lsp-server/CMakeLists.txt
+++ b/mlir/tools/mlir-lsp-server/CMakeLists.txt
@@ -38,7 +38,6 @@ set(LIBS
${conversion_libs}
${dialect_libs}
${extension_libs}
- ${test_libs}
MLIRAffineAnalysis
MLIRAnalysis
@@ -56,11 +55,9 @@ set(LIBS
add_mlir_tool(mlir-lsp-server
mlir-lsp-server.cpp
-
- DEPENDS
- ${LIBS}
)
-target_link_libraries(mlir-lsp-server PRIVATE ${LIBS})
+mlir_target_link_libraries(mlir-lsp-server PRIVATE ${LIBS})
+target_link_libraries(mlir-lsp-server PRIVATE ${test_libs})
llvm_update_compile_flags(mlir-lsp-server)
mlir_check_all_link_libraries(mlir-lsp-server)
diff --git a/mlir/tools/mlir-opt/CMakeLists.txt b/mlir/tools/mlir-opt/CMakeLists.txt
index 8b79de58fa1028..71ab67d94ef91f 100644
--- a/mlir/tools/mlir-opt/CMakeLists.txt
+++ b/mlir/tools/mlir-opt/CMakeLists.txt
@@ -45,6 +45,7 @@ if(MLIR_INCLUDE_TESTS)
MLIRTestReducer
MLIRTestTransforms
MLIRTilingInterfaceTestPasses
+ MLIRTosaTestPasses
MLIRVectorTestPasses
MLIRTestVectorToSPIRV
MLIRLLVMTestPasses
@@ -66,7 +67,6 @@ set(LIBS
${dialect_libs}
${conversion_libs}
${extension_libs}
- ${test_libs}
MLIRAffineAnalysis
MLIRAnalysis
@@ -99,11 +99,10 @@ add_mlir_library(MLIRMlirOptMain
add_mlir_tool(mlir-opt
mlir-opt.cpp
- DEPENDS
- ${LIBS}
SUPPORT_PLUGINS
)
-target_link_libraries(mlir-opt PRIVATE ${LIBS})
+mlir_target_link_libraries(mlir-opt PRIVATE ${LIBS})
+target_link_libraries(mlir-opt PRIVATE ${test_libs})
llvm_update_compile_flags(mlir-opt)
mlir_check_all_link_libraries(mlir-opt)
diff --git a/mlir/tools/mlir-parser-fuzzer/bytecode/CMakeLists.txt b/mlir/tools/mlir-parser-fuzzer/bytecode/CMakeLists.txt
index 7d922656ad12f4..e17b1588519898 100644
--- a/mlir/tools/mlir-parser-fuzzer/bytecode/CMakeLists.txt
+++ b/mlir/tools/mlir-parser-fuzzer/bytecode/CMakeLists.txt
@@ -6,7 +6,7 @@ add_llvm_fuzzer(mlir-bytecode-parser-fuzzer
mlir-bytecode-parser-fuzzer.cpp
DUMMY_MAIN DummyParserFuzzer.cpp
)
-target_link_libraries(mlir-bytecode-parser-fuzzer
+mlir_target_link_libraries(mlir-bytecode-parser-fuzzer
PUBLIC
MLIRIR
MLIRParser
diff --git a/mlir/tools/mlir-parser-fuzzer/text/CMakeLists.txt b/mlir/tools/mlir-parser-fuzzer/text/CMakeLists.txt
index a9c9e1047b54ef..b4a2bacc0ee0be 100644
--- a/mlir/tools/mlir-parser-fuzzer/text/CMakeLists.txt
+++ b/mlir/tools/mlir-parser-fuzzer/text/CMakeLists.txt
@@ -6,7 +6,7 @@ add_llvm_fuzzer(mlir-text-parser-fuzzer
mlir-text-parser-fuzzer.cpp
DUMMY_MAIN DummyParserFuzzer.cpp
)
-target_link_libraries(mlir-text-parser-fuzzer
+mlir_target_link_libraries(mlir-text-parser-fuzzer
PUBLIC
MLIRIR
MLIRParser
diff --git a/mlir/tools/mlir-query/CMakeLists.txt b/mlir/tools/mlir-query/CMakeLists.txt
index ef2e5a84b5569b..18263970a7bbc7 100644
--- a/mlir/tools/mlir-query/CMakeLists.txt
+++ b/mlir/tools/mlir-query/CMakeLists.txt
@@ -10,11 +10,11 @@ add_mlir_tool(mlir-query
mlir-query.cpp
)
llvm_update_compile_flags(mlir-query)
-target_link_libraries(mlir-query
+mlir_target_link_libraries(mlir-query
PRIVATE
${dialect_libs}
- ${test_libs}
MLIRQueryLib
)
+target_link_libraries(mlir-query PRIVATE ${test_libs})
mlir_check_link_libraries(mlir-query)
diff --git a/mlir/tools/mlir-reduce/CMakeLists.txt b/mlir/tools/mlir-reduce/CMakeLists.txt
index 8549dbf805f54e..d71ac861a29dca 100644
--- a/mlir/tools/mlir-reduce/CMakeLists.txt
+++ b/mlir/tools/mlir-reduce/CMakeLists.txt
@@ -10,7 +10,6 @@ endif()
set(LIBS
${conversion_libs}
${dialect_libs}
- ${test_libs}
MLIRDialect
MLIRIR
MLIRPass
@@ -19,12 +18,10 @@ set(LIBS
add_mlir_tool(mlir-reduce
mlir-reduce.cpp
-
- DEPENDS
- ${LIBS}
)
-target_link_libraries(mlir-reduce PRIVATE ${LIBS})
+mlir_target_link_libraries(mlir-reduce PRIVATE ${LIBS})
+target_link_libraries(mlir-reduce PRIVATE ${test_libs})
llvm_update_compile_flags(mlir-reduce)
mlir_check_all_link_libraries(mlir-reduce)
diff --git a/mlir/tools/mlir-rewrite/CMakeLists.txt b/mlir/tools/mlir-rewrite/CMakeLists.txt
index 5b8c1cd4553997..216491eb432af0 100644
--- a/mlir/tools/mlir-rewrite/CMakeLists.txt
+++ b/mlir/tools/mlir-rewrite/CMakeLists.txt
@@ -5,7 +5,6 @@ set(LLVM_LINK_COMPONENTS
set(LIBS
${dialect_libs}
- ${test_libs}
MLIRAffineAnalysis
MLIRAnalysis
@@ -24,11 +23,9 @@ include_directories(../../../clang/include)
add_mlir_tool(mlir-rewrite
mlir-rewrite.cpp
- DEPENDS
- ${LIBS}
SUPPORT_PLUGINS
)
-target_link_libraries(mlir-rewrite PRIVATE ${LIBS})
+mlir_target_link_libraries(mlir-rewrite PRIVATE ${LIBS})
llvm_update_compile_flags(mlir-rewrite)
mlir_check_all_link_libraries(mlir-rewrite)
diff --git a/mlir/tools/mlir-translate/CMakeLists.txt b/mlir/tools/mlir-translate/CMakeLists.txt
index a78131b8c356c0..b356e04bb1dc4a 100644
--- a/mlir/tools/mlir-translate/CMakeLists.txt
+++ b/mlir/tools/mlir-translate/CMakeLists.txt
@@ -9,11 +9,9 @@ add_mlir_tool(mlir-translate
mlir-translate.cpp
)
llvm_update_compile_flags(mlir-translate)
-target_link_libraries(mlir-translate
+mlir_target_link_libraries(mlir-translate
PRIVATE
${dialect_libs}
- ${translation_libs}
- ${test_libs}
MLIRIR
MLIRParser
MLIRPass
@@ -21,5 +19,10 @@ target_link_libraries(mlir-translate
MLIRTranslateLib
MLIRSupport
)
+target_link_libraries(mlir-translate
+ PRIVATE
+ ${translation_libs}
+ ${test_libs}
+ )
mlir_check_link_libraries(mlir-translate)
|
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.
@@ -717,3 +717,15 @@ function(mlir_check_all_link_libraries name) | |||
endforeach() | |||
endif() | |||
endfunction(mlir_check_all_link_libraries) | |||
|
|||
function(mlir_target_link_libraries target type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you document this? (why it is there and when/how it should be used?)
My concern isn't really in the context of this PR, but for people who have to read the cmake code later and try to figure out what's going on.
4c6a397
to
57fa6e4
Compare
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/89/builds/12531 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/138/builds/7670 Here is the relevant piece of the build log for the reference
|
e582865 should fix the buildbot failures. |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/130/builds/7465 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/80/builds/7581 Here is the relevant piece of the build log for the reference
|
This is a followup to llvm#119408, which switches unit test binaries to also use mlir_target_link_libraries() where necessary. This allows them to link against against the MLIR dylib.
This is a followup to #119408, which switches unit test binaries to also use mlir_target_link_libraries() where necessary. This allows them to link against against the MLIR dylib.
Just want to say: thank you a lot! With this in, I have finally added MLIR to Gentoo, and I think we're going to be ready for ClangIR too. Do you happen to know if libMLIR is good enough for Flang to link to? I'm about to start trying to port it to |
I haven't tried it, but I would expect libMLIR to work for flang as well. |
FWIW, this broke building on windows with mingw for me with
Looks somewhat similar to #106859. Anyways setting |
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.Actually, this already works when MLIR_BUILD_MLIR_C_DYLIB is enabled.