# Disable debuginfo to avoid slow / large builds for now. %global debug_package %{nil} %global rocm_version 1.6.0 Name: hcc Version: 1.0 Release: 8.rocm%{rocm_version}%{?dist} Summary: HCC C++ Compiler License: NCSA URL: https://github.com/RadeonOpenCompute/ROCm Source0: https://github.com/RadeonOpenCompute/hcc/archive/rocm-1.6.0/hcc-rocm-1.6.0.tar.gz Source1: https://github.com/RadeonOpenCompute/hcc-clang-upgrade/archive/rocm-1.6.0/hcc-clang-upgrade-rocm-1.6.0.tar.gz Source2: https://github.com/RadeonOpenCompute/llvm/archive/rocm-1.6.0/llvm-rocm-1.6.0.tar.gz Source3: https://github.com/RadeonOpenCompute/lld/archive/rocm-1.6.0/lld-rocm-1.6.0.tar.gz Source4: https://github.com/RadeonOpenCompute/ROCm-Device-Libs/archive/roc-1.6.1/device-libs-1.6.1.tar.gz Patch0: 0001-CMake-Remove-clang-dependency-from-world-target.patch Patch1: 0001-Don-t-build-clang-before-runtime-libraries.patch Patch2: 0001-Load-opt-plugins-from-BINDIR.patch Patch3: 0001-Use-hcc-in-scripts-instead-of-clang.patch Patch4: 0001-clamp-link-Add-hcc-resource-dir-to-linker-args.patch Patch5: 0001-Remove-compiler-rt-dependency.patch Patch6: 0001-Disable-signal-pool.patch BuildRequires: cmake BuildRequires: hsakmt-devel BuildRequires: rocm-runtime-devel BuildRequires: libunwind-devel # gcc-c++ is required because it installs the symlink libstdc++.so, which is # needed when passing -lstdc++ to the linker. Requires: gcc-c++ Requires: rocm-device-libs Requires: libunwind-devel Requires: libstdc++-devel Requires: file Requires: rocm-device-libs-clc Requires: rocm-runtime %description HCC C++ Compiler %package -n rocm-device-libs-clc Summary: Compiler for rocm-device-libs %description -n rocm-device-libs-clc hcc compiler with minimal depencies that can be used to build the rocm-device-libs. %prep %setup -T -q -b 4 -n ROCm-Device-Libs-roc-1.6.1 %setup -T -q -b 1 -n hcc-clang-upgrade-rocm-%{rocm_version} %patch5 -p1 -b .no-compiler-rt %setup -T -q -b 3 -n lld-rocm-%{rocm_version} %setup -T -q -b 2 -n llvm-rocm-%{rocm_version} mv ../hcc-clang-upgrade-rocm-%{rocm_version} tools/clang mv ../lld-rocm-%{rocm_version} tools/lld %setup -q -n hcc-rocm-%{rocm_version} %patch0 -p1 -b .world-clang %patch1 -p1 -b .lib-dep-clang %patch2 -p1 -b .plugin-dir %patch3 -p1 -b .hcc-clang %patch4 -p1 -b .clang-resource %patch6 -p1 -b .disable-signal-pool %build %global optflags %(echo %{optflags} | sed 's/-g / /') %global llvm_tools llc llvm-as llvm-dis llvm-link llvm-objdump opt clang-offload-bundler cd ../llvm-rocm-%{rocm_version} mkdir build cd build # Use release build type to avoid slow / large builds for now. %cmake .. \ -DCMAKE_BUILD_TYPE=Release \ %if 0%{?__isa_bits} == 64 -DLLVM_LIBDIR_SUFFIX=64 \ -DCLANG_RESOURCE_DIR=hcc-resource-dir/ \ %else -DLLVM_LIBDIR_SUFFIX= \ -DCLANG_RESOURCE_DIR=hcc-resource-dir/ \ %endif -DBUILD_SHARED_LIBS=OFF \ -DLLVM_ENABLE_ASSERTIONS=Off \ -DKALMAR_VERSION_STRING=1.0.17441--- \ -DKALMAR_VERSION_MAJOR=1 \ -DKALMAR_VERSION_MINOR=0 \ -DKALMAR_VERSION_PATCH=17441 \ -DKALMAR_SDK_COMMIT= \ -DKALMAR_FRONTEND_COMMIT= \ -DKALMAR_BACKEND_COMMIT= \ -DKALMAR_BACKEND=HCC_BACKEND_AMDGPU \ -DAMDGPU_TARGET=auto \ -DLLVM_TARGETS_TO_BUILD="AMDGPU;X86" \ -DLLVM_INCLUDE_EXAMPLES=off make %{?_smp_mflags} clang lld %{llvm_tools} LLVMWrapperGen LLVMDirectFuncCall LLVMEraseNonkernel LLVMTileUniform %if 0%{?__isa_bits} == 64 %global build_libdir lib64 %else %global build_libdir lib %endif # HACK so that the custom CLANG_RESOURCE_DIR we use works when clang is called # from the build directory. CLANG_VERSION=`ls %{build_libdir}/clang/` ln -s ../%{build_libdir}/clang/$CLANG_VERSION bin/hcc-resource-dir cd ../../hcc-rocm-%{rocm_version} mkdir build cd build # The default LDFLAGS include: -specs=/usr/lib/rpm/redhat/redhat-hardened-ld' # which casuse a failure when likning: # /usr/bin/ld: CMakeFiles/hcc-config.dir/hcc_config.cpp.o: # relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC # /usr/bin/ld: final link failed: Nonrepresentable section on output # FIXME: We should investigate and fix this in the source. export LDFLAGS='-Wl,-z,relro' %cmake .. \ -DHCC_INTEGRATE_ROCDL=OFF \ -DHCC_RUNTIME_DEBUG=ON \ -DROCM_DEVICE_LIB=%{_datadir}/rocm/ \ -DCMAKE_CXX_COMPILER=`pwd`/../../llvm-rocm-%{rocm_version}/build/bin/hcc export PATH=$PATH:`pwd`/compiler/bin make %{?_smp_mflags} hcc-config mcwamp_hsa mcwamp cd ../../ROCm-Device-Libs-roc-1.6.1 mkdir build cd build %cmake .. \ -DLLVM_DIR=%{_builddir}/llvm-rocm-%{rocm_version}/build/%{build_libdir}/cmake/llvm \ make prepare-builtins %install mkdir -p %{buildroot}%{_bindir} mkdir -p %{buildroot}%{_libexecdir}/hcc mkdir -p %{buildroot}%{_libdir} mkdir -p %{buildroot}%{_libdir}/cmake/hcc mkdir -p %{buildroot}%{_includedir} cd build install -m 0755 bin/hcc-config %{buildroot}%{_bindir} install -m 0755 lib/libhc_am.so %{buildroot}%{_libdir} install -m 0755 lib/libmcwamp_hsa.so %{buildroot}%{_libdir} install -m 0755 lib/libmcwamp.so %{buildroot}%{_libdir} install -m 0755 compiler/bin/* %{buildroot}%{_libexecdir}/hcc # The headers should really go into {_includedir}/hcc, but existing apps expect # the headers to be in {_includedir}. So, we will add a symlink from #{_includedir}/hcc to {includedir} to make the transition easier if upstream # changes this. install -m 0644 include/*.h* %{buildroot}%{_includedir} install -m 0644 include/*.inl* %{buildroot}%{_includedir} ln -s %{_includedir} %{buildroot}%{_includedir}/hcc install -m 0644 lib/hcc-config.cmake %{buildroot}%{_libdir}/cmake/hcc install -m 0644 lib/hcc-config-version.cmake %{buildroot}%{_libdir}/cmake/hcc install -m 0644 lib/CMakeFiles/Export/lib64/cmake/hcc/hcc-targets.cmake %{buildroot}%{_libdir}/cmake/hcc cd ../../llvm-rocm-%{rocm_version}/build install -m 0755 bin/hcc %{buildroot}%{_libexecdir}/hcc install -m 0755 bin/ld.lld %{buildroot}%{_libexecdir}/hcc ln -s %{_libexecdir}/hcc/hcc %{buildroot}%{_bindir}/hcc for f in %{llvm_tools} ld.lld; do install -m 0755 bin/$f %{buildroot}%{_libexecdir}/hcc done # Install internal headers for hcc mkdir -p %{buildroot}%{_libexecdir}/hcc/hcc-resource-dir/ # How to install directories with install ? mv %{build_libdir}/clang/*/include %{buildroot}%{_libexecdir}/hcc/hcc-resource-dir/ install -m 0644 %{build_libdir}/LLVMWrapperGen.so %{buildroot}%{_libexecdir}/hcc install -m 0644 %{build_libdir}/LLVMDirectFuncCall.so %{buildroot}%{_libexecdir}/hcc install -m 0644 %{build_libdir}/LLVMEraseNonkernel.so %{buildroot}%{_libexecdir}/hcc install -m 0644 %{build_libdir}/LLVMTileUniform.so %{buildroot}%{_libexecdir}/hcc cd ../../ROCm-Device-Libs-roc-1.6.1/build install -m 0755 utils/prepare-builtins/prepare-builtins %{buildroot}%{_libexecdir}/hcc %files %doc %exclude %{_libexecdir}/hcc/hcc %exclude %{_libexecdir}/hcc/llvm-link %exclude %{_libexecdir}/hcc/llvm-objdump %exclude %{_libexecdir}/hcc/prepare-builtins %exclude %{_libexecdir}/hcc/hcc-resource-dir/include/opencl-c.h %{_libexecdir}/hcc/* %{_bindir}/hcc %{_bindir}/hcc-config %{_libdir}/libhc_am.so %{_libdir}/libmcwamp_hsa.so %{_libdir}/libmcwamp.so %{_includedir}/* %{_libdir}/cmake/hcc/* %files -n rocm-device-libs-clc %{_libexecdir}/hcc/hcc %{_libexecdir}/hcc/llvm-link %{_libexecdir}/hcc/llvm-objdump %{_libexecdir}/hcc/prepare-builtins %{_libexecdir}/hcc/hcc-resource-dir/include/opencl-c.h %changelog * Wed Dec 20 2017 Tom Stellard - 1.0-8.rocm1.6.0 - Update version to match upstream. * Sat Dec 16 2017 Tom Stellard - 1.6.0-7 - Package cmake files * Fri Dec 15 2017 Tom Stellard - 1.6.0-6 - Install .inl files * Wed Dec 13 2017 Tom Stellard - 1.6.0-5 - Fix permissions on shared objects so that they are automatically added to Provides list * Fri Dec 08 2017 Tom Stellard - 1.6.0-4 - Add sub-package for compiling rocm-device-libs * Wed Dec 06 2017 Tom Stellard - 1.6.0-3 - Disable signal pool * Wed Dec 06 2017 Tom Stellard - 1.6.0-2 - Add Requres: rocm-runtime