%global rocm_version 2.0.0 %global hcc_clang_upgrade_commit 6ec3c61e09fbb60373eaf5a40021eb862363ba2c %global hcc_clang_upgrade_shortcommit %(c=%{hcc_clang_upgrade_commit}; echo ${c:0:7}) %global llvm_commit roc-%{rocm_version} %global lld_commit roc-%{rocm_version} %global rocdl_commit roc-%{rocm_version} %global __requires_exclude libLLVM-8-rocm.so %global hcc_version_major 1 %global hcc_version_minor 3 # 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 19020 Name: hcc Version: %{hcc_version_major}.%{hcc_version_minor}.%{hcc_version_patch} Release: 1.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-Remove-broken-rocdl-symlinks.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-Set-version-for-shared-libraries.patch Patch12: 0001-rpt-Convert-to-python3.patch BuildRequires: cmake BuildRequires: hsakmt-devel BuildRequires: rocm-runtime-devel = %{rocm_version} BuildRequires: libunwind-devel BuildRequires: gcc-c++ # We need python3-devel for pathfix.py BuildRequires: python3-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-devel Requires: rocminfo %description Heterogeneous C++ Compiler supporting offload to AMD GPUs via the Radeon Open Compute (ROCm) runtime. %package runtime Summary: hcc runtime libraries %description runtime hcc runtime libraries %package runtime-devel Summary: Development files for hcc runtime libraries Requires: %{name}-runtime%{?_isa} = %{version}-%{release} %description runtime-devel Development files for 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 %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 .fix-rocdl-symlinks %patch8 -p1 -b .hcc-version %patch9 -p1 -b .lib64-install %patch10 -p1 -b .headers-install %patch11 -p1 -b .shlib-versions %patch12 -p1 -b .rpt-py3 pathfix.py -i %{__python3} lib/rpt 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/8.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} \ LLVMSelectAcceleratorCode \ LLVMPromotePointerKernArgsToGlobal \ 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 error-check; do mv %{buildroot}{/usr,%{_libexecdir}/hcc}/bin/$f done 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}/LLVMSelectAcceleratorCode.so %{buildroot}%{_libexecdir}/hcc/%{build_libdir} install -m 0644 compiler/%{build_libdir}/LLVMPromotePointerKernArgsToGlobal.so %{buildroot}%{_libexecdir}/hcc/%{build_libdir} install -m 0644 compiler/%{build_libdir}/libLLVM-8-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.%{hcc_version_major}.%{hcc_version_minor} %{_libdir}/libmcwamp_hsa.so.%{hcc_version_major}.%{hcc_version_minor} %{_libdir}/libmcwamp.so.%{hcc_version_major}.%{hcc_version_minor} %{_libdir}/libmcwamp_cpu.so.%{hcc_version_major}.%{hcc_version_minor} %files runtime-devel %{_libdir}/libhc_am.so %{_libdir}/libmcwamp_hsa.so %{_libdir}/libmcwamp.so %{_libdir}/libmcwamp_cpu.so %{_libdir}/libmcwamp_atomic.a %changelog * Wed Jan 16 2019 Tom Stellard - 1.3.19020-1.rocm2.0.0 - ROCm 2.0.0 Release * 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.