Skip to content

Commit 6402706

Browse files
authored
[mlir] Fix the link of libcuda.so in MLIRGPUTransforms to not use fully qualified path (#74018)
At the moment we find libcuda.so in a path like: /usr/local/cuda/targets/x86_64-linux/lib/stubs/libcuda.so and directly add this to `target_link_libraries`. The problem is that our installed MLIR package will include the full path to the library, and a user downstream when including our cmake installed package will inherit this full path. We're changing this to instead -L /usr/local/cuda/targets/x86_64-linux/lib/stubs/ -lcuda
1 parent d0a39e6 commit 6402706

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mlir/lib/Dialect/GPU/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,15 @@ if(MLIR_ENABLE_CUDA_RUNNER)
135135
${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}
136136
)
137137

138+
# Add link path for the cuda driver library.
138139
find_library(CUDA_DRIVER_LIBRARY cuda HINTS ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES} REQUIRED)
140+
get_filename_component(CUDA_DRIVER_LIBRARY_PATH "${CUDA_DRIVER_LIBRARY}" DIRECTORY)
141+
target_link_directories(MLIRGPUTransforms PRIVATE ${CUDA_DRIVER_LIBRARY_PATH})
142+
139143
target_link_libraries(MLIRGPUTransforms
140144
PRIVATE
141145
MLIRNVVMToLLVMIRTranslation
142-
${CUDA_DRIVER_LIBRARY}
146+
cuda
143147
)
144148

145149
endif()

0 commit comments

Comments
 (0)