%global cclang_70_commit_id 6257ffe137a2c8df95a3f3b39fa477aa8ed15837 %global spirv_llvm_70_commit_id 8ce6443ec1020183eafaeb3410c7d1edc2355dc3 %global llvm_commit_id release_70 %global clang_commit_id release_70 %global package_version 7.0.68 %global package_release 1 Name: intel-opencl-clang Version: %{package_version} Release: %{package_release}%{?dist} Summary: Intel(R) OpenCL(TM) Clang Group: System Environment/Libraries License: MIT URL: https://github.com/intel/opencl-clang Source0: https://github.com/intel/opencl-clang/archive/%{cclang_70_commit_id}/intel-opencl-clang-70.tar.gz Source1: https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/%{spirv_llvm_70_commit_id}/spirv-llvm-translator-70.tar.gz Source2: https://github.com/llvm-mirror/llvm/archive/%{llvm_commit_id}/llvm-70.tar.gz Source3: https://github.com/llvm-mirror/clang/archive/%{clang_commit_id}/clang-70.tar.gz BuildRequires: git %if 0%{?el7} BuildRequires: centos-release-scl epel-release BuildRequires: gcc-c++ make patch devtoolset-6-gcc-c++ cmake3 ninja-build %else %if 0%{?fedora} == 29 BuildRequires: cmake clang gcc-c++ make patch BuildRequires: llvm-devel >= 7.0.0, llvm-devel < 8.0.0 BuildRequires: clang-devel >= 7.0.0, clang-devel < 8.0.0 %else %if 0%{?fedora} == 30 BuildRequires: cmake clang gcc-c++ make patch BuildRequires: llvm7.0-devel llvm7.0-static BuildRequires: clang7.0-devel %endif %endif %endif %if 0%{?el7} %define _unpackaged_files_terminate_build 0 %endif %description Common clang is a thin wrapper library around clang. Common clang has OpenCL-oriented API and is capable to compile OpenCL C kernels to SPIR-V modules. %package devel Summary: Development files Intel(R) OpenCL(TM) Clang Requires: %{name} = %{version}-%{release} %description devel %clean echo "==== CLEAN ====" %prep echo "==== PREP ====" %if 0%{?el7} mkdir src tar xzf $RPM_SOURCE_DIR/llvm-70.tar.gz -C src --strip-components=1 cd src/tools mkdir clang tar xzf $RPM_SOURCE_DIR/clang-70.tar.gz -C clang --strip-components=1 cd ../projects/ mkdir opencl-clang llvm-spirv tar xzf $RPM_SOURCE_DIR/intel-opencl-clang-70.tar.gz -C opencl-clang --strip-components=1 tar xzf $RPM_SOURCE_DIR/spirv-llvm-translator-70.tar.gz -C llvm-spirv --strip-components=1 %else mkdir opencl-clang spirv-llvm tar xzf $RPM_SOURCE_DIR/intel-opencl-clang-70.tar.gz -C opencl-clang --strip-components=1 tar xzf $RPM_SOURCE_DIR/spirv-llvm-translator-70.tar.gz -C spirv-llvm --strip-components=1 %endif %build echo "==== BUILD ====" %if 0%{?el7} mkdir build_cc echo building for el7: %{el7} pushd build_cc scl enable devtoolset-6 "cmake3 ../src/ -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86 -DCOMMON_CLANG_LIBRARY_NAME=opencl-clang -DCMAKE_INSTALL_PREFIX=/usr -DLLVM_BUILD_TOOLS=OFF -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_TESTS=OFF -DLLVM_INCLUDE_BENCHMARKS=OFF" scl enable devtoolset-6 "make opencl-clang -j8 install DESTDIR=../inst_cc" popd find inst_cc %else mkdir build_cc build_s %if 0%{?fedora} == 30 export LLVM_DIR=/usr/lib64/llvm7.0/lib/cmake/llvm/ %endif echo building for %{dist} pushd build_s cmake ../spirv-llvm/ -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-fPIC" -DCMAKE_INSTALL_PREFIX=/usr make -j8 install DESTDIR=../inst_s popd pushd build_cc cmake ../opencl-clang/ -DCMAKE_BUILD_TYPE=Release -DCOMMON_CLANG_LIBRARY_NAME="opencl-clang" -DLLVMSPIRV_INCLUDED_IN_LLVM=OFF -DSPIRV_TRANSLATOR_DIR=../inst_s/usr/ -DCMAKE_INSTALL_PREFIX=/usr make -j8 install DESTDIR=../inst_cc popd %endif %install echo "==== INSTALL ====" cd build_cc make install DESTDIR=$RPM_BUILD_ROOT %files %if 0%{?el7} /usr/lib/libopencl-clang.so.7.1 /usr/lib/libopencl-clang.so.7.1.0 %else %if 0%{?fedora} == 30 /usr/lib/libopencl-clang.so.7 %else /usr/lib64/libopencl-clang.so.7 %endif %endif %files devel %if 0%{?el7} /usr/lib/libopencl-clang.so %else %if 0%{?fedora} == 30 /usr/lib/libopencl-clang.so %else /usr/lib64/libopencl-clang.so %endif %endif /usr/include/cclang/common_clang.h %doc %changelog