Problem compiling openmp project for LLVM 12

Hi all,

I’m experiencing the following error when compiling the openmp project:

Building LLVM bitcode cancel.cu-cuda_80-sm_80.bc
FAILED: projects/openmp/libomptarget/deviceRTLs/nvptx/cancel.cu-cuda_80-sm_80.bc 
cd /home/andrew/projects/llvm-project/build/projects/openmp/libomptarget/deviceRTLs/nvptx && /usr/local/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/andrew/projects/llvm-project/openmp/libomptarget/deviceRTLs -I/home/andrew/projects/llvm-project/openmp/libomptarget/deviceRTLs/nvptx/src -DOMPTARGET_NVPTX_DEBUG=0 -Xclang -target-cpu -Xclang sm_80 -D__CUDA_ARCH__=800 -Xclang -target-feature -Xclang +ptx42 -DCUDA_VERSION=8000 /home/andrew/projects/llvm-project/openmp/libomptarget/deviceRTLs/common/src/cancel.cu -o cancel.cu-cuda_80-sm_80.bc
In file included from /home/andrew/projects/llvm-project/openmp/libomptarget/deviceRTLs/common/src/cancel.cu:14:
In file included from /home/andrew/projects/llvm-project/openmp/libomptarget/deviceRTLs/interface.h:20:
In file included from /usr/local/lib/clang/11.0.1/include/stdint.h:52:
/usr/include/stdint.h:26:10: fatal error: 'bits/libc-header-start.h' file not found
#include <bits/libc-header-start.h>

Steps to reproduce

$ git clone git@github.com:llvm/llvm-project.git
$ cd llvm-project
$ git checkout llvmorg-12.0.1
$ mkdir build
$ cd build
$ cmake ../llvm \
  -DCMAKE_BUILD_TYPE=Release \
  -DLLVM_ENABLE_PROJECTS="clang;openmp" \
  -DLLVM_TARGETS_TO_BUILD="X86;NVPTX" \
  -G Ninja
$ cmake --build .

I suspect I may be missing a dependency but this works fine with 11.0.1 so I’m wondering what’s changed.

Adding -v to the clang command line gives:

clang version 11.0.1 (git@github.com:llvm/llvm-project.git 43ff75f2c3feef64f9d73328230d34dac8832a91)
Target: nvptx64
Thread model: posix
InstalledDir: /usr/local/bin
Found CUDA installation: /usr/local/cuda-10.2, version 10.2
 (in-process)
 "/usr/local/bin/clang-11" -cc1 -triple nvptx64 -S -disable-free -disable-llvm-verifier -discard-value-names -main-file-name cancel.cu -mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math -fno-verbose-asm -no-integrated-as -fno-split-dwarf-inlining -debugger-tuning=gdb -v -resource-dir /usr/local/lib/clang/11.0.1 -D __CUDACC__ -I /home/andrew/projects/llvm-project/openmp/libomptarget/deviceRTLs -I /home/andrew/projects/llvm-project/openmp/libomptarget/deviceRTLs/nvptx/src -D OMPTARGET_NVPTX_DEBUG=0 -D __CUDA_ARCH__=800 -D CUDA_VERSION=8000 -O1 -std=c++14 -fdeprecated-macro -fno-dwarf-directory-asm -fdebug-compilation-dir /home/andrew/projects/llvm-project/build/projects/openmp/libomptarget/deviceRTLs/nvptx -ferror-limit 19 -fopenmp -fopenmp-cuda-mode -fopenmp-cuda-parallel-target-regions -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics -emit-llvm-bc -aux-triple x86_64-unknown-linux-gnu -fopenmp-is-device -target-cpu sm_80 -target-feature +ptx42 -o cancel.cu-cuda_80-sm_80.bc -x c++ /home/andrew/projects/llvm-project/openmp/libomptarget/deviceRTLs/common/src/cancel.cu
clang -cc1 version 11.0.1 based upon LLVM 11.0.1 default target x86_64-unknown-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
 /home/andrew/projects/llvm-project/openmp/libomptarget/deviceRTLs
 /home/andrew/projects/llvm-project/openmp/libomptarget/deviceRTLs/nvptx/src
 /usr/local/include
 /usr/local/lib/clang/11.0.1/include
 /usr/include
End of search list.
In file included from /home/andrew/projects/llvm-project/openmp/libomptarget/deviceRTLs/common/src/cancel.cu:14:
In file included from /home/andrew/projects/llvm-project/openmp/libomptarget/deviceRTLs/interface.h:20:
In file included from /usr/local/lib/clang/11.0.1/include/stdint.h:52:
/usr/include/stdint.h:26:10: fatal error: 'bits/libc-header-start.h' file not found
#include <bits/libc-header-start.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

On my system the libc-header-start.h file is located in

$ find /usr -name libc-header-start.h
/usr/include/x86_64-linux-gnu/bits/libc-header-start.h

System Information

Ubuntu 20.04
Clang 11
CMake 3.19.3

CMake log files attached.

Thanks,
Andrew.

CMakeOutput
CMakeError

Compiling 32 bit nvptx on a 64 bit platform that doesn’t have the 32 bit libs available looks like that. If that’s your problem, apt install gcc-multilibs and g+±multilibs will fix it.