[Mlir-commits] [mlir] 7b63588 - Fix MLIR build when the NVPTX target isn't configured
Mehdi Amini
llvmlistbot at llvm.org
Wed Feb 12 04:38:53 PST 2020
Author: Mehdi Amini
Date: 2020-02-12T12:38:45Z
New Revision: 7b635880ab5720f25f2be572240f8cad89ccf10b
URL: https://github.com/llvm/llvm-project/commit/7b635880ab5720f25f2be572240f8cad89ccf10b
DIFF: https://github.com/llvm/llvm-project/commit/7b635880ab5720f25f2be572240f8cad89ccf10b.diff
LOG: Fix MLIR build when the NVPTX target isn't configured
Differential Revision: https://reviews.llvm.org/D74472
Added:
Modified:
mlir/lib/Conversion/GPUToCUDA/CMakeLists.txt
mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp
mlir/tools/mlir-opt/CMakeLists.txt
Removed:
################################################################################
diff --git a/mlir/lib/Conversion/GPUToCUDA/CMakeLists.txt b/mlir/lib/Conversion/GPUToCUDA/CMakeLists.txt
index a34ffea6e93e..a758f7b935ef 100644
--- a/mlir/lib/Conversion/GPUToCUDA/CMakeLists.txt
+++ b/mlir/lib/Conversion/GPUToCUDA/CMakeLists.txt
@@ -1,16 +1,11 @@
-if(MLIR_CUDA_CONVERSIONS_ENABLED)
- add_llvm_library(MLIRGPUtoCUDATransforms
- ConvertKernelFuncToCubin.cpp
- ConvertLaunchFuncToCudaCalls.cpp
- )
- target_link_libraries(MLIRGPUtoCUDATransforms
- LLVMNVPTXCodeGen
- LLVMNVPTXDesc
- LLVMNVPTXInfo
- MLIRGPU
- MLIRLLVMIR
- MLIRNVVMIR
- MLIRPass
- MLIRTargetNVVMIR
- )
-endif()
+add_llvm_library(MLIRGPUtoCUDATransforms
+ ConvertKernelFuncToCubin.cpp
+ ConvertLaunchFuncToCudaCalls.cpp
+)
+target_link_libraries(MLIRGPUtoCUDATransforms
+ MLIRGPU
+ MLIRLLVMIR
+ MLIRNVVMIR
+ MLIRPass
+ MLIRTargetNVVMIR
+)
diff --git a/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp b/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp
index 140026eaf643..fe571cf31548 100644
--- a/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp
+++ b/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp
@@ -57,10 +57,9 @@ class GpuKernelToCubinPass
gpu::GPUModuleOp module = getOperation();
// Make sure the NVPTX target is initialized.
- LLVMInitializeNVPTXTarget();
- LLVMInitializeNVPTXTargetInfo();
- LLVMInitializeNVPTXTargetMC();
- LLVMInitializeNVPTXAsmPrinter();
+ llvm::InitializeAllTargets();
+ llvm::InitializeAllTargetMCs();
+ llvm::InitializeAllAsmPrinters();
auto llvmModule = translateModuleToNVVMIR(module);
if (!llvmModule)
diff --git a/mlir/tools/mlir-opt/CMakeLists.txt b/mlir/tools/mlir-opt/CMakeLists.txt
index b7e1b4442e21..99a2088e5d9a 100644
--- a/mlir/tools/mlir-opt/CMakeLists.txt
+++ b/mlir/tools/mlir-opt/CMakeLists.txt
@@ -31,6 +31,7 @@ set(LIBS
MLIREDSC
MLIRFxpMathOps
MLIRGPU
+ MLIRGPUtoCUDATransforms
MLIRGPUtoNVVMTransforms
MLIRGPUtoROCDLTransforms
MLIRGPUtoSPIRVTransforms
@@ -75,17 +76,19 @@ set(LIBS
LLVMAsmParser
)
-if(MLIR_CUDA_CONVERSIONS_ENABLED)
- list(APPEND LIBS
- LLVMNVPTXCodeGen
- LLVMNVPTXDesc
- LLVMNVPTXInfo
- MLIRGPUtoCUDATransforms
- MLIRTargetNVVMIR
- )
-endif()
add_llvm_tool(mlir-opt
mlir-opt.cpp
)
+# Manually expand the target library, since our MLIR libraries
+# aren't plugged into the LLVM dependency tracking. If we don't
+# do this then we can't insert the CodeGen library after ourselves
+llvm_expand_pseudo_components(TARGET_LIBS AllTargetsCodeGens)
+# Prepend LLVM in front of every target, this is how the library
+# are named with CMake
+SET(targets_to_link)
+FOREACH(t ${TARGET_LIBS})
+ LIST(APPEND targets_to_link "LLVM${t}")
+ENDFOREACH(t)
+
llvm_update_compile_flags(mlir-opt)
-target_link_libraries(mlir-opt PRIVATE ${LIBS})
+target_link_libraries(mlir-opt PRIVATE ${LIBS} ${targets_to_link})
More information about the Mlir-commits
mailing list