[PATCH] D74472: Fix MLIR build when the NVPTX target isn't configured
Mehdi AMINI via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 12 03:19:20 PST 2020
mehdi_amini updated this revision to Diff 244117.
mehdi_amini added a comment.
Fix build with bfd
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74472/new/
https://reviews.llvm.org/D74472
Files:
mlir/lib/Conversion/GPUToCUDA/CMakeLists.txt
mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp
mlir/tools/mlir-opt/CMakeLists.txt
Index: mlir/tools/mlir-opt/CMakeLists.txt
===================================================================
--- mlir/tools/mlir-opt/CMakeLists.txt
+++ mlir/tools/mlir-opt/CMakeLists.txt
@@ -31,6 +31,7 @@
MLIREDSC
MLIRFxpMathOps
MLIRGPU
+ MLIRGPUtoCUDATransforms
MLIRGPUtoNVVMTransforms
MLIRGPUtoROCDLTransforms
MLIRGPUtoSPIRVTransforms
@@ -75,17 +76,23 @@
LLVMAsmParser
)
-if(MLIR_CUDA_CONVERSIONS_ENABLED)
- list(APPEND LIBS
- LLVMNVPTXCodeGen
- LLVMNVPTXDesc
- LLVMNVPTXInfo
- MLIRGPUtoCUDATransforms
- MLIRTargetNVVMIR
- )
-endif()
+set(LLVM_LINK_COMPONENTS
+ AllTargetsCodeGens
+)
+
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})
Index: mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp
===================================================================
--- mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp
+++ mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp
@@ -57,10 +57,9 @@
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)
Index: mlir/lib/Conversion/GPUToCUDA/CMakeLists.txt
===================================================================
--- mlir/lib/Conversion/GPUToCUDA/CMakeLists.txt
+++ 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
+)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74472.244117.patch
Type: text/x-patch
Size: 2833 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200212/75ff6694/attachment.bin>
More information about the llvm-commits
mailing list