building with openmp target nvptx with llvm 12 versus 11


I have succesfully built and used clang with OpenMP offload target for Nivida architecture (sm_80) using llvm-11.0.1 release sources.

However, using release 12.0.0, I have a strange compile error.

Here is how I configure the openmp support with cmake:

here clang and clang++ are actually clang-12 and clang++-12 (built previously, I crossed check that I was able to compile cuda code, it is ok).

The compile error in building openmp support is

[ 24%] Building LLVM bitcode
cd /home/kestener/install/llvm/llvm-project-llvmorg-12.0.0/build-openmp/libomptarget/deviceRTLs/nvptx && /opt/local/llvm-12-omptarget/bin/clang -S -x c++ -O1 -std=c++14 -target nvptx64 -Xclang -emit-llvm-bc -Xclang -aux-triple -Xclang x86_64-unknown-linux-gnu -fopenmp -fopenmp-cuda-mode -Xclang -fopenmp-is-device -D__CUDACC__ -I/home/kestener/install/llvm/llvm-project-llvmorg-12.0.0/openmp/libomptarget/deviceRTLs -I/home/kestener/install/llvm/llvm-project-llvmorg-12.0.0/openmp/libomptarget/deviceRTLs/nvptx/src -DOMPTARGET_NVPTX_DEBUG=0 -Xclang -target-cpu -Xclang sm_80 -D__CUDA_ARCH__=800 -Xclang -target-feature -Xclang +ptx70 -DCUDA_VERSION=11200 /home/kestener/install/llvm/llvm-project-llvmorg-12.0.0/openmp/libomptarget/deviceRTLs/nvptx/src/ -o
In file included from /home/kestener/install/llvm/llvm-project-llvmorg-12.0.0/openmp/libomptarget/deviceRTLs/nvptx/src/
In file included from /home/kestener/install/llvm/llvm-project-llvmorg-12.0.0/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h:15:
In file included from /usr/include/assert.h:35:
/usr/include/features.h:461:12: fatal error: 'sys/cdefs.h' file not found
# include <sys/cdefs.h>

I don't know why this header is not found, it is actually present in my system (Ubuntu 20.04)

Did I miss something here ? It was building fine with llvm-11.0.1.

Thanks for your help.


This was an oversight and we'll make sure the runtime will be freestanding in the future.
That said, Ye Luo fixed this by installing gcc-multilib, maybe that helps you too.

If not, we'll have to come up with a hotfix.

~ Johannes

Dear Johannes,

thanks for your answer.
Yes gcc-multilib was necessary, silly of me !
The build is ok now.

Best regards.