[cfe-dev] Problem building llvm and clang 7.0.0
Jonas Hahnfeld via cfe-dev
cfe-dev at lists.llvm.org
Wed Aug 15 07:38:17 PDT 2018
Hi Andrea,
I think right now CMake is only prepared to build the OpenMP runtime
using nvcc. That said, it could now be possible to add support for
building with Clang. This probably needs to use Relocatable Device Code
which wasn't available before Clang 7. I'm not sure if somebody is
already working on this, but that sounds like a good improvement to
make!
For now you can workaround the too recent version of GCC by using the
mentioned LIBOMPTARGET_NVPTX_ALTERNATE_HOST_COMPILER. This makes the
check pass even though the compiler is never used (libomptarget-nvptx
doesn't have any host code).
Regards,
Jonas
On 2018-08-15 15:24, Andrea Bocci wrote:
> Hi Jonas,
> I have a related question: is it possible to build the nvidia OpenMP
> support with clang itself, instead of nvcc ?
>
> 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.
>
> It builds fine if I leave out OpenMP support:
>
> $ cmake $BASE/llvm-project/llvm -G Ninja \
> -DLLVM_TARGETS_TO_BUILD:STRING="X86;NVPTX" \
> -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;compiler-rt;lld" \
> -DCMAKE_BUILD_TYPE:STRING=Release \
> -DCMAKE_INSTALL_PREFIX:PATH="$BASE/install-r339664" \
> -DLLVM_LIBDIR_SUFFIX:STRING=64 \
> -DBUILD_SHARED_LIBS:BOOL=ON \
> -DLLVM_ENABLE_EH:BOOL=ON \
> -DLLVM_ENABLE_PIC:BOOL=ON \
> -DLLVM_ENABLE_RTTI:BOOL=ON
> ...
> -- Targeting X86
> -- Targeting NVPTX
> ...
> -- Clang version: 7.0.0
> -- Performing Test CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG
> -- Performing Test CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG - Failed
> -- LLD version: 7.0.0
> -- Configuring done
> -- Generating done
> -- Build files have been written to:
> /data/user/fwyzard/llvm/build-r339664
>
> $ ninja
> ...
> [3874/3875] Linking CXX executable bin/llvm-readobj
> [3875/3875] Generating ../../bin/llvm-readelf
>
> If I try to include OpenMP support, it correctly finds the CUDA
> installation (and libelf / libffi with some help):
>
> $ cmake $BASE/llvm-project/llvm -G Ninja \
> -DLLVM_TARGETS_TO_BUILD:STRING="X86;NVPTX" \
>
> -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;compiler-rt;lld;openmp"
> \
> -DLIBOMPTARGET_DEP_LIBELF_INCLUDE_DIR:PATH="$GCC_ROOT/include" \
> -DLIBOMPTARGET_DEP_LIBELF_LIBRARIES:PATH="$GCC_ROOT/lib/libelf.so" \
> -DLIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIR:PATH="$LIBFFI_ROOT/include" \
>
> -DLIBOMPTARGET_DEP_LIBFFI_LIBRARIES:PATH="$LIBFFI_ROOT/lib64/libffi.so"
> \
> -DCMAKE_BUILD_TYPE:STRING=Release \
> -DCMAKE_INSTALL_PREFIX:PATH="$BASE/install-r339664" \
> -DLLVM_LIBDIR_SUFFIX:STRING=64 \
> -DBUILD_SHARED_LIBS:BOOL=ON \
> -DLLVM_ENABLE_EH:BOOL=ON \
> -DLLVM_ENABLE_PIC:BOOL=ON \
> -DLLVM_ENABLE_RTTI:BOOL=ON
> ...
> -- Targeting X86
> -- Targeting NVPTX
> ...
> -- Found LIBOMPTARGET_DEP_LIBELF:
> /data/user/fwyzard/llvm/build/slc7_amd64_gcc810.llvm/slc7_amd64_gcc810/external/gcc/8.1.0/lib/libelf.so
> -- Found LIBOMPTARGET_DEP_LIBFFI:
> /data/user/fwyzard/llvm/build/slc7_amd64_gcc810.llvm/slc7_amd64_gcc810/external/libffi/3.2.1/lib64/libffi.so
> -- LIBOMPTARGET: Building offloading runtime library libomptarget.
> -- LIBOMPTARGET: Not building aarch64 offloading plugin: machine not
> found in the system.
> -- LIBOMPTARGET: Building CUDA offloading 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: Building x86_64 offloading plugin.
> -- LIBOMPTARGET: Building CUDA offloading device RTL.
> -- Clang version: 7.0.0
> -- LLD version: 7.0.0
> -- Configuring done
> -- Generating done
> -- Build files have been written to:
> /data/user/fwyzard/llvm/build-r339664
>
> but then it fails because CUDA 9.2 does not support gcc 8:
>
> ninja
> ...
>
> [780/3744] Building NVCC (Device) object
> projects/openmp/libomptarget/deviceRTLs/nvptx/CMakeFiles/omptarget-nvptx.dir/src/omptarget-nvptx_generated_cancel.cu.o
> FAILED:
> projects/openmp/libomptarget/deviceRTLs/nvptx/CMakeFiles/omptarget-nvptx.dir/src/omptarget-nvptx_generated_cancel.cu.o
> 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
> 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,
> from
> /data/user/fwyzard/llvm/build/slc7_amd64_gcc810.llvm/slc7_amd64_gcc810/external/cuda/9.2.148/include/cuda_runtime.h:78,
> from <command-line>:
> /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!
> #error -- unsupported GNU version! gcc versions later than 7 are not
> supported!
>
> and so on.
>
> Is it possible to build openmp with offload capabilities, using the
> just-built clang 7 itself as the compiler ?
>
> Ciao,
> .Andrea
More information about the cfe-dev
mailing list