File tree 11 files changed +46
-28
lines changed
11 files changed +46
-28
lines changed Original file line number Diff line number Diff line change @@ -153,6 +153,9 @@ set(MLIR_INSTALL_AGGREGATE_OBJECTS 1 CACHE BOOL
153
153
154
154
set (MLIR_BUILD_MLIR_C_DYLIB 0 CACHE BOOL "Builds libMLIR-C shared library." )
155
155
156
+ set (MLIR_LINK_MLIR_DYLIB ${LLVM_LINK_LLVM_DYLIB} CACHE BOOL
157
+ "Link tools against libMLIR.so" )
158
+
156
159
configure_file (
157
160
${MLIR_MAIN_INCLUDE_DIR} /mlir/Config/mlir-config.h.cmake
158
161
${MLIR_INCLUDE_DIR} /mlir/Config/mlir-config.h)
Original file line number Diff line number Diff line change @@ -717,3 +717,23 @@ function(mlir_check_all_link_libraries name)
717
717
endforeach ()
718
718
endif ()
719
719
endfunction (mlir_check_all_link_libraries)
720
+
721
+ # Link target against a list of MLIR libraries. If MLIR_LINK_MLIR_DYLIB is
722
+ # enabled, this will link against the MLIR dylib instead of the static
723
+ # libraries.
724
+ #
725
+ # This function should be used instead of target_link_libraries() when linking
726
+ # MLIR libraries that are part of the MLIR dylib. For libraries that are not
727
+ # part of the dylib (like test libraries), target_link_libraries() should be
728
+ # used.
729
+ function (mlir_target_link_libraries target type )
730
+ if (TARGET obj.${target} )
731
+ target_link_libraries (obj.${target} ${ARGN} )
732
+ endif ()
733
+
734
+ if (MLIR_LINK_MLIR_DYLIB)
735
+ target_link_libraries (${target} ${type} MLIR)
736
+ else ()
737
+ target_link_libraries (${target} ${type} ${ARGN} )
738
+ endif ()
739
+ endfunction ()
Original file line number Diff line number Diff line change @@ -11,16 +11,18 @@ add_mlir_tool(mlir-cpu-runner
11
11
EXPORT_SYMBOLS
12
12
)
13
13
llvm_update_compile_flags(mlir-cpu-runner)
14
- target_link_libraries (mlir-cpu-runner PRIVATE
14
+ mlir_target_link_libraries (mlir-cpu-runner PRIVATE
15
15
MLIRAnalysis
16
16
MLIRBuiltinToLLVMIRTranslation
17
- MLIRExecutionEngine
18
17
MLIRIR
19
- MLIRJitRunner
20
18
MLIRLLVMDialect
21
19
MLIRLLVMToLLVMIRTranslation
22
20
MLIRToLLVMIRTranslationRegistration
23
21
MLIRParser
24
22
MLIRTargetLLVMIRExport
25
23
MLIRSupport
26
24
)
25
+ target_link_libraries (mlir-cpu-runner PRIVATE
26
+ MLIRExecutionEngine
27
+ MLIRJitRunner
28
+ )
Original file line number Diff line number Diff line change @@ -38,7 +38,6 @@ set(LIBS
38
38
${conversion_libs}
39
39
${dialect_libs}
40
40
${extension_libs}
41
- ${test_libs}
42
41
43
42
MLIRAffineAnalysis
44
43
MLIRAnalysis
@@ -56,11 +55,9 @@ set(LIBS
56
55
57
56
add_mlir_tool(mlir-lsp-server
58
57
mlir-lsp-server.cpp
59
-
60
- DEPENDS
61
- ${LIBS}
62
58
)
63
- target_link_libraries (mlir-lsp-server PRIVATE ${LIBS} )
59
+ mlir_target_link_libraries(mlir-lsp-server PRIVATE ${LIBS} )
60
+ target_link_libraries (mlir-lsp-server PRIVATE ${test_libs} )
64
61
llvm_update_compile_flags(mlir-lsp-server)
65
62
66
63
mlir_check_all_link_libraries(mlir-lsp-server)
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ if(MLIR_INCLUDE_TESTS)
45
45
MLIRTestReducer
46
46
MLIRTestTransforms
47
47
MLIRTilingInterfaceTestPasses
48
+ MLIRTosaTestPasses
48
49
MLIRVectorTestPasses
49
50
MLIRTestVectorToSPIRV
50
51
MLIRLLVMTestPasses
@@ -66,7 +67,6 @@ set(LIBS
66
67
${dialect_libs}
67
68
${conversion_libs}
68
69
${extension_libs}
69
- ${test_libs}
70
70
71
71
MLIRAffineAnalysis
72
72
MLIRAnalysis
@@ -99,11 +99,10 @@ add_mlir_library(MLIRMlirOptMain
99
99
add_mlir_tool(mlir-opt
100
100
mlir-opt.cpp
101
101
102
- DEPENDS
103
- ${LIBS}
104
102
SUPPORT_PLUGINS
105
103
)
106
- target_link_libraries (mlir-opt PRIVATE ${LIBS} )
104
+ mlir_target_link_libraries(mlir-opt PRIVATE ${LIBS} )
105
+ target_link_libraries (mlir-opt PRIVATE ${test_libs} )
107
106
llvm_update_compile_flags(mlir-opt)
108
107
109
108
mlir_check_all_link_libraries(mlir-opt)
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ add_llvm_fuzzer(mlir-bytecode-parser-fuzzer
6
6
mlir-bytecode-parser-fuzzer.cpp
7
7
DUMMY_MAIN DummyParserFuzzer.cpp
8
8
)
9
- target_link_libraries (mlir-bytecode-parser-fuzzer
9
+ mlir_target_link_libraries (mlir-bytecode-parser-fuzzer
10
10
PUBLIC
11
11
MLIRIR
12
12
MLIRParser
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ add_llvm_fuzzer(mlir-text-parser-fuzzer
6
6
mlir-text-parser-fuzzer.cpp
7
7
DUMMY_MAIN DummyParserFuzzer.cpp
8
8
)
9
- target_link_libraries (mlir-text-parser-fuzzer
9
+ mlir_target_link_libraries (mlir-text-parser-fuzzer
10
10
PUBLIC
11
11
MLIRIR
12
12
MLIRParser
Original file line number Diff line number Diff line change @@ -10,11 +10,11 @@ add_mlir_tool(mlir-query
10
10
mlir-query.cpp
11
11
)
12
12
llvm_update_compile_flags(mlir-query)
13
- target_link_libraries (mlir-query
13
+ mlir_target_link_libraries (mlir-query
14
14
PRIVATE
15
15
${dialect_libs}
16
- ${test_libs}
17
16
MLIRQueryLib
18
17
)
18
+ target_link_libraries (mlir-query PRIVATE ${test_libs} )
19
19
20
20
mlir_check_link_libraries(mlir-query)
Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ endif()
10
10
set (LIBS
11
11
${conversion_libs}
12
12
${dialect_libs}
13
- ${test_libs}
14
13
MLIRDialect
15
14
MLIRIR
16
15
MLIRPass
@@ -19,12 +18,10 @@ set(LIBS
19
18
20
19
add_mlir_tool(mlir-reduce
21
20
mlir-reduce.cpp
22
-
23
- DEPENDS
24
- ${LIBS}
25
21
)
26
22
27
- target_link_libraries (mlir-reduce PRIVATE ${LIBS} )
23
+ mlir_target_link_libraries(mlir-reduce PRIVATE ${LIBS} )
24
+ target_link_libraries (mlir-reduce PRIVATE ${test_libs} )
28
25
llvm_update_compile_flags(mlir-reduce)
29
26
30
27
mlir_check_all_link_libraries(mlir-reduce)
Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ set(LLVM_LINK_COMPONENTS
5
5
6
6
set (LIBS
7
7
${dialect_libs}
8
- ${test_libs}
9
8
10
9
MLIRAffineAnalysis
11
10
MLIRAnalysis
@@ -24,11 +23,9 @@ include_directories(../../../clang/include)
24
23
add_mlir_tool(mlir-rewrite
25
24
mlir-rewrite.cpp
26
25
27
- DEPENDS
28
- ${LIBS}
29
26
SUPPORT_PLUGINS
30
27
)
31
- target_link_libraries (mlir-rewrite PRIVATE ${LIBS} )
28
+ mlir_target_link_libraries (mlir-rewrite PRIVATE ${LIBS} )
32
29
llvm_update_compile_flags(mlir-rewrite)
33
30
34
31
mlir_check_all_link_libraries(mlir-rewrite)
Original file line number Diff line number Diff line change @@ -9,17 +9,20 @@ add_mlir_tool(mlir-translate
9
9
mlir-translate.cpp
10
10
)
11
11
llvm_update_compile_flags(mlir-translate)
12
- target_link_libraries (mlir-translate
12
+ mlir_target_link_libraries (mlir-translate
13
13
PRIVATE
14
14
${dialect_libs}
15
- ${translation_libs}
16
- ${test_libs}
17
15
MLIRIR
18
16
MLIRParser
19
17
MLIRPass
20
18
MLIRSPIRVDialect
21
19
MLIRTranslateLib
22
20
MLIRSupport
23
21
)
22
+ target_link_libraries (mlir-translate
23
+ PRIVATE
24
+ ${translation_libs}
25
+ ${test_libs}
26
+ )
24
27
25
28
mlir_check_link_libraries(mlir-translate)
You can’t perform that action at this time.
0 commit comments