%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 Name: hcc Version: 1.1.0 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-Use-hcc-in-scripts-instead-of-clang.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 %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 %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 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 \ -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 %if 0%{?__isa_bits} == 64 mkdir -p %{buildroot}%{_libdir} mv %{buildroot}{/usr/lib/*,%{_libdir}} %endif sed -i 's|^#!/usr/bin/python|#!/usr/bin/python2|' %{buildroot}%{_bindir}/rpt # 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. make -C include install ln -s %{_includedir} %{buildroot}%{_includedir}/hcc # 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} %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 * 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.