Trying to build clang-13 for openmp target offload

Hello,

I am trying to build clang-13 with support for OpenMP target offload to Nvidia GPUS.

I can build clang, but it stubbornly refuses to build the openmpRTL, I get this in the cmake output:

  • Could NOT find LIBOMPTARGET_DEP_VEO (missing: LIBOMPTARGET_DEP_VEO_LIBRARIES LIBOMPTARGET_DEP_VEOSINFO_LIBRARIES LIBOMPTARGET_DEP_V

EO_INCLUDE_DIRS)

– LIBOMPTARGET: Building offloading runtime library libomptarget.

– LIBOMPTARGET: Not building aarch64 offloading plugin: machine not found in the system.

– LIBOMPTARGET: Building AMDGPU plugin for dlopened libhsa

– LIBOMPTARGET: Not generating amdgcn test targets as amdgpu-arch is not found

– LIBOMPTARGET: Building CUDA offloading plugin.

– LIBOMPTARGET: Building CUDA plugin linked against libcuda

– LIBOMPTARGET: Enable tests using CUDA plugin

– LIBOMPTARGET: Not building PPC64 offloading plugin: machine not found in the system.

– LIBOMPTARGET: Not building PPC64le offloading plugin: machine not found in the system.

– LIBOMPTARGET: Not building nec-aurora plugin: libveo or libveosinfo not found.

– LIBOMPTARGET: Not building x86_64 offloading plugin: libffi dependency not found.

– LIBOMPTARGET: Building AMDGCN device RTL. Using clang from in-tree build

– LIBOMPTARGET: Not building NVPTX deviceRTL: clang not found

– LIBOMPTARGET: Not building NVPTX deviceRTL: clang not found

– LIBOMPTARGET: Building the llvm-omp-device-info tool

Hi,

If using LLVM_ENABLE_PROJECTS=clang;openmp (or
LLVM_ENABLE_PROJECTS=clang and LLVM_ENABLE_RUNTIMES=openmp),
libomptarget should pick-up in-tree clang itself. The relevant change
(ofr LLVM_ENABLE_PROJECTS=clang;openmp) is
⚙ D101265 [OpenMP][CMake] Use in-project clang as CUDA->IR compiler., which I just checked landed in the
release of clang 13. Are you maybe using a pre-release version of
clang 13?

In any case, you should be able to explicitly set the clang for the
device RTL using -DLIBOMPTARGET_NVPTX_CUDA_COMPILER=... Just compile
clang first, then re-configure using the
DLIBOMPTARGET_NVPTX_CUDA_COMPILER set to the clang executable you just
build.

Note that this just changed for clang-14 which uses the clang found in
LLVM_TOOLS_BINARY_DIR.

Michael