%global rocm_version 1.6.0 %global __requires_exclude libLLVM-5.0-rocm.so Name: hcc Version: 1.0 Release: 19.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 Patch7: 0001-Add-mutable-qualifier-to-lambdas-to-fix-errors.patch Patch8: 0001-Fixes-for-rocdl-target.patch Patch9: 0001-Revert-Use-new-intrinsics.patch Patch10: 0001-Look-for-rocm_agent_enumerator-in-usr-bin.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-roc-1.6.1 %patch9 -p1 -b .revert-new-intrinsics %setup -T -q -b 1 -n hcc-clang-upgrade-rocm-%{rocm_version} %patch5 -p1 -b .no-compiler-rt %patch10 -p1 -b .agent-enumerator %setup -T -q -b 3 -n lld-rocm-%{rocm_version} %patch7 -p1 -b .gcc8-fixes %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 %patch8 -p1 -b .rocdl sed -i 's/@ROCM_DEVICE_LIB_PATHS@/\/usr\/share\/rocm/g' lib/clamp-device.in mv ../ROCm-Device-Libs-roc-1.6.1/* 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 cd ../llvm-rocm-%{rocm_version} mkdir build cd build # Use release build type to avoid slow / large builds for now. %cmake .. \ %if 0%{?__isa_bits} == 64 -DLLVM_LIBDIR_SUFFIX=64 \ %else -DLLVM_LIBDIR_SUFFIX= \ %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" \ -DENABLE_LINKER_BUILD_ID=ON \ -DLLVM_BUILD_LLVM_DYLIB=ON \ -DLLVM_LINK_LLVM_DYLIB=ON \ -DLLVM_VERSION_SUFFIX="-rocm" \ -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 # FIXME: We should investigate and fix this in the source. export LDFLAGS='-Wl,-z,relro' # Some of the default CXXFLAGS aren't supported by hcc. export CXXFLAGS="-O2 -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables" export CFLAGS="-O2 -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables" export PATH=$PATH:`pwd`/compiler/bin # FXIME: Dont use %%cmake macro, because it will reset the default CXXFLAGS # which have options that hcc doesn't support. cmake .. \ -DCMAKE_INSTALL_PREFIX=%{buildroot}/usr \ -DCMAKE_BUILD_TYPE=RELWITHDEBINFO \ -DLLVM_DIR=%{_builddir}/llvm-rocm-%{rocm_version}/build/lib64/cmake/llvm \ -DHCC_INTEGRATE_ROCDL=ON \ -DBUILD_SHARED_LIBS=ON \ -DCMAKE_CXX_COMPILER=`pwd`/../../llvm-rocm-%{rocm_version}/build/bin/hcc make %{?_smp_mflags} hcc-config mcwamp_hsa mcwamp rocdl %install mkdir -p %{buildroot}%{_libexecdir}/hcc mkdir -p %{buildroot}%{_libexecdir}/hcc/bin mkdir -p %{buildroot}%{_libexecdir}/hcc/%{build_libdir} cd build export PATH=$PATH:`pwd`/compiler/bin 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/compiler,%{_libexecdir}/hcc}/bin/$f done # 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 cd ../../llvm-rocm-%{rocm_version}/build install -m 0755 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 bin/$f %{buildroot}%{_libexecdir}/hcc/bin/ done # Install internal headers for hcc mkdir -p %{buildroot}%{_libexecdir}/hcc/hcc-resource-dir/ # How to install directories with install ? mv %{build_libdir}/clang/ %{buildroot}%{_libexecdir}/hcc/%{build_libdir} install -m 0644 %{build_libdir}/LLVMWrapperGen.so %{buildroot}%{_libexecdir}/hcc/bin install -m 0644 %{build_libdir}/LLVMDirectFuncCall.so %{buildroot}%{_libexecdir}/hcc/bin install -m 0644 %{build_libdir}/LLVMEraseNonkernel.so %{buildroot}%{_libexecdir}/hcc/bin install -m 0644 %{build_libdir}/LLVMTileUniform.so %{buildroot}%{_libexecdir}/hcc/bin install -m 0644 %{build_libdir}/libLLVM-5.0-rocm.so %{buildroot}%{_libexecdir}/hcc/%{build_libdir} find %{_builddir}/llvm-rocm-%{rocm_version} -name "*.a" -type f -delete %files %doc README.md %license LICENSE.TXT %{_libexecdir}/hcc/ %{_bindir}/hcc %{_bindir}/hcc-config %{_bindir}/clamp-config %{_bindir}/extractkernel %{_includedir}/* %{_libdir}/cmake/hcc/ %files -n rocm-device-libs %{_datadir}/rocm/ %files runtime %{_libdir}/libhc_am.so %{_libdir}/libmcwamp_hsa.so %{_libdir}/libmcwamp.so %{_libdir}/libmcwamp_cpu.so %{_libdir}/libmcwamp_atomic.so %changelog * 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. * 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