Adding CUDA includes with `-isystem` can cause build errors in system headers.
sh1boot opened this issue · comments
Lines 175 to 177 in a46c55d
This line can add-isystem=/usr/include
to the command line, which is a bad idea because it messes with include directory order and causes things like #include_next <math.h>
in cmath.h
to fail with "no such file or directory".
I think this happens when the CUDA toolkit comes from a system package rather than being manually downloaded and placed in /usr/local
.
Hi @sh1boot can you describe your build environment? We added this because the nvhpc toolkit had a bug that caused the cuda includes not to be system includes by default. We haven't tested nvhpc in a while, so it may have been fixed and this change is no longer needed.
Ubuntu 23.04 with the nvidia-cuda-*
Ubuntu packages version 11.8.89~11.8.0-3 installed That and the usual development packages for Python and C++.
I don't think that my environment solves the problem that line works around, exactly. However, in my case, because I'm using Ubuntu packages of the CUDA tools, they live in /usr
instead of /usr/local
and so the required -isystem /usr/include
is already implicit. So it's going to work (for me) without that. While at the same time adding it redundantly has an obscure, fatal side effect on the way system headers work.
I assume what's needed is a guard around the addition, checking that CUDAToolkit_INCLUDE_DIRS
is not equal to /usr/include
before setting the option.
Thanks. We will test if this is still needed in nvhpc. If not, the easiest path forward is to remove that.
This should be fixed.