%global rocm_version 2.5.0 %global hcc_clang_upgrade_commit roc-%{rocm_version} %global hcc_clang_upgrade_shortcommit %(c=%{hcc_clang_upgrade_commit}; echo ${c:0:7}) %global llvm_commit roc-hcc-%{rocm_version} %global lld_commit roc-hcc-%{rocm_version} %global rocdl_commit roc-%{rocm_version} %global __requires_exclude libLLVM-9-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: # COMMIT_DATE=`git show -s --format=@%ct` # 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 18505 %ifarch aarch64 %global llvm_native_target AArch64 %endif %ifarch x86_64 %global llvm_native_target X86 %endif Name: hcc Version: %{hcc_version_major}.%{hcc_version_minor}.%{hcc_version_patch} Release: 3.rocm%{rocm_version}%{?dist} Summary: HCC C++ Compiler # stl-test/*.pl.in are ASL 2.0 # utils/gtest is BSD # lib/hsa/unpinnned_copy_engine.* and hc2/external/elfio are MIT License: NCSA and ASL 2.0 and BSD and MIT 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-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-roc-%{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 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 Patch13: 0001-Install-irif.amdgcn.bc.patch Patch14: 0001-hcc-config-Add-usr-include-hcc-to-include-directorie.patch Patch15: 0001-Install-experimental-headers-to-include-hc.patch Patch16: 0001-Fix-paths-in-hcc-config.cmake.in.patch Patch17: 0001-Install-internal-tools-to-libexecdir.patch Patch18: 0001-Build-mcwamp_atomic-as-a-shared-library.patch Patch20: 0001-Filter-out-cxx-flags-not-supported-by-hcc-when-build.patch ExclusiveArch: x86_64 aarch64 BuildRequires: cmake BuildRequires: hsakmt-devel BuildRequires: rocm-runtime-devel = %{rocm_version} BuildRequires: gcc-c++ # We need python3-devel for pathfix.py BuildRequires: python3-devel # Need because the hcc runtime libraries have enabled excutable stacks. BuildRequires: execstack # gcc-c++ is required because it installs the symlink libstdc++.so, which is # needed when passing -lstdc++ to the linker. Requires: gcc-c++ Requires: libstdc++-devel Requires: file Requires: rocm-device-libs Requires: hcc-runtime-devel Requires: rocminfo # The bundled version is a trunk snapshot between 7.0.0 and 8.0.0. Provides: bundled(llvm) %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 %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 %patch13 -p1 -b .irif %patch14 -p1 -b .hcc-config-headers %patch15 -p1 -b .experimental-headers-install %patch16 -p1 -b .fix-hcc-config-paths %patch17 -p1 -b .tools-install %patch18 -p1 -b .atomic-shared %patch20 -p1 -b .runtime-cxxflags 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 llvm_tools llc llvm-as llvm-dis llvm-link llvm-objdump opt clang-offload-bundler mkdir build cd build %cmake .. \ -DCMAKE_INSTALL_PREFIX=%{buildroot}%{_prefix} \ -DCMAKE_BUILD_TYPE=RELWITHDEBINFO \ %if 0%{?__isa_bits} == 64 -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;%{llvm_native_target}" \ -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/ \ -DCMAKE_INSTALL_INCLUDEDIR=%{_includedir} \ -DROCM_ROOT=%{_prefix} # 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/%{_lib}/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/%{_lib} 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/%{_lib} cd build make -C hcc_config install make -C lib install # Disable executable stack for runtime libraries. execstack -c %{buildroot}%{_libdir}/*.so.%{hcc_version_major}.%{hcc_version_minor} make -C include install # Remove installed CMakeLists.txt file rm %{buildroot}%{_includedir}/hcc/CMakeLists.txt.headers-install # 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} lld; do install -m 0755 compiler/bin/$f %{buildroot}%{_libexecdir}/hcc/bin/ done ln -s lld %{buildroot}%{_libexecdir}/hcc/bin/ld.lld # Install internal headers for hcc mv compiler/%{_lib}/clang/ %{buildroot}%{_libexecdir}/hcc/%{_lib} # Install plugins. Make these executable, so find-debuginfo.sh will strip them. install -m 0755 compiler/%{_lib}/LLVMSelectAcceleratorCode.so %{buildroot}%{_libexecdir}/hcc/%{_lib} install -m 0755 compiler/%{_lib}/LLVMPromotePointerKernArgsToGlobal.so %{buildroot}%{_libexecdir}/hcc/%{_lib} install -m 0755 compiler/%{_lib}/libLLVM-9-rocm.so %{buildroot}%{_libexecdir}/hcc/%{_lib} # 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 %files -n rocm-device-libs %license rocdl/LICENSE %{_datadir}/rocm/ %files runtime %license LICENSE.TXT %{_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} %{_libdir}/libmcwamp_atomic.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.so %{_includedir}/hcc/ %{_libdir}/cmake/hcc/ %changelog * Tue Sep 17 2019 Tom Stellard - 1.3.18505-3.rocm2.5.0 - ROCm 2.5.0 Release * Tue Feb 12 2019 Tom Stellard - 1.3.18505-2.rocm2.0.0 - Address some review comments * Wed Jan 16 2019 Tom Stellard - 1.3.18505-1.rocm2.0.0 - ROCm 2.0.0 Release