The Arch Linux
has shipped gcc 9
, but the newest CUDA V10.1.168
still only supports gcc 8
. So I met following error after upgrading Arch Linux
:
......
/usr/include/c++/9.1.0/bits/stl_function.h(437): error: identifier "__builtin_is_constant_evaluated" is undefined
......
Unfortunately, gcc-8 package is not ready now. So I fell back to gcc-7
:
SET(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -ccbin=gcc-7"}
Although the CUDA release note claims it already supports clang 8
, I indeed bumped into some compile errors when using clang 8
. So using gcc-7
is a feasible work-around for me.
I am running void linux, and I was checking the CUDA installation was fine. I ran into the same error:
make[1]: Entering directory ‘/home/_/NVIDIA_CUDA-10.1_Samples/0_Simple/simpleCudaGraphs’
/usr/local/cuda/bin/nvcc -ccbin g++ -I../../common/inc -m64 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_75,code=compute_75 -o simpleCudaGraphs.o -c simpleCudaGraphs.cu
/usr/include/c++/9.1/bits/stl_function.h(437): error: identifier “__builtin_is_constant_evaluated” is undefined
1 error detected in the compilation of “/tmp/tmpxft_0000144c_00000000-14_sim*
I tried your solution but it does not work 🙁
Which gcc do you install? Could you make sure the oldest gcc search correct header files?
It depends on your CMakeList.txt.
What worked for me was adding `list(APPEND CUDA_NVCC_FLAGS “-ccbin g++-8”)` instead because I had a `set` command before that
I added `list(APPEND CUDA_NVCC_FLAGS “-ccbin g++-8”)` instead because my CMakeList.txt contained a `set(CUDA_NVCC_FLAGS foo)` before, and it worked.
Hi, I ran into this same problem using a Linux X86_64 kernel 5.2.2 with gcc 9.1.1.
I made modifications to the stl_function.h file. I saved the original first… I made several modifications. First, I changed the __builtin_is_constant_evaluated() to ‘std::is_constant_evaluated(). Next, I modified either a Makefile or another header file to remove the logic check of the gcc version. The result, the compiled source completed without errors! I tired all the sources that failed, and I am not able to compile them. I had to install additional libraries for GL headers and -devel. I will also post on the Nvidia developers site.
Before:
BEFORE:
[em 5_Simulations]$ cd particles/
[em particles]$ make
/usr/local/cuda/bin/nvcc -ccbin g++ -I../../common/inc -m64 -DCUDA_ENABLE_DEPRECATED -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_75,code=compute_75 -o particleSystem_cuda.o -c particleSystem_cuda.cu
/usr/include/c++/9.1.1/bits/stl_function.h(443): error: identifier “__builtin_is_constant_evaluated” is undefined
1 error detected in the compilation of “/tmp/tmpxft_00001c79_00000000-14_particleSystem_cuda.compute_75.cpp1.ii”.
make: *** [Makefile:313: particleSystem_cuda.o] Error 1
[em particles]$
AFTER:
$ make
/usr/local/cuda/bin/nvcc -ccbin g++ -I../../common/inc -m64 -DCUDA_ENABLE_DEPRECATED -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_75,code=compute_75 -o particleSystem_cuda.o -c particleSystem_cuda.cu
/usr/local/cuda/bin/nvcc -ccbin g++ -I../../common/inc -m64 -DCUDA_ENABLE_DEPRECATED -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_75,code=compute_75 -o particles.o -c particles.cpp
/usr/local/cuda/bin/nvcc -ccbin g++ -I../../common/inc -m64 -DCUDA_ENABLE_DEPRECATED -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_75,code=compute_75 -o render_particles.o -c render_particles.cpp
/usr/local/cuda/bin/nvcc -ccbin g++ -I../../common/inc -m64 -DCUDA_ENABLE_DEPRECATED -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_75,code=compute_75 -o shaders.o -c shaders.cpp
/usr/local/cuda/bin/nvcc -ccbin g++ -m64 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_75,code=compute_75 -o particles particleSystem.o particleSystem_cuda.o particles.o render_particles.o shaders.o -lGL -lGLU -lglut
mkdir -p ../../bin/x86_64/linux/release
cp particles ../../bin/x86_64/linux/release
[em particles]$
The problem is not with the compiler per se, it is with the compiler standard used to compile the examples. I believed that the examples were crafted to use C++11 by default. Even though I have installed, in a fresh fedora 30, the latest version of gcc-c++ (at the time of this writing is 9.2.1-1), I solve the problem by adding the corresponding flag to every Makefile in every directory:
CCFLAGS :=-std=c++11
I did this with the simple command:
find . -type f -name Makefile -exec sed -i -r ‘s/^CCFLAGS :=/CCFLAGS :=\-std=c\+\+11/’ {} +
All NVIDIA examples compiled just fine.