[MLIR][GPU] Fix build files for mlir-opt.
authorStephan Herhut <herhut@google.com>
Wed, 5 Feb 2020 17:06:36 +0000 (17:06 +0000)
committerMehdi Amini <joker-eph@gmail.com>
Wed, 5 Feb 2020 17:13:48 +0000 (17:13 +0000)
The recent refactoring of build files broke building with the MIR CUDA
integration enabled. This fixes it by adding some additional
dependencies to mlir-opt.

Differential Revision: https://reviews.llvm.org/D74041

mlir/lib/Conversion/GPUToCUDA/CMakeLists.txt
mlir/tools/mlir-opt/CMakeLists.txt

index 4eddb78..a34ffea 100644 (file)
@@ -1,16 +1,16 @@
 if(MLIR_CUDA_CONVERSIONS_ENABLED)
-  llvm_map_components_to_libnames(nvptx "NVPTX")
-
   add_llvm_library(MLIRGPUtoCUDATransforms
     ConvertKernelFuncToCubin.cpp
     ConvertLaunchFuncToCudaCalls.cpp
   )
   target_link_libraries(MLIRGPUtoCUDATransforms
+    LLVMNVPTXCodeGen
+    LLVMNVPTXDesc
+    LLVMNVPTXInfo
     MLIRGPU
     MLIRLLVMIR
     MLIRNVVMIR
     MLIRPass
     MLIRTargetNVVMIR
-    ${nvptx}
   )
 endif()
index 47305b7..b3605f4 100644 (file)
@@ -18,7 +18,7 @@ target_link_libraries(MLIRMlirOptLib
   ${LIB_LIBS}
 )
 
-set(LIBS
+set(FULL_LINK_LIBS
   MLIRAnalysis
   MLIRAffineOps
   MLIRAffineToStandard
@@ -68,8 +68,23 @@ set(LIBS
   MLIRVectorToLLVM
   MLIRVectorToLoops
 )
+set(LIBS
+  MLIRIR
+  MLIROptMain
+  LLVMSupport
+  LLVMCore
+  LLVMAsmParser
+)
+
 if(MLIR_CUDA_CONVERSIONS_ENABLED)
   list(APPEND LIBS
+    LLVMNVPTXCodeGen
+    LLVMNVPTXDesc
+    LLVMNVPTXInfo
+    MLIRTargetNVVMIR
+  )
+  # Order matters here, so insert at front.
+  list(INSERT FULL_LINK_LIBS 0
     MLIRGPUtoCUDATransforms
   )
 endif()
@@ -78,7 +93,7 @@ add_llvm_tool(mlir-opt
 )
 llvm_update_compile_flags(mlir-opt)
 # It is necessary to use whole_archive_link to ensure that all static
-# initializers are called.  However, whole_archive_link libraries cannot
-# also be target_link_libraries
-whole_archive_link(mlir-opt ${LIBS})
-target_link_libraries(mlir-opt PRIVATE MLIRIR MLIROptMain LLVMSupport LLVMCore LLVMAsmParser)
+# initializers are called. However, whole_archive_link libraries cannot
+# also be target_link_libraries.
+whole_archive_link(mlir-opt ${FULL_LINK_LIBS})
+target_link_libraries(mlir-opt PRIVATE ${LIBS})