Compiling CUDA programs with clang-14,15


I am trying to compile a CUDA program with clang-15 and am getting the following error saying the “texture template is missing”. Similar error with clang-14. Compiles fine with clang-12. Am I missing anything?

$ ~/Documents/Tools/llvm-project/build/bin/clang --verbose -L/usr/local/cuda-12.1/lib -lcudart_static -ldl -lrt -pthread
~/Documents/Tools/llvm-project/build/lib/clang/15.0.0/include/__clang_cuda_texture_intrinsics.h:696:13: error: no template named 'texture'
            texture<__DataT, __TexT, cudaReadModeNormalizedFloat> __handle,
~/Documents/Tools/llvm-project/build/lib/clang/15.0.0/include/__clang_cuda_texture_intrinsics.h:709:13: error: no template named 'texture'
            texture<__DataT, __TexT, cudaReadModeElementType> __handle,
2 errors generated when compiling for sm_35.
1 Like

I think these texture stuff are deprecated in CUDA 12, which Clang didnt update. So I modify __clang_cuda_runtime_wrapper.h by adding && CUDA_VERSION < 12000 test:

// __clang_cuda_texture_intrinsics.h must be included first in order to provide
// implementation for __nv_tex_surf_handler that CUDA's headers depend on.
// The implementation requires c++11 and only works with CUDA-9 or newer.
#if __cplusplus >= 201103L && CUDA_VERSION >= 9000 && CUDA_VERSION < 12000
// clang-format off
#include <__clang_cuda_texture_intrinsics.h>
// clang-format on