diff --git a/mlir/lib/Conversion/GPUToCUDA/CMakeLists.txt b/mlir/lib/Conversion/GPUToCUDA/CMakeLists.txt --- a/mlir/lib/Conversion/GPUToCUDA/CMakeLists.txt +++ b/mlir/lib/Conversion/GPUToCUDA/CMakeLists.txt @@ -1,7 +1,16 @@ -add_llvm_library(MLIRGPUtoCUDATransforms +set(LLVM_OPTIONAL_SOURCES ConvertKernelFuncToCubin.cpp +) + +set(SOURCES ConvertLaunchFuncToCudaCalls.cpp ) + +if (MLIR_CUDA_CONVERSIONS_ENABLED) + append(SOURCES ConvertKernelFuncToCubin.cpp) +endif() + +add_llvm_library(MLIRGPUtoCUDATransforms ${SOURCES}) target_link_libraries(MLIRGPUtoCUDATransforms MLIRGPU MLIRLLVMIR diff --git a/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp b/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp --- a/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp +++ b/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp @@ -57,9 +57,10 @@ gpu::GPUModuleOp module = getOperation(); // Make sure the NVPTX target is initialized. - llvm::InitializeAllTargets(); - llvm::InitializeAllTargetMCs(); - llvm::InitializeAllAsmPrinters(); + LLVMInitializeNVPTXTarget(); + LLVMInitializeNVPTXTargetInfo(); + LLVMInitializeNVPTXTargetMC(); + LLVMInitializeNVPTXAsmPrinter(); auto llvmModule = translateModuleToNVVMIR(module); if (!llvmModule)