%global rocm_version 1.7.0 %global hcc_clang_upgrade_commit 42ceed861a212d9bd0aef883ee7981144f3ecc02 %global hcc_clang_upgrade_shortcommit %(c=%{hcc_clang_upgrade_commit}; echo ${c:0:7}) %global llvm_commit 23e086be6f627e6e983c6789d2e77da6bf85ebb6 %global llvm_shortcommit %(c=%llvm_commit}; echo ${c:0:7}) %global lld_commit 3844d469706d4434c1cf2e7661ed52dab92d7846 %global lld_shortcommit %(c=%lld_commit}; echo ${c:0:7}) %global rocdl_commit d44d5ea5030a72e068a558a9213bb6decd8b1645 %global rocdl_shortcommit %(c=%rocdl_commit}; echo ${c:0:7}) %global __requires_exclude libLLVM-6.0-rocm.so # This comes is generated by using the commit date of the most recent commit: # date -d $COMMIT_DATE --utc '+%y%U%w' # hip will fail to build if we don't set this. # Only update this for each new feature release e.g. ROCm 1.7.0 and not for bug # fix releases e.g. ROCm 1.7.1. %global hcc_version_patch 17503 Name: hcc Version: 1.1.%{hcc_version_patch} 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/roc-%{rocm_version}/hcc-roc-%{rocm_version}.tar.gz Source1: https://github.com/RadeonOpenCompute/hcc-clang-upgrade/archive/%{hcc_clang_upgrade_commit}/hcc-clang-upgrade-%{hcc_clang_upgrade_commit}-roc-%{rocm_version}.tar.gz Source2: https://github.com/RadeonOpenCompute/llvm/archive/%{llvm_commit}/llvm-roc-%{rocm_version}.tar.gz Source3: https://github.com/RadeonOpenCompute/lld/archive/%{lld_commit}/lld-roc-%{rocm_version}.tar.gz Source4: https://github.com/RadeonOpenCompute/ROCm-Device-Libs/archive/%{rocdl_commit}/device-libs-%{rocm_version}.tar.gz Patch0: 0001-Remove-compiler-rt-dependency.patch Patch1: 0001-Look-for-rocm_agent_enumerator-in-usr-bin.patch Patch2: 0001-Disable-compiler-rt-build.patch Patch3: 0001-Disable-cmake-tests-build.patch Patch4: 0001-Remove-compiler-rt-install-target.patch Patch5: 0001-Load-opt-plugins-from-BINDIR-lib64.patch Patch6: 0001-Hard-code-rocm-device-libs-search-path-to-usr-share-.patch Patch7: 0001-Use-hcc-in-scripts-instead-of-clang.patch Patch8: 0001-Make-HCC_VERSION_PATCH-configurable.patch Patch9: 0001-Dont-force-libdir-to-lib.patch Patch10: 0001-Install-headers-to-usr-include-hcc.patch Patch11: 0001-Fixes-for-devtoolset-7.patch Patch12: 0001-workaround-build-issue-on-RHEL.patch Patch13: 0001-clamp-link-Hard-code-devtoolset-7-linker.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: libunwind-devel Requires: libstdc++-devel Requires: file Requires: rocm-device-libs Requires: hcc-runtime Requires: rocminfo %{!?enable_llvmtoolset7: %define enable_llvmtoolset7 %{nil}} %{!?enable_devtoolset7: %define enable_devtoolset7 %{nil}} %if 0%{?rhel} == 7 # FIXME: Manually define enable_llvmtoolset7 until llvm-toolset-7-5.0.1 is # available %enable_llvmtoolset7 %global ___build_pre %{___build_pre}; source scl_source enable llvm-toolset-7 || : BuildRequires: llvm-toolset-7-cmake BuildRequires: llvm-toolset-7-runtime BuildRequires: devtoolset-7-build BuildRequires: devtoolset-7-gcc-c++ Requires: devtoolset-7-gcc-c++ %enable_llvmtoolset7 %enable_devtoolset7 %global __cmake cmake %endif %description Heterogeneous C++ Compiler %package runtime Summary: hcc runtime libraries %description runtime hcc runtime libraries %package -n rocm-device-libs Summary: ROCm device library BuildArch: noarch Version: 0.0.1 %description -n rocm-device-libs ROCm device library %prep %setup -T -q -b 4 -n ROCm-Device-Libs-%{rocdl_commit} %setup -T -q -b 1 -n hcc-clang-upgrade-%{hcc_clang_upgrade_commit} %patch0 -p1 -b .no-compiler-rt %patch1 -p1 -b .agent-enumerator %patch11 -p1 -b .devtoolset-7 %setup -T -q -b 3 -n lld-%{lld_commit} %setup -T -q -b 2 -n llvm-%{llvm_commit} %setup -q -n hcc-roc-%{rocm_version} %patch2 -p1 -b .disable-compiler-rt %patch3 -p1 -b .disable-cmake-tests %patch4 -p1 -b .remove-compiler-rt-install %patch5 -p1 -b .plugin-dir %patch6 -p1 -b .rocm-search-path %patch7 -p1 -b .hcc-in-scripts %patch8 -p1 -b .hcc-version %patch9 -p1 -b .lib64-install %patch10 -p1 -b .headers-install %patch12 -p1 -b .rhel-build-fix %if 0%{?rhel} == 7 %patch13 -p1 -b .devtoolset-ld %endif mv ../llvm-%{llvm_commit}/* compiler mv ../hcc-clang-upgrade-%{hcc_clang_upgrade_commit}/* clang mv ../lld-%{lld_commit}/* lld mv ../ROCm-Device-Libs-%{rocdl_commit}/* rocdl %build %global optflags %(echo %{optflags} | sed 's/-g / /') %global llvm_tools llc llvm-as llvm-dis llvm-link llvm-objdump opt clang-offload-bundler mkdir build cd build # FXIME: Dont use %%cmake macro, because it will reset the default CXXFLAGS # which have options that hcc doesn't support. %__cmake .. \ %if 0%{?__isa_bits} == 64 -DCMAKE_INSTALL_PREFIX=%{buildroot}/usr \ -DCMAKE_BUILD_TYPE=RELWITHDEBINFO \ -DLLVM_LIBDIR_SUFFIX=64 \ %else -DLLVM_LIBDIR_SUFFIX= \ %endif -DBUILD_SHARED_LIBS=OFF \ -DLLVM_ENABLE_ASSERTIONS=Off \ -DAMDGPU_TARGET=auto \ -DLLVM_TARGETS_TO_BUILD="AMDGPU;X86" \ -DENABLE_LINKER_BUILD_ID=ON \ -DLLVM_BUILD_LLVM_DYLIB=ON \ -DLLVM_LINK_LLVM_DYLIB=ON \ -DLLVM_VERSION_SUFFIX="-rocm" \ -DLLVM_INCLUDE_EXAMPLES=off \ -DHCC_VERSION_PATCH="%{hcc_version_patch}" \ -DROCM_DEVICE_LIB=%{_datadir}/rocm/ %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. ln -s %{_builddir}/hcc-%{hcc_commit}/build/compiler/%{build_libdir}/clang/6.0.0 compiler/bin/hcc-resource-dir # HACK So that hcc can find the plugins from the build directory ln -s %{_builddir}/hcc-%{hcc_commit}/build/compiler/%{build_libdir} compiler/bin/lib64 make %{?_smp_mflags} \ clang \ lld \ %{llvm_tools} \ LLVMWrapperGen \ LLVMDirectFuncCall \ LLVMSelectAcceleratorCode \ LLVMTileUniform \ hcc-config \ mcwamp_hsa \ mcwamp \ rocdl_links %install mkdir -p %{buildroot}%{_libexecdir}/hcc mkdir -p %{buildroot}%{_libexecdir}/hcc/bin mkdir -p %{buildroot}%{_libexecdir}/hcc/%{build_libdir} cd build make -C hcc_config install make -C lib install for f in clamp-device clamp-embed clamp-assemble clamp-link hc-kernel-assemble hc-host-assemble; do mv %{buildroot}{/usr,%{_libexecdir}/hcc}/bin/$f done sed -i 's|^#!/usr/bin/python|#!/usr/bin/python2|' %{buildroot}%{_bindir}/rpt make -C include install # Remove installed CMakeLists.txt file rm %{buildroot}%{_includedir}/hcc/CMakeLists.txt.headers-install # Some applications look for the headers in /usr/include so symlink the includes # from /usr/include/hcc to /usr/include for f in `ls %{buildroot}%{_includedir}/hcc`; do ln -s %{_includedir}/hcc/$f %{buildroot}%{_includedir}/$f done # Install ROCm device libs mkdir -p %{buildroot}%{_datadir}/rocm install -m 0644 rocdl/lib/*.bc %{buildroot}%{_datadir}/rocm install -m 0755 compiler/bin/hcc %{buildroot}%{_libexecdir}/hcc/bin/ ln -s %{_libexecdir}/hcc/bin/hcc %{buildroot}%{_bindir}/hcc for f in %{llvm_tools} ld.lld; do install -m 0755 compiler/bin/$f %{buildroot}%{_libexecdir}/hcc/bin/ done # Install internal headers for hcc mv compiler/%{build_libdir}/clang/ %{buildroot}%{_libexecdir}/hcc/%{build_libdir} # Install plugins install -m 0644 compiler/%{build_libdir}/LLVMWrapperGen.so %{buildroot}%{_libexecdir}/hcc/%{build_libdir} install -m 0644 compiler/%{build_libdir}/LLVMDirectFuncCall.so %{buildroot}%{_libexecdir}/hcc/%{build_libdir} install -m 0644 compiler/%{build_libdir}/LLVMTileUniform.so %{buildroot}%{_libexecdir}/hcc/%{build_libdir} install -m 0644 compiler/%{build_libdir}/LLVMSelectAcceleratorCode.so %{buildroot}%{_libexecdir}/hcc/%{build_libdir} install -m 0644 compiler/%{build_libdir}/libLLVM-6.0-rocm.so %{buildroot}%{_libexecdir}/hcc/%{build_libdir} # Install some stray cmake files install -m 0644 ../scripts/cmake/ImportedTargets.cmake %{buildroot}%{_libdir}/cmake/hcc %files %doc README.md %license LICENSE.TXT %{_libexecdir}/hcc/ %{_bindir}/hcc %{_bindir}/hcc-config %{_bindir}/clamp-config %{_bindir}/extractkernel %{_bindir}/rpt %{_includedir}/* %{_libdir}/cmake/hcc/ %files -n rocm-device-libs %{_datadir}/rocm/ %files runtime %{_libdir}/libhc_am.so %{_libdir}/libmcwamp_hsa.so %{_libdir}/libmcwamp.a %{_libdir}/libmcwamp_cpu.so %{_libdir}/libmcwamp_atomic.a %changelog * Mon Mar 12 2018 Tom Stellard - 1.1.17503-8.rocm1.7.0 - Make sure to always use devtoolset ld * Wed Mar 07 2018 Tom Stellard - 1.1.17503-7.rocm1.7.0 - Make sure to use devtoolset linker on epel/RHEL * Mon Mar 05 2018 Tom Stellard - 1.1.17503-6.rocm1.7.0 - Add epel support * Wed Feb 28 2018 Tom Stellard - 1.1.17503-5.rocm1.7.0 - Don't symlink /usr/include/hcc to /usr/include * Tue Feb 27 2018 Tom Stellard - 1.1.17503-4.rocm1.7.0 - Fix typo in install command * Tue Feb 27 2018 Tom Stellard - 1.1.17503-3.rocm1.7.0 - Install missing cmake file * Mon Feb 26 2018 Tom Stellard - 1.1.17503-2.rocm1.7.0 - Fix library paths in installed camke files * Fri Feb 23 2018 Tom Stellard - 1.1.17503-1.rocm1.7.0 - Specify HCC_VERSION_PATCH to satisfy hip * Thu Feb 22 2018 Tom Stellard - 1.1.0-1.rocm1.7.0 - ROCm 1.7.0 * Tue Feb 20 2018 Tom Stellard - 1.0-19.rocm1.6.0 - Add dependency on rocminfo * Tue Feb 20 2018 Tom Stellard - 1.0-18.rocm1.6.0 - Re-enable signal pool * Fri Feb 16 2018 Tom Stellard - 1.0-17.rocm1.6.0 - Use make install targets when possible. - This fixes an issue with some missing cmake files. * Fri Feb 16 2018 Tom Stellard - 1.0-16.rocm1.6.0 - Move runtime libraries to their own sub-package * Wed Feb 14 2018 Tom Stellard - 1.0-15.rocm1.6.0 - Split rocm-device-libs into a sub-package * Tue Feb 13 2018 Tom Stellard - 1.0-14.rocm1.6.0 - Link against internal libLLVM.so to reduce memory usage for builds * Thu Feb 08 2018 Tom Stellard - 1.0-13.rocm1.6.0 - Enable debuginfo * Thu Feb 08 2018 Tom Stellard - 1.0-12.rocm1.6.0 - Add ExclusiveArch: x86_64 * Thu Feb 08 2018 Tom Stellard - 1.0-11.rocm1.6.0 - Add lincense and doc * Thu Feb 08 2018 Tom Stellard - 1.0-10.rocm1.6.0 - Fix directory ownership * Wed Feb 07 2018 Tom Stellard - 1.0-9.rocm1.6.0 - Integrate rocdl * Wed Dec 20 2017 Tom Stellard - 1.0-8.rocm1.6.0 - Update version to match upstream.