mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-30 03:38:05 +00:00
[OpenMP] Fix nvidia-cuda-toolkit detection on Debian/Ubuntu
The OpenMP runtime's cmake scripts do not correctly locate the libdevice that the Debian/Ubuntu package nvidia-cuda-toolkit currently includes, at least on my Ubuntu 18.04.1 installation. This patch fixes that for me. This problem was discussed at length in D55269. D40453 added a similar adjustment in clang, but reviewers of D55269 concluded that, for the OpenMP runtime, the right place to address this problem is in cmake's CUDA support. However, it was also suggested we could add a workaround to OpenMP's cmake scripts now. This patch contains such a workaround, which I've tried to design so that it will have no harmful effect if cmake improves in the future. nvidia-cuda-toolkit also needs improvements because its intended monolithic CUDA tree shim, /usr/lib/cuda, has many empty directories, such as bin. I reported that at: <https://bugs.launchpad.net/ubuntu/+source/nvidia-cuda-toolkit/+bug/1808999> Reviewed By: grokos Differential Revision: https://reviews.llvm.org/D55588 llvm-svn: 350377
This commit is contained in:
parent
961fbf21c6
commit
f17f7a5d4d
@ -112,6 +112,9 @@ mark_as_advanced(
|
||||
################################################################################
|
||||
# Looking for CUDA...
|
||||
################################################################################
|
||||
if (CUDA_TOOLKIT_ROOT_DIR)
|
||||
set(LIBOMPTARGET_CUDA_TOOLKIT_ROOT_DIR_PRESET TRUE)
|
||||
endif()
|
||||
find_package(CUDA QUIET)
|
||||
|
||||
set(LIBOMPTARGET_DEP_CUDA_FOUND ${CUDA_FOUND})
|
||||
@ -158,3 +161,33 @@ find_package_handle_standard_args(
|
||||
LIBOMPTARGET_DEP_CUDA_DRIVER_LIBRARIES)
|
||||
|
||||
mark_as_advanced(LIBOMPTARGET_DEP_CUDA_DRIVER_LIBRARIES)
|
||||
|
||||
################################################################################
|
||||
# Looking for CUDA libdevice subdirectory
|
||||
#
|
||||
# Special case for Debian/Ubuntu to have nvidia-cuda-toolkit work
|
||||
# out of the box. More info on http://bugs.debian.org/882505
|
||||
################################################################################
|
||||
|
||||
set(LIBOMPTARGET_CUDA_LIBDEVICE_SUBDIR nvvm/libdevice)
|
||||
|
||||
# Don't alter CUDA_TOOLKIT_ROOT_DIR if the user specified it, if a value was
|
||||
# already cached for it, or if it already has libdevice. Otherwise, on
|
||||
# Debian/Ubuntu, look where the nvidia-cuda-toolkit package normally installs
|
||||
# libdevice.
|
||||
if (NOT LIBOMPTARGET_CUDA_TOOLKIT_ROOT_DIR_PRESET AND
|
||||
NOT EXISTS
|
||||
"${CUDA_TOOLKIT_ROOT_DIR}/${LIBOMPTARGET_CUDA_LIBDEVICE_SUBDIR}")
|
||||
find_program(LSB_RELEASE lsb_release)
|
||||
if (LSB_RELEASE)
|
||||
execute_process(COMMAND ${LSB_RELEASE} -is
|
||||
OUTPUT_VARIABLE LSB_RELEASE_ID
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
set(candidate_dir /usr/lib/cuda)
|
||||
if ((LSB_RELEASE_ID STREQUAL "Debian" OR LSB_RELEASE_ID STREQUAL "Ubuntu")
|
||||
AND EXISTS "${candidate_dir}/${LIBOMPTARGET_CUDA_LIBDEVICE_SUBDIR}")
|
||||
set(CUDA_TOOLKIT_ROOT_DIR "${candidate_dir}" CACHE PATH
|
||||
"Toolkit location." FORCE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
Loading…
Reference in New Issue
Block a user