Skip to content

Commit e4f0db5

Browse files
committed
Fix issues with MLIR build when using BUILD_SHARED_LIBS
1 parent a9d7af0 commit e4f0db5

File tree

9 files changed

+57
-24
lines changed

9 files changed

+57
-24
lines changed

mlir/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ include_directories( ${MLIR_INCLUDE_DIR})
5555
add_subdirectory(include/mlir)
5656
add_subdirectory(lib)
5757
add_subdirectory(tools)
58-
add_subdirectory(unittests)
58+
if ( LLVM_INCLUDE_TESTS )
59+
add_subdirectory(unittests)
60+
endif()
5961
add_subdirectory(test)
6062

6163
if( LLVM_INCLUDE_EXAMPLES )

mlir/include/mlir/Dialect/Shape/IR/Shape.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ namespace shape {
2424
class ShapeDialect : public Dialect {
2525
public:
2626
/// Create the dialect in the given `context`.
27-
explicit ShapeDialect(MLIRContext *context);
27+
explicit ShapeDialect(MLIRContext *context)
28+
: Dialect("shape", context) {}
2829
};
2930

3031
namespace ShapeTypes {

mlir/lib/Dialect/Shape/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ add_llvm_library(MLIRShape
55
ADDITIONAL_HEADER_DIRS
66
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/Shape
77
)
8-
add_dependencies(MLIRShape MLIRShapeOpsIncGen LLVMSupport)
9-
target_link_libraries(MLIRShape LLVMSupport)
8+
add_dependencies(MLIRShape MLIRIR MLIRShapeOpsIncGen LLVMSupport)
9+
target_link_libraries(MLIRShape MLIRIR LLVMSupport)

mlir/lib/Support/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ add_llvm_library(MLIRJitRunner
4242
JitRunner.cpp
4343
)
4444
target_link_libraries(MLIRJitRunner PRIVATE
45+
MLIRAllDialects
4546
MLIRExecutionEngine
4647
MLIRIR
4748
MLIRParser

mlir/test/CMakeLists.txt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,14 @@ if(MLIR_CUDA_RUNNER_ENABLED)
6161
)
6262
endif()
6363

64-
add_lit_testsuite(check-mlir "Running the MLIR regression tests"
65-
${CMAKE_CURRENT_BINARY_DIR}
66-
DEPENDS ${MLIR_TEST_DEPENDS}
64+
if(LLVM_BUILD_TESTS)
65+
add_lit_testsuite(check-mlir "Running the MLIR regression tests"
66+
${CMAKE_CURRENT_BINARY_DIR}
67+
DEPENDS ${MLIR_TEST_DEPENDS}
6768
)
68-
set_target_properties(check-mlir PROPERTIES FOLDER "Tests")
69+
set_target_properties(check-mlir PROPERTIES FOLDER "Tests")
6970

70-
add_lit_testsuites(MLIR ${CMAKE_CURRENT_SOURCE_DIR}
71-
DEPENDS ${MLIR_TEST_DEPS}
72-
)
71+
add_lit_testsuites(MLIR ${CMAKE_CURRENT_SOURCE_DIR}
72+
DEPENDS ${MLIR_TEST_DEPS}
73+
)
74+
endif()

mlir/test/EDSC/CMakeLists.txt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ target_link_libraries(mlir-edsc-builder-api-test
2121

2222
target_include_directories(mlir-edsc-builder-api-test PRIVATE ..)
2323

24-
whole_archive_link(mlir-edsc-builder-api-test
25-
MLIRAffineOps
26-
MLIRLinalgOps
27-
MLIRLoopOps
28-
MLIRStandardOps
29-
MLIRVectorOps
30-
MLIRTransforms
31-
)
24+
if( NOT BUILD_SHARED_LIBS )
25+
whole_archive_link(mlir-edsc-builder-api-test
26+
MLIRAffineOps
27+
MLIRLinalgOps
28+
MLIRLoopOps
29+
MLIRStandardOps
30+
MLIRVectorOps
31+
MLIRTransforms
32+
)
33+
endif()

mlir/test/SDBM/CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ target_link_libraries(mlir-sdbm-api-test
1414

1515
target_include_directories(mlir-sdbm-api-test PRIVATE ..)
1616

17-
whole_archive_link(mlir-sdbm-api-test
18-
MLIRSDBM
19-
)
17+
if( NOT BUILD_SHARED_LIBS)
18+
whole_archive_link(mlir-sdbm-api-test
19+
MLIRSDBM
20+
)
21+
endif()

mlir/tools/mlir-opt/CMakeLists.txt

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,32 @@ set(LLVM_OPTIONAL_SOURCES
44

55
set(LIB_LIBS
66
MLIRAnalysis
7-
MLIRLLVMIR
7+
MLIRAllDialects
8+
MLIRAffineToStandard
9+
MLIRGPUtoCUDATransforms
10+
MLIRGPUtoNVVMTransforms
11+
MLIRGPUtoROCDLTransforms
12+
MLIRGPUtoSPIRVTransforms
13+
MLIRGPUtoVulkanTransforms
14+
MLIRLinalgTransforms
15+
MLIRLinalgToLLVM
16+
MLIRLinalgToSPIRVTransforms
17+
MLIRLoopsToGPU
18+
MLIRLoopToStandard
19+
MLIRStandardToLLVM
20+
MLIRStandardToSPIRVTransforms
21+
MLIRSPIRVTransforms
22+
MLIRSPIRVTestPasses
23+
MLIRVectorToLLVM
24+
MLIRVectorToLoops
825
MLIROptLib
926
MLIRParser
1027
MLIRPass
1128
MLIRTransforms
29+
MLIRTestIR
30+
MLIRTestPass
31+
MLIRTestTransforms
32+
MLIRQuantizerTransforms
1233
MLIRSupport
1334
)
1435
add_llvm_library(MLIRMlirOptMain

mlir/tools/mlir-translate/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,7 @@ add_llvm_tool(mlir-translate
2020
mlir-translate.cpp
2121
)
2222
llvm_update_compile_flags(mlir-translate)
23-
whole_archive_link(mlir-translate ${FULL_LIBS})
23+
if( NOT BUILD_SHARED_LIBS)
24+
whole_archive_link(mlir-translate ${FULL_LIBS})
25+
endif()
2426
target_link_libraries(mlir-translate PRIVATE MLIRIR MLIRTranslateClParser ${LIBS} LLVMSupport)

0 commit comments

Comments
 (0)