Main issue:
When modifying some headers files, CUDA files (.cu) are not compiled even though they are including those header files in the code.
My investigation:
A MSBUILD task called GenerateDeps is executed that generate a file (XXX.deps) with a list of header file dependencies (tree) that the cuda file include. I have noticed though that some files are missing from that list (from the XXX.deps).
By looking into the msbuild log, I have seen the command executed to generate that list of dependencies (calling cl.exe). When calling that command line from the command line and the same context, I saw compilation errors:
Note: including file: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\\include\cccl\cuda/std/utility
Note: including file: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\\include\cccl\cuda/std/detail/__config
Note: including file: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\\include\cccl\cuda/std/__cccl/version.h
Note: including file: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\\include\cccl\cuda/std/detail/libcxx/include/__config
Note: including file: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\\include\cccl\cuda/__cccl_config
Note: including file: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\\include\cccl\cuda/std/__cccl/architecture.h
Note: including file: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\\include\cccl\cuda/std/__cccl/assert.h
Note: including file: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\\include\cccl\cuda/std/__cccl/compiler.h
Note: including file: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\\include\cccl\cuda/std/__cccl/preprocessor.h
Note: including file: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\\include\cccl\cuda/std/__cccl/system_header.h
Note: including file: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\\include\cccl\cuda/std/__cccl/is_non_narrowing_convertible.h
Note: including file: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\\include\cccl\cuda/std/__cccl/attributes.h
Note: including file: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\\include\cccl\cuda/std/__cccl/dialect.h
Note: including file: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\\include\cccl\cuda/std/__cccl/builtin.h
Note: including file: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\\include\cccl\cuda/std/__cccl/extended_data_types.h
Note: including file: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\\include\cccl\cuda/std/__cccl/cuda_toolkit.h
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\\include\cccl\cuda/std/__cccl/cuda_toolkit.h(39): fatal error C1189: #error: "CUDA compiler and CUDA toolkit headers are incompatible, please check your include paths"
The compilation errors came from the cuda_toolkit.h file. When generating the list of dependencies, the NVIDIA toolkit defines some CUDA macros (/D__CUDACC__ /D__CUDACC_VER_MAJOR__=13 /D__CUDACC_VER_MINOR__=0) but nothing about a CUDA compiler (_CCCL_HAS_CUDA_COMPILER() = 0). I think this is the reason the list of dependencies cannot be generated entirely because it stops at the compilation error.
To reproduce:
In a CUDA Project in Visual Studio, do the following:
-
Create a header file called “test.h”
-
create a CUDA file with the following content:
#include <cuda/std/utility>
#include "test.h" // Or any other files, this file and all files below won't be listed as a dependency
- Modify “test.h”
- Compile the project, you will notice that the CUDA file won’t be compiled even if the header file has changed.
- if you look at the .deps generated for that CUDA file, the header file “test.h” won’t be listed.
Environment :
- Visual Studio (2019 in my case)
- CUDA Toolkit 13.0
Conclusion:
It appears that once an header file from the CCCL library is included in a CUDA file, the list of dependencies related to that CUDA file won’t be updated for any files listed below.