Author: Caroline Rodewig Date: 2026-11-06T00:49:38+01:00 New Revision: 7a1989913d44a9cad259806dd18d8a3c5a2d7342
URL: https://github.com/llvm/llvm-project/commit/7a1989913d44a9cad259806dd18d8a3c5a2d7342 DIFF: https://github.com/llvm/llvm-project/commit/7a1989913d44a9cad259806dd18d8a3c5a2d7342.diff LOG: [clang][CUDA] Search include/cccl of CUDA 13 installations (#235910) >From CUDA 13.0 on, the CUDA C++ Core Libraries (libcu++, CUB and Thrust) are in `include/cccl` of the CUDA installation rather than in `include/`. Some of the toolkit's own headers include them, so with CUDA 13 something as simple as `#include <cooperative_groups.h>` fails to compile with Clang: ``` cooperative_groups/details/info.h: fatal error: 'cuda/std/type_traits' file not found ``` nvcc searches `include/cccl` right after `include/`. This makes Clang do the same, when the directory exists. `-nogpuinc` still leaves it out, and the user's own include directories are still searched first. The HIP toolchain already does the equivalent for [`include/libhipcxx`](https://github.com/llvm/llvm-project/blob/fe84f6e3b0ae40ef28998cd9cee3220eec2ea261/clang/lib/Driver/ToolChains/AMDGPU.cpp#L617-L624). Assisted-by: Devin Added: clang/test/Driver/Inputs/CUDA_130/usr/local/cuda/bin/.keep clang/test/Driver/Inputs/CUDA_130/usr/local/cuda/include/cccl/.keep clang/test/Driver/Inputs/CUDA_130/usr/local/cuda/include/cuda.h clang/test/Driver/Inputs/CUDA_130/usr/local/cuda/lib/.keep clang/test/Driver/Inputs/CUDA_130/usr/local/cuda/lib64/.keep clang/test/Driver/Inputs/CUDA_130/usr/local/cuda/nvvm/libdevice/libdevice.10.bc clang/test/Driver/cuda-cccl-include.cu Modified: clang/docs/ReleaseNotes.md clang/lib/Driver/ToolChains/Cuda.cpp Removed: ################################################################################ diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md index 03c5b85c32c13e..ea9fbe00ae3fe2 100644 --- a/clang/docs/ReleaseNotes.md +++ b/clang/docs/ReleaseNotes.md @@ -1410,6 +1410,12 @@ documentation](CIR/index.md) for more information regarding ClangIR's status and functions with CUDA 13.4 and newer. Added `__nvvm_idp4a_*` and `__nvvm_idp2a_*` builtins. (#GH233434) +- CUDA compilations now add the `include/cccl` directory of the selected CUDA + installation to the header search path when it exists. From CUDA 13.0 on, + libcu++, CUB and Thrust are in that directory, and toolkit headers such as + `cooperative_groups.h` include them. The `-nogpuinc` option disables this + path together with the other CUDA include paths. + #### AIX Support #### NetBSD Support diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp b/clang/lib/Driver/ToolChains/Cuda.cpp index acbbbb3b72c048..57470c18db3930 100644 --- a/clang/lib/Driver/ToolChains/Cuda.cpp +++ b/clang/lib/Driver/ToolChains/Cuda.cpp @@ -328,6 +328,15 @@ void CudaInstallationDetector::AddCudaIncludeArgs( CC1Args.push_back("-include"); CC1Args.push_back("__clang_cuda_runtime_wrapper.h"); + + // From CUDA 13.0 on, libcu++, CUB and Thrust are in include/cccl, and some + // of the toolkit's own headers, such as cooperative_groups.h, include them. + SmallString<128> CCCLPath(getIncludePath()); + llvm::sys::path::append(CCCLPath, "cccl"); + if (D.getVFS().exists(CCCLPath)) { + CC1Args.push_back("-internal-isystem"); + CC1Args.push_back(DriverArgs.MakeArgString(CCCLPath)); + } } void CudaInstallationDetector::CheckCudaVersionSupportsArch( diff --git a/clang/test/Driver/Inputs/CUDA_130/usr/local/cuda/bin/.keep b/clang/test/Driver/Inputs/CUDA_130/usr/local/cuda/bin/.keep new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/clang/test/Driver/Inputs/CUDA_130/usr/local/cuda/include/cccl/.keep b/clang/test/Driver/Inputs/CUDA_130/usr/local/cuda/include/cccl/.keep new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/clang/test/Driver/Inputs/CUDA_130/usr/local/cuda/include/cuda.h b/clang/test/Driver/Inputs/CUDA_130/usr/local/cuda/include/cuda.h new file mode 100644 index 00000000000000..9ddfd9b011fdac --- /dev/null +++ b/clang/test/Driver/Inputs/CUDA_130/usr/local/cuda/include/cuda.h @@ -0,0 +1,7 @@ +// +// Placeholder file for testing CUDA version detection +// + +#define CUDA_VERSION 13000 + +// diff --git a/clang/test/Driver/Inputs/CUDA_130/usr/local/cuda/lib/.keep b/clang/test/Driver/Inputs/CUDA_130/usr/local/cuda/lib/.keep new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/clang/test/Driver/Inputs/CUDA_130/usr/local/cuda/lib64/.keep b/clang/test/Driver/Inputs/CUDA_130/usr/local/cuda/lib64/.keep new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/clang/test/Driver/Inputs/CUDA_130/usr/local/cuda/nvvm/libdevice/libdevice.10.bc b/clang/test/Driver/Inputs/CUDA_130/usr/local/cuda/nvvm/libdevice/libdevice.10.bc new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/clang/test/Driver/cuda-cccl-include.cu b/clang/test/Driver/cuda-cccl-include.cu new file mode 100644 index 00000000000000..72406d5ff5a057 --- /dev/null +++ b/clang/test/Driver/cuda-cccl-include.cu @@ -0,0 +1,27 @@ +// From CUDA 13.0 on, the CUDA C++ Core Libraries are in include/cccl of the +// CUDA installation. Check that it is a system include directory for both the +// device and the host compilation. + +// RUN: %clang -### --target=x86_64-unknown-linux-gnu --cuda-gpu-arch=sm_75 \ +// RUN: --cuda-path=%S/Inputs/CUDA_130/usr/local/cuda %s 2>&1 \ +// RUN: | FileCheck %s --check-prefix=CCCL + +// CCCL: "-cc1" "-triple" "nvptx64-nvidia-cuda" +// CCCL-SAME: "-internal-isystem" "[[CUDA:[^"]*Inputs/CUDA_130/usr/local/cuda]]{{[/\\]+}}include{{[/\\]+}}cccl" {{.*}}"-internal-isystem" "[[CUDA]]{{[/\\]+}}include" +// CCCL: "-cc1" "-triple" "x86_64-unknown-linux-gnu" +// CCCL-SAME: "-internal-isystem" "[[CUDA]]{{[/\\]+}}include{{[/\\]+}}cccl" {{.*}}"-internal-isystem" "[[CUDA]]{{[/\\]+}}include" + +// Older CUDA installations have no include/cccl. +// RUN: %clang -### --target=x86_64-unknown-linux-gnu --cuda-gpu-arch=sm_75 \ +// RUN: --cuda-path=%S/Inputs/CUDA_111/usr/local/cuda %s 2>&1 \ +// RUN: | FileCheck %s --check-prefix=NOCCCL + +// -nogpuinc leaves out all of the CUDA installation's include directories. +// RUN: %clang -### --target=x86_64-unknown-linux-gnu --cuda-gpu-arch=sm_75 \ +// RUN: -nogpuinc --cuda-path=%S/Inputs/CUDA_130/usr/local/cuda %s 2>&1 \ +// RUN: | FileCheck %s --check-prefix=NOCCCL + +// NOCCCL: "-cc1" "-triple" "nvptx64-nvidia-cuda" +// NOCCCL-NOT: include{{[/\\]+}}cccl" +// NOCCCL: "-cc1" "-triple" "x86_64-unknown-linux-gnu" +// NOCCCL-NOT: include{{[/\\]+}}cccl" _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
