From 6beae9bca32169b6746d99fc4915d4b6ddd39792 Mon Sep 17 00:00:00 2001 From: Stephen Neuendorffer Date: Tue, 10 Sep 2019 15:42:21 -0700 Subject: [PATCH] Update CMakeLists.txt for shared library build There are several circular dependencies between libraries. These are explicitly marked as STATIC. Note that add_llvm_library is redundant with add_dependencies, so we don't have to have libraries in both places. --- examples/Linalg/Linalg1/lib/CMakeLists.txt | 7 +++--- lib/Analysis/CMakeLists.txt | 3 +-- lib/Conversion/GPUToNVVM/CMakeLists.txt | 2 ++ lib/Conversion/StandardToSPIRV/CMakeLists.txt | 1 + lib/Conversion/VectorToLLVM/CMakeLists.txt | 1 + lib/Dialect/AffineOps/CMakeLists.txt | 3 +-- lib/Dialect/FxpMathOps/CMakeLists.txt | 17 ++++++++------ lib/Dialect/GPU/CMakeLists.txt | 2 +- lib/Dialect/LLVMIR/CMakeLists.txt | 4 ++-- lib/Dialect/Linalg/CMakeLists.txt | 8 +++++-- lib/Dialect/LoopOps/CMakeLists.txt | 6 ++--- lib/Dialect/QuantOps/CMakeLists.txt | 2 ++ lib/Dialect/SPIRV/CMakeLists.txt | 3 ++- .../SPIRV/Serialization/CMakeLists.txt | 3 ++- lib/Dialect/StandardOps/CMakeLists.txt | 4 ++-- lib/ExecutionEngine/CMakeLists.txt | 8 +++++++ lib/Parser/CMakeLists.txt | 2 +- lib/Pass/CMakeLists.txt | 4 ++-- lib/Quantizer/CMakeLists.txt | 22 ++++++++++++------- lib/Support/CMakeLists.txt | 6 ++--- lib/Transforms/CMakeLists.txt | 1 + test/lib/TestDialect/CMakeLists.txt | 4 ++-- tools/mlir-opt/CMakeLists.txt | 9 +++++--- 23 files changed, 77 insertions(+), 45 deletions(-) diff --git a/examples/Linalg/Linalg1/lib/CMakeLists.txt b/examples/Linalg/Linalg1/lib/CMakeLists.txt index 84d73cbfa36e..80c73b6a7f7a 100644 --- a/examples/Linalg/Linalg1/lib/CMakeLists.txt +++ b/examples/Linalg/Linalg1/lib/CMakeLists.txt @@ -17,6 +17,7 @@ set(LIBS MLIRAnalysis MLIRControlFlowToCFG MLIREDSC + MLIRLinalg MLIRLLVMIR MLIRParser MLIRPass @@ -26,13 +27,13 @@ set(LIBS MLIRTransforms ) -add_llvm_library(Linalg1LLVMConversion +add_llvm_library(Linalg1LLVMConversion STATIC ConvertToLLVMDialect.cpp ) target_link_libraries(Linalg1LLVMConversion PUBLIC MLIRLLVMIR - MLIRControlFlowToCFG MLIRStandardOps) + Linalg1 MLIRControlFlowToCFG MLIRStandardOps MLIRStandardToLLVM MLIRLinalg) -add_llvm_library(Linalg1 +add_llvm_library(Linalg1 STATIC Analysis.cpp SliceOp.cpp ViewOp.cpp diff --git a/lib/Analysis/CMakeLists.txt b/lib/Analysis/CMakeLists.txt index e2b1d126cdfc..3c8e6160e182 100644 --- a/lib/Analysis/CMakeLists.txt +++ b/lib/Analysis/CMakeLists.txt @@ -16,5 +16,4 @@ add_llvm_library(MLIRAnalysis STATIC ADDITIONAL_HEADER_DIRS ${MLIR_MAIN_INCLUDE_DIR}/mlir/Analysis ) -add_dependencies(MLIRAnalysis MLIRAffineOps MLIRLoopOps) -target_link_libraries(MLIRAnalysis MLIRAffineOps MLIRLoopOps) +target_link_libraries(MLIRAnalysis MLIRAffineOps MLIRLoopOps MLIRPass) diff --git a/lib/Conversion/GPUToNVVM/CMakeLists.txt b/lib/Conversion/GPUToNVVM/CMakeLists.txt index 492f3a112feb..86303988d5f1 100644 --- a/lib/Conversion/GPUToNVVM/CMakeLists.txt +++ b/lib/Conversion/GPUToNVVM/CMakeLists.txt @@ -6,5 +6,7 @@ target_link_libraries(MLIRGPUtoNVVMTransforms MLIRGPU MLIRLLVMIR MLIRNVVMIR + MLIRStandardToLLVM + MLIRTransforms MLIRPass ) diff --git a/lib/Conversion/StandardToSPIRV/CMakeLists.txt b/lib/Conversion/StandardToSPIRV/CMakeLists.txt index be5311275036..b3ccaf27d310 100644 --- a/lib/Conversion/StandardToSPIRV/CMakeLists.txt +++ b/lib/Conversion/StandardToSPIRV/CMakeLists.txt @@ -19,6 +19,7 @@ target_link_libraries(MLIRSPIRVConversion MLIRPass MLIRSPIRV MLIRSupport + MLIRTransforms MLIRTransformUtils MLIRSPIRV MLIRStandardOps diff --git a/lib/Conversion/VectorToLLVM/CMakeLists.txt b/lib/Conversion/VectorToLLVM/CMakeLists.txt index a75b6c1e98af..bacc2e4713a6 100644 --- a/lib/Conversion/VectorToLLVM/CMakeLists.txt +++ b/lib/Conversion/VectorToLLVM/CMakeLists.txt @@ -6,6 +6,7 @@ add_llvm_library(MLIRVectorToLLVM ) set(LIBS MLIRLLVMIR + MLIRStandardToLLVM MLIRTransforms LLVMCore LLVMSupport diff --git a/lib/Dialect/AffineOps/CMakeLists.txt b/lib/Dialect/AffineOps/CMakeLists.txt index dbe469369a3d..6af726c385ab 100644 --- a/lib/Dialect/AffineOps/CMakeLists.txt +++ b/lib/Dialect/AffineOps/CMakeLists.txt @@ -1,4 +1,4 @@ -add_llvm_library(MLIRAffineOps +add_llvm_library(MLIRAffineOps STATIC AffineOps.cpp DialectRegistration.cpp @@ -7,4 +7,3 @@ add_llvm_library(MLIRAffineOps ) add_dependencies(MLIRAffineOps MLIRAffineOpsIncGen MLIRIR MLIRStandardOps) target_link_libraries(MLIRAffineOps MLIRIR MLIRStandardOps) - diff --git a/lib/Dialect/FxpMathOps/CMakeLists.txt b/lib/Dialect/FxpMathOps/CMakeLists.txt index 9eddc5545f58..fbf6e168cebc 100644 --- a/lib/Dialect/FxpMathOps/CMakeLists.txt +++ b/lib/Dialect/FxpMathOps/CMakeLists.txt @@ -6,10 +6,13 @@ add_llvm_library(MLIRFxpMathOps ADDITIONAL_HEADER_DIRS ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/FxpMathOps ) -add_dependencies(MLIRFxpMathOps - MLIRFxpMathOpsIncGen - MLIRQuantOps - MLIRIR - MLIRPass - MLIRSupport - MLIRStandardOps) +add_dependencies( + MLIRFxpMathOps + MLIRFxpMathOpsIncGen) +target_link_libraries( + MLIRFxpMathOps + MLIRQuantOps + MLIRIR + MLIRPass + MLIRSupport + MLIRStandardOps) diff --git a/lib/Dialect/GPU/CMakeLists.txt b/lib/Dialect/GPU/CMakeLists.txt index 09da5cc16e9e..542b6fdf953b 100644 --- a/lib/Dialect/GPU/CMakeLists.txt +++ b/lib/Dialect/GPU/CMakeLists.txt @@ -7,4 +7,4 @@ add_llvm_library(MLIRGPU ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/GPU ) add_dependencies(MLIRGPU MLIRGPUOpsIncGen MLIRIR LLVMSupport) -target_link_libraries(MLIRGPU MLIRIR MLIRStandardOps LLVMSupport) +target_link_libraries(MLIRGPU MLIRIR MLIRPass MLIRStandardOps LLVMSupport) diff --git a/lib/Dialect/LLVMIR/CMakeLists.txt b/lib/Dialect/LLVMIR/CMakeLists.txt index 4469e7606d39..df1de0d2f3c9 100644 --- a/lib/Dialect/LLVMIR/CMakeLists.txt +++ b/lib/Dialect/LLVMIR/CMakeLists.txt @@ -5,7 +5,7 @@ add_llvm_library(MLIRLLVMIR ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/LLVMIR ) add_dependencies(MLIRLLVMIR MLIRLLVMOpsIncGen MLIRLLVMConversionsIncGen LLVMAsmParser LLVMCore LLVMSupport) -target_link_libraries(MLIRLLVMIR LLVMAsmParser LLVMCore LLVMSupport) +target_link_libraries(MLIRLLVMIR MLIRIR LLVMAsmParser LLVMCore LLVMSupport) add_llvm_library(MLIRNVVMIR IR/NVVMDialect.cpp @@ -14,4 +14,4 @@ add_llvm_library(MLIRNVVMIR ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/LLVMIR ) add_dependencies(MLIRNVVMIR MLIRNVVMOpsIncGen MLIRNVVMConversionsIncGen LLVMAsmParser LLVMCore LLVMSupport) -target_link_libraries(MLIRNVVMIR LLVMAsmParser LLVMCore LLVMSupport) +target_link_libraries(MLIRNVVMIR MLIRLLVMIR MLIRIR LLVMAsmParser LLVMCore LLVMSupport) diff --git a/lib/Dialect/Linalg/CMakeLists.txt b/lib/Dialect/Linalg/CMakeLists.txt index 8eea5dc7137e..f666770e39af 100644 --- a/lib/Dialect/Linalg/CMakeLists.txt +++ b/lib/Dialect/Linalg/CMakeLists.txt @@ -1,4 +1,4 @@ -add_llvm_library(MLIRLinalg +add_llvm_library(MLIRLinalg STATIC LinalgRegistration.cpp Analysis/DependenceAnalysis.cpp IR/LinalgOps.cpp @@ -17,8 +17,12 @@ add_llvm_library(MLIRLinalg add_dependencies(MLIRLinalg - MLIRAffineOps MLIRLinalgOpsIncGen MLIRLinalgLibraryOpsIncGen + ) +target_link_libraries(MLIRLinalg + + MLIRAffineOps + MLIRIR MLIRStandardToLLVM ) diff --git a/lib/Dialect/LoopOps/CMakeLists.txt b/lib/Dialect/LoopOps/CMakeLists.txt index ce4a66689004..93b7c436368f 100644 --- a/lib/Dialect/LoopOps/CMakeLists.txt +++ b/lib/Dialect/LoopOps/CMakeLists.txt @@ -1,9 +1,9 @@ file(GLOB globbed *.c *.cpp) -add_llvm_library(MLIRLoopOps +add_llvm_library(MLIRLoopOps STATIC ${globbed} ADDITIONAL_HEADER_DIRS ${MLIR_MAIN_INCLUDE_DIR}/mlir/LoopOps ) -add_dependencies(MLIRLoopOps MLIRLoopOpsIncGen MLIRStandardOps LLVMSupport) -target_link_libraries(MLIRLoopOps LLVMSupport) +add_dependencies(MLIRLoopOps MLIRLoopOpsIncGen MLIRStandardOps MLIRIR LLVMSupport) +target_link_libraries(MLIRLoopOps MLIRStandardOps MLIRIR LLVMSupport) diff --git a/lib/Dialect/QuantOps/CMakeLists.txt b/lib/Dialect/QuantOps/CMakeLists.txt index 74b3f3c4525c..a2df6e7379f7 100644 --- a/lib/Dialect/QuantOps/CMakeLists.txt +++ b/lib/Dialect/QuantOps/CMakeLists.txt @@ -19,3 +19,5 @@ add_dependencies(MLIRQuantOps MLIRQuantOpsIncGen MLIRSupport MLIRStandardOps) + +target_link_libraries(MLIRQuantOps MLIRIR MLIRPass MLIRParser MLIRSupport MLIRTransforms MLIRAnalysis MLIRStandardOps LLVMSupport) diff --git a/lib/Dialect/SPIRV/CMakeLists.txt b/lib/Dialect/SPIRV/CMakeLists.txt index 2803b90ea31e..345d885f6f3a 100644 --- a/lib/Dialect/SPIRV/CMakeLists.txt +++ b/lib/Dialect/SPIRV/CMakeLists.txt @@ -16,6 +16,7 @@ add_dependencies(MLIRSPIRV target_link_libraries(MLIRSPIRV MLIRIR MLIRParser - MLIRSupport) + MLIRSupport + MLIRTranslation) add_subdirectory(Serialization) diff --git a/lib/Dialect/SPIRV/Serialization/CMakeLists.txt b/lib/Dialect/SPIRV/Serialization/CMakeLists.txt index e652bf317fbf..bfe3a346ce62 100644 --- a/lib/Dialect/SPIRV/Serialization/CMakeLists.txt +++ b/lib/Dialect/SPIRV/Serialization/CMakeLists.txt @@ -15,4 +15,5 @@ add_dependencies(MLIRSPIRVSerialization target_link_libraries(MLIRSPIRVSerialization MLIRIR MLIRSPIRV - MLIRSupport) + MLIRSupport + MLIRTranslation) diff --git a/lib/Dialect/StandardOps/CMakeLists.txt b/lib/Dialect/StandardOps/CMakeLists.txt index f10c173af8a3..b3ddcf987178 100644 --- a/lib/Dialect/StandardOps/CMakeLists.txt +++ b/lib/Dialect/StandardOps/CMakeLists.txt @@ -1,9 +1,9 @@ file(GLOB globbed *.c *.cpp) -add_llvm_library(MLIRStandardOps +add_llvm_library(MLIRStandardOps STATIC ${globbed} ADDITIONAL_HEADER_DIRS ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/StandardOps ) add_dependencies(MLIRStandardOps MLIRStandardOpsIncGen LLVMSupport) -target_link_libraries(MLIRStandardOps LLVMSupport) +target_link_libraries(MLIRStandardOps MLIRIR MLIRParser LLVMSupport) diff --git a/lib/ExecutionEngine/CMakeLists.txt b/lib/ExecutionEngine/CMakeLists.txt index 07061b1db119..b508de08a1a4 100644 --- a/lib/ExecutionEngine/CMakeLists.txt +++ b/lib/ExecutionEngine/CMakeLists.txt @@ -11,11 +11,19 @@ target_link_libraries(MLIRExecutionEngine MLIRLLVMIR MLIRTargetLLVMIR + Linalg1LLVMConversion + LLVMAggressiveInstCombine + LLVMAnalysis LLVMBitReader LLVMBitWriter LLVMExecutionEngine + LLVMInstCombine LLVMOrcJIT + LLVMMC + LLVMScalarOpts LLVMSupport + LLVMTarget LLVMTransformUtils + LLVMVectorize ${outlibs}) diff --git a/lib/Parser/CMakeLists.txt b/lib/Parser/CMakeLists.txt index 9fd29ae78791..061e9203a51f 100644 --- a/lib/Parser/CMakeLists.txt +++ b/lib/Parser/CMakeLists.txt @@ -1,4 +1,4 @@ -add_llvm_library(MLIRParser +add_llvm_library(MLIRParser STATIC Lexer.cpp Parser.cpp Token.cpp diff --git a/lib/Pass/CMakeLists.txt b/lib/Pass/CMakeLists.txt index 05122f5a7ed4..b4fed2510794 100644 --- a/lib/Pass/CMakeLists.txt +++ b/lib/Pass/CMakeLists.txt @@ -1,9 +1,9 @@ file(GLOB globbed *.c *.cpp) -add_llvm_library(MLIRPass +add_llvm_library(MLIRPass STATIC ${globbed} ADDITIONAL_HEADER_DIRS ${MLIR_MAIN_INCLUDE_DIR}/mlir/Pass ) -add_dependencies(MLIRPass MLIRAnalysis MLIRIR LLVMSupport) +add_dependencies(MLIRPass MLIRIR LLVMSupport) target_link_libraries(MLIRPass MLIRAnalysis MLIRIR LLVMSupport) diff --git a/lib/Quantizer/CMakeLists.txt b/lib/Quantizer/CMakeLists.txt index bc157d0e9799..ce36e4cd8c53 100644 --- a/lib/Quantizer/CMakeLists.txt +++ b/lib/Quantizer/CMakeLists.txt @@ -10,11 +10,12 @@ add_llvm_library(MLIRQuantizerSupport ADDITIONAL_HEADER_DIRS ) -add_dependencies(MLIRQuantizerSupport - MLIRIR - MLIRQuantOps - MLIRSupport - MLIRStandardOps) +target_link_libraries( + MLIRQuantizerSupport + MLIRIR + MLIRQuantOps + MLIRSupport + MLIRStandardOps) # Configurations. add_llvm_library(MLIRQuantizerFxpMathConfig @@ -22,9 +23,14 @@ add_llvm_library(MLIRQuantizerFxpMathConfig ADDITIONAL_HEADER_DIRS ) -add_dependencies(MLIRQuantizerFxpMathConfig - MLIRFxpMathOpsIncGen - MLIRQuantizerSupport) +add_dependencies( + MLIRQuantizerFxpMathConfig + MLIRFxpMathOpsIncGen) +target_link_libraries( + MLIRQuantizerFxpMathConfig + MLIRFxpMathOps + MLIRIR + MLIRQuantizerSupport) # Transforms. add_llvm_library(MLIRQuantizerTransforms diff --git a/lib/Support/CMakeLists.txt b/lib/Support/CMakeLists.txt index a927fc681c4f..28059d77115e 100644 --- a/lib/Support/CMakeLists.txt +++ b/lib/Support/CMakeLists.txt @@ -13,7 +13,7 @@ add_llvm_library(MLIRSupport ADDITIONAL_HEADER_DIRS ${MLIR_MAIN_INCLUDE_DIR}/mlir/Support ) -target_link_libraries(MLIRSupport LLVMSupport) +target_link_libraries(MLIRSupport Threads::Threads LLVMSupport) add_llvm_library(MLIROptMain MlirOptMain.cpp @@ -21,7 +21,7 @@ add_llvm_library(MLIROptMain ADDITIONAL_HEADER_DIRS ${MLIR_MAIN_INCLUDE_DIR}/mlir/Support ) -target_link_libraries(MLIROptMain LLVMSupport) +target_link_libraries(MLIROptMain MLIRIR MLIRParser LLVMSupport) add_llvm_library(MLIRTranslateClParser TranslateClParser.cpp @@ -29,7 +29,7 @@ add_llvm_library(MLIRTranslateClParser ADDITIONAL_HEADER_DIRS ${MLIR_MAIN_INCLUDE_DIR}/mlir/Support ) -target_link_libraries(MLIRTranslateClParser LLVMSupport) +target_link_libraries(MLIRTranslateClParser MLIRTranslation MLIRIR MLIRAnalysis MLIRParser LLVMSupport) add_llvm_library(MLIRJitRunner JitRunner.cpp diff --git a/lib/Transforms/CMakeLists.txt b/lib/Transforms/CMakeLists.txt index 184a6f952c9a..094b533db28f 100644 --- a/lib/Transforms/CMakeLists.txt +++ b/lib/Transforms/CMakeLists.txt @@ -31,6 +31,7 @@ add_dependencies(MLIRTransforms MLIRStandardOpsIncGen) target_link_libraries(MLIRTransforms MLIRAffineOps MLIRAnalysis + MLIREDSC MLIRLoopOps MLIRPass MLIRTransformUtils diff --git a/test/lib/TestDialect/CMakeLists.txt b/test/lib/TestDialect/CMakeLists.txt index 77bcd4201b74..5abf0786aa03 100644 --- a/test/lib/TestDialect/CMakeLists.txt +++ b/test/lib/TestDialect/CMakeLists.txt @@ -15,11 +15,11 @@ add_llvm_library(MLIRTestDialect ) add_dependencies(MLIRTestDialect MLIRTestOpsIncGen - MLIRIR - LLVMSupport ) target_link_libraries(MLIRTestDialect MLIRDialect MLIRIR + MLIRPass + MLIRTransforms LLVMSupport ) diff --git a/tools/mlir-opt/CMakeLists.txt b/tools/mlir-opt/CMakeLists.txt index 2f57eb02f18d..2f651939dcb9 100644 --- a/tools/mlir-opt/CMakeLists.txt +++ b/tools/mlir-opt/CMakeLists.txt @@ -3,17 +3,21 @@ set(LLVM_OPTIONAL_SOURCES ) set(LIB_LIBS + Linalg1LLVMConversion MLIRAnalysis + MLIRIR MLIRLLVMIR + MLIROptMain MLIRParser MLIRPass - MLIRTransforms + MLIRQuantizerSupport MLIRSupport + MLIRTransforms ) add_llvm_library(MLIRMlirOptLib mlir-opt.cpp ) -target_link_libraries(MLIRMlirOptLib ${LIB_LIBS}) +target_link_libraries(MLIRMlirOptLib ${LIB_LIBS} MLIRIR) set(LIBS MLIRAffineOps @@ -40,7 +44,6 @@ set(LIBS MLIRStandardToLLVM MLIRTransforms MLIRTestDialect - MLIRTestPass MLIRTestTransforms MLIRSupport MLIRVectorOps