The following file
// t2.cu
template<typename T>
struct __numeric_traits_integer
{
static const bool __is_signed = true;
static const bool bar = __is_signed;
};
Cannot be built with clang with nvcc from CUDA 11.3.1
$ /opt/cuda/bin/nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Mon_May__3_19:15:13_PDT_2021
Cuda compilation tools, release 11.3, V11.3.109
Build cuda_11.3.r11.3/compiler.29920130_0
$ /opt/cuda/bin/nvcc -std=c++14 -ccbin=/usr/bin/clang -c t2.cu -o /dev/null
t2.cu(4): warning: __is_signed is no longer a keyword from this point
t2.cu(6): error: expected a "("
t2.cu(6): error: expected a type specifier
t2.cu(6): error: expected a ")"
3 errors detected in the compilation of "t2.cu".
The issue seems related to the identifier __is_signed
. If I replace it with something else (e.g., one more leading underscore), compiling works:
/opt/cuda/bin/nvcc -D__is_signed=___is_signed -std=c++14 -ccbin=/usr/bin/clang -c t2.cu -o /dev/null
The same file builds fine with the same nvcc command from CUDA 11.3.0.
$ /opt/cuda/bin/nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Sun_Mar_21_19:15:46_PDT_2021
Cuda compilation tools, release 11.3, V11.3.58
Build cuda_11.3.r11.3/compiler.29745058_0
$ /opt/cuda/bin/nvcc -std=c++14 -ccbin=/usr/bin/clang -c t2.cu -o /dev/null
t2.cu:4:19: warning: keyword '__is_signed' will be made available as an identifier for the remainder of the translation unit [-Wkeyword-compat]
static const bool __is_signed = true;
^
1 warning generated.
Is it a regression?
I got this issue when I was building onnxruntime 1.8.0 on Arch Linux. GCC crashes with internal compiler errors at some other files, so I tried clang. The struct in t2.cu
is from <ext/numeric_traits.h> of libstdc++, which is in turn included by <bits/stl_algobase.h>
and <algorithm>
. Complete build logs can be found at here
System environment:
- Arch Linux up-to-date
- gcc 11.1.0
- clang 12.0.0