July 22, 2020

If the gcc version being used is incompatible with cuda version, there will be errors such as:

[ 68%] Building NVCC (Device) object src/nvtt/CMakeFiles/cuda_compile_1.dir/cuda/cuda_compile_1_generated_CompressKernel.cu.o
/usr/include/c++/10.1.0/type_traits(1396): error: type name is not allowed

/usr/include/c++/10.1.0/type_traits(1396): error: type name is not allowed

/usr/include/c++/10.1.0/type_traits(1396): error: identifier "__is_same_as" is undefined

3 errors detected in the compilation of "/home/nick/Code/Git/github.com/nvidia-texture-tools/src/nvtt/cuda/CompressKernel.cu".
CMake Error at cuda_compile_1_generated_CompressKernel.cu.o.Release.cmake:280 (message):
  Error generating file
  /home/nick/Code/Git/github.com/nvidia-texture-tools/cmake-build-release/src/nvtt/CMakeFiles/cuda_compile_1.dir/cuda/./cuda_compile_1_generated_CompressKernel.cu.o


make[2]: *** [src/nvtt/CMakeFiles/nvtt.dir/build.make:85: src/nvtt/CMakeFiles/cuda_compile_1.dir/cuda/cuda_compile_1_generated_CompressKernel.cu.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:721: src/nvtt/CMakeFiles/nvtt.dir/all] Error 2
make: *** [Makefile:183: all] Error 2

See discussion on GitHub: CUDA Build error on Arch Linux and CUDA Compilers – nvcc compatibility chart.

This can be resolved by using an earlier version of GCC which is compatible with the CUDA version. In my example setting the following CMake variable resolved the issue:

	-DCUDA_HOST_COMPILER=/usr/bin/gcc-9

The default version of gcc in the Arch Linux repositories is now gcc10:

➜  ~ pacman -Qo /usr/bin/c++
/usr/bin/c++ is owned by gcc 10.1.0-2

This can result in errors during linking while building packages, such as:

[ 75%] Linking CXX executable ../../../../../bin/sst_conn_tool
/usr/bin/ld: ../../../../../lib/libadios2_core.so.2.6.0: undefined reference to `int adios2::format::DataManSerializer::GetData<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<unsigned long, std::allocator<unsigned long> > const&, std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, std::vector<unsigned long, std::allocator<unsigned long> > const&, std::vector<unsigned long, std::allocator<unsigned long> > const&)'
/usr/bin/ld: ../../../../../lib/libadios2_core.so.2.6.0: undefined reference to `int adios2::format::DataManSerializer::GetData<float>(float*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<unsigned long, std::allocator<unsigned long> > const&, std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, std::vector<unsigned long, std::allocator<unsigned long> > const&, std::vector<unsigned long, std::allocator<unsigned long> > const&)'

This issue can be resolved by compiling with an earlier version of gcc:

➜  ~ pacman -Qo /usr/bin/g++-9
/usr/bin/g++-9 is owned by gcc9 9.3.0-3

Setting these CMake variables will result in using the gcc9 version of gcc, g++, gcc-ar, and gcc-ranlib:

        -DCMAKE_CXX_COMPILER=/usr/bin/g++-9 \
        -DCMAKE_CXX_COMPILER_AR=/usr/bin/gcc-ar-9 \
        -DCMAKE_CXX_COMPILER_RANLIB=/usr/bin/gcc-ranlib-9 \
        -DCMAKE_C_COMPILER=/usr/bin/gcc-9 \
        -DCMAKE_C_COMPILER_AR=/usr/bin/gcc-ar-9 \
        -DCMAKE_C_COMPILER_RANLIB=/usr/bin/gcc-ranlib-9 \