Open
Description
see CUDA - inline variable
A namespace scope inline variable declared with device or constant or managed memory space specifier must have internal linkage, if the code is compiled with nvcc in whole program compilation mode.
#include <stdio.h>
__device__ inline int a = 10;
__global__ void kernel() {
printf("%d\n",a);
}
int main() {
kernel<<<1,1>>>();
cudaDeviceSynchronize();
}
nvcc report_error.cu -o report_error
report_error.cu(3): error: An inline __device__/__constant__/__managed__ variable must have internal linkage when the program is compiled in whole program mode (-rdc=false)
__attribute__((device)) inline int a = 10;
^
1 error detected in the compilation of "report_error.cu".
but no error report with
clang++ report_error.cu -o report_error --cuda-gpu-arch=sm_52 -L /usr/local/cuda/lib64 -lcudart -pthread