clang-cuda compiler checks fail due to broken linker paths
The following minimal test case fails on the master branch:
CMakeLists.txt:
cmake_minimum_required(VERSION 3.19)
project(Test CUDA)
CMake invocation:
../CMake/build/bin/cmake -DCMAKE_CUDA_COMPILER=clang++ ..
Error output:
-- Check for working CUDA compiler: /usr/bin/clang++ - broken
CMake Error at CMake/Modules/CMakeTestCUDACompiler.cmake:52 (message):
The CUDA compiler
"/usr/bin/clang++"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /build/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make -f Makefile cmTC_01c87/fast && /usr/bin/make -f CMakeFiles/cmTC_01c87.dir/build.make CMakeFiles/cmTC_01c87.dir/build
make[1]: Entering directory '/build/CMakeFiles/CMakeTmp'
Building CUDA object CMakeFiles/cmTC_01c87.dir/main.cu.o
/usr/bin/clang++ --cuda-gpu-arch=sm_30 --cuda-path=/usr/local/cuda -MD -MT CMakeFiles/cmTC_01c87.dir/main.cu.o -MF CMakeFiles/cmTC_01c87.dir/main.cu.o.d -x cuda -c /build/CMakeFiles/CMakeTmp/main.cu -o CMakeFiles/cmTC_01c87.dir/main.cu.o
Linking CUDA executable cmTC_01c87
/CMake/build/bin/cmake -E cmake_link_script CMakeFiles/cmTC_01c87.dir/link.txt --verbose=1
/usr/bin/clang++ CMakeFiles/cmTC_01c87.dir/main.cu.o -o cmTC_01c87 -lcudadevrt -lcudart_static -lrt -lpthread -ldl
/usr/bin/ld: cannot find -lcudadevrt
/usr/bin/ld: cannot find -lcudart_static
clang: error: linker command failed with exit code 1 (use -v to see invocation)
CMakeFiles/cmTC_01c87.dir/build.make:99: recipe for target 'cmTC_01c87' failed
make[1]: *** [cmTC_01c87] Error 1
make[1]: Leaving directory '/build/CMakeFiles/CMakeTmp'
Makefile:127: recipe for target 'cmTC_01c87/fast' failed
make: *** [cmTC_01c87/fast] Error 2
My environment:
Ubuntu clang version 10.0.1-++20201112101950+ef32c611aa2-1~exp1~20201112092551.202
Cuda compilation tools, release 10.1, V10.1.243
I bisected the issue down to 4620cf77, though with previous versions, the compiler check just gets skipped.