<div dir="ltr"><div>Hi Jonas,</div><div>I have a related question: is it possible to build the nvidia OpenMP support with clang itself, instead of nvcc ?</div><div><br></div><div>I am trying to build clang 7 (r339664) with support for CUDA 9.2.148, using gcc 8.1, on a CentOS 7.5 system.<br></div><div><br></div><div>It builds fine if I leave out OpenMP support:</div><div><br></div><div style="margin-left:40px"><span style="font-family:monospace,monospace">$ cmake $BASE/llvm-project/llvm -G Ninja \<br>  -DLLVM_TARGETS_TO_BUILD:STRING="X86;NVPTX" \<br>  -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;compiler-rt;lld" \<br>  -DCMAKE_BUILD_TYPE:STRING=Release \<br>  -DCMAKE_INSTALL_PREFIX:PATH="$BASE/install-r339664" \<br>  -DLLVM_LIBDIR_SUFFIX:STRING=64 \<br>  -DBUILD_SHARED_LIBS:BOOL=ON \<br>  -DLLVM_ENABLE_EH:BOOL=ON \<br>  -DLLVM_ENABLE_PIC:BOOL=ON \<br>  -DLLVM_ENABLE_RTTI:BOOL=ON<br>...<br>-- Targeting X86<br>-- Targeting NVPTX<br>...<br>-- Clang version: 7.0.0<br>-- Performing Test CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG<br>-- Performing Test CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG - Failed<br>-- LLD version: 7.0.0<br>-- Configuring done<br>-- Generating done<br>-- Build files have been written to: /data/user/fwyzard/llvm/build-r339664<br><br></span></div><span style="font-family:monospace,monospace"></span><div><br></div><div><div style="margin-left:40px"><span style="font-family:monospace,monospace">$ ninja<br>...<br>[3874/3875] Linking CXX executable bin/llvm-readobj<br>[3875/3875] Generating ../../bin/llvm-readelf<br></span></div><div><br></div><div><br></div><div>If I try to include OpenMP support, it correctly finds the CUDA installation (and libelf / libffi with some help):</div><div><br></div><div><div style="margin-left:40px"><span style="font-family:monospace,monospace">$ cmake $BASE/llvm-project/llvm -G Ninja \<br>  -DLLVM_TARGETS_TO_BUILD:STRING="X86;NVPTX" \<br>  -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;compiler-rt;lld;openmp" \<br>  -DLIBOMPTARGET_DEP_LIBELF_INCLUDE_DIR:PATH="$GCC_ROOT/include" \<br>  -DLIBOMPTARGET_DEP_LIBELF_LIBRARIES:PATH="$GCC_ROOT/lib/libelf.so" \<br>  -DLIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIR:PATH="$LIBFFI_ROOT/include" \<br>  -DLIBOMPTARGET_DEP_LIBFFI_LIBRARIES:PATH="$LIBFFI_ROOT/lib64/libffi.so" \<br>  -DCMAKE_BUILD_TYPE:STRING=Release \<br>  -DCMAKE_INSTALL_PREFIX:PATH="$BASE/install-r339664" \<br>  -DLLVM_LIBDIR_SUFFIX:STRING=64 \<br>  -DBUILD_SHARED_LIBS:BOOL=ON \<br>  -DLLVM_ENABLE_EH:BOOL=ON \<br>  -DLLVM_ENABLE_PIC:BOOL=ON \<br>  -DLLVM_ENABLE_RTTI:BOOL=ON<br>...<br>-- Targeting X86<br>-- Targeting NVPTX<br>...<br>-- Found LIBOMPTARGET_DEP_LIBELF: /data/user/fwyzard/llvm/build/slc7_amd64_gcc810.llvm/slc7_amd64_gcc810/external/gcc/8.1.0/lib/libelf.so<br>-- Found LIBOMPTARGET_DEP_LIBFFI: /data/user/fwyzard/llvm/build/slc7_amd64_gcc810.llvm/slc7_amd64_gcc810/external/libffi/3.2.1/lib64/libffi.so<br>-- LIBOMPTARGET: Building offloading runtime library libomptarget.<br>-- LIBOMPTARGET: Not building aarch64 offloading plugin: machine not found in the system.<br>-- LIBOMPTARGET: Building CUDA offloading plugin.<br>-- LIBOMPTARGET: Not building PPC64 offloading plugin: machine not found in the system.<br>-- LIBOMPTARGET: Not building PPC64le offloading plugin: machine not found in the system.<br>-- LIBOMPTARGET: Building x86_64 offloading plugin.<br>-- LIBOMPTARGET: Building CUDA offloading device RTL.<br>-- Clang version: 7.0.0<br>-- LLD version: 7.0.0<br>-- Configuring done<br>-- Generating done<br>-- Build files have been written to: /data/user/fwyzard/llvm/build-r339664<br></span></div></div><div><br></div><div>but then it fails because CUDA 9.2 does not support gcc 8:</div><div><br></div><div style="margin-left:40px"><span style="font-family:monospace,monospace">ninja</span></div><div style="margin-left:40px"><span style="font-family:monospace,monospace">...</span></div><div><div style="margin-left:40px"><span style="font-family:monospace,monospace">[780/3744] Building NVCC (Device) object projects/openmp/libomptarget/deviceRTLs/nvptx/CMakeFiles/omptarget-nvptx.dir/src/omptarget-nvptx_generated_cancel.cu.o<br>FAILED: projects/openmp/libomptarget/deviceRTLs/nvptx/CMakeFiles/omptarget-nvptx.dir/src/omptarget-nvptx_generated_cancel.cu.o<br>cd /data/user/fwyzard/llvm/build-r339664/projects/openmp/libomptarget/deviceRTLs/nvptx/CMakeFiles/omptarget-nvptx.dir/src && /data/user/fwyzard/llvm/build/slc7_amd64_gcc810.llvm/slc7_amd64_gcc810/external/cmake/3.11.1/bin/cmake -E make_directory /data/user/fwyzard/llvm/b<br>In file included from /data/user/fwyzard/llvm/build/slc7_amd64_gcc810.llvm/slc7_amd64_gcc810/external/cuda/9.2.148/include/host_config.h:50,<br>                 from /data/user/fwyzard/llvm/build/slc7_amd64_gcc810.llvm/slc7_amd64_gcc810/external/cuda/9.2.148/include/cuda_runtime.h:78,<br>                 from <command-line>:<br>/data/user/fwyzard/llvm/build/slc7_amd64_gcc810.llvm/slc7_amd64_gcc810/external/cuda/9.2.148/include/crt/host_config.h:119:2: error: #error -- unsupported GNU version! gcc versions later than 7 are not supported!<br> #error -- unsupported GNU version! gcc versions later than 7 are not supported!<br></span></div><br></div><div>and so on.<br></div><div><br></div><div><br></div>Is it possible to build openmp with offload capabilities, using the just-built clang 7 itself as the compiler ?<br><div><br></div><div><br></div><div>Ciao,</div><div>.Andrea<br></div></div></div>