File rocclr.spec of Package rocclr
# ROCclr loads comgr at run time by soversion, so this needs to be checked when
# updating this package as it's used for the comgr requires for opencl and hip:
%global comgr_maj_api_ver 2
# See the file "rocclr/device/comgrctx.cpp" for reference:
# https://github.com/ROCm-Developer-Tools/ROCclr/blob/develop/device/comgrctx.cpp#L62
%global rocm_major 6
%global rocm_minor 2
%global rocm_patch 0
%global rocm_release %{rocm_major}.%{rocm_minor}
%global rocm_version %{rocm_release}.%{rocm_patch}
%global upstreamname clr
%define build_flags $(echo %{optflags} | sed 's/-flto=auto//')
%define linker_flags %{?build_ldflags} -Wl,--as-needed -Wl,--no-undefined
%define module_linker_flags %{?build_ldflags} -Wl,--as-needed
%define __builder ninja
%define cmake_opts \\\
-DCMAKE_C_FLAGS="%{build_flags}" \\\
-DCMAKE_CXX_FLAGS="%{build_flags}" \\\
-DCMAKE_EXE_LINKER_FLAGS="%linker_flags" \\\
-DCMAKE_MODULE_LINKER_FLAGS="%module_linker_flags" \\\
-DCMAKE_SHARED_LINKER_FLAGS="%linker_flags -Wl,-z,noexecstack"
%bcond_with debug
%if %{with debug}
%global build_type DEBUG
%else
%global build_type RelWithDebInfo
%endif
Name: rocclr
Version: %{rocm_version}
Release: 0
Summary: ROCm Compute Language Runtime
Url: https://github.com/ROCm/clr
License: MIT
Source0: %{url}/archive/refs/tags/rocm-%{version}.tar.gz#/%{upstreamname}-rocm-%{version}.tar.gz
# TODO: it would be nice to separate this into its own package:
Source1: https://github.com/ROCm/HIP/archive/refs/tags/rocm-%{version}.tar.gz#/HIP-rocm-%{version}.tar.gz
Patch0: rocclr-hipamd-cmake.patch
Patch1: rocclr-disable-gcc15-asserts.patch
# a fix for building blender
Patch8: rocclr-add-long-variants-for-__ffsll.patch
# https://github.com/ROCm/clr/pull/69
Patch9: rocclr-check-p2p_agents_list_-before-deleting.patch
# HIP patch
Patch10: hip-use-env-in-FindHIP.patch
BuildRequires: cmake
BuildRequires: ninja
# Skip building docs
# BuildRequires: doxygen
BuildRequires: fdupes
BuildRequires: hipcc
BuildRequires: libffi-devel
BuildRequires: perl-base
BuildRequires: pkgconfig(gl)
BuildRequires: pkgconfig(numa)
BuildRequires: pkgconfig(ocl-icd)
BuildRequires: python311-CppHeaderParser
BuildRequires: cmake(COMgr-ROCm) = %{rocm_release}
BuildRequires: cmake(LLVM-ROCm) = %{rocm_release}
BuildRequires: cmake(Clang-ROCm) = %{rocm_release}
BuildRequires: rocm-llvm-rpm-macros
BuildRequires: rocm-release(rocm-runtime-devel) = %{rocm_release}
BuildRequires: pkgconfig(libedit)
BuildRequires: pkgconfig(zlib)
%if 0%{?sle_version} == 150600
BuildRequires: gcc12-c++
BuildRequires: libstdc++6-devel-gcc12
%else
BuildRequires: libstdc++-devel
%endif
# ROCclr relise on some x86 intrinsics
# 32bit userspace is excluded as it likely doesn't work and is not very useful
ExclusiveArch: x86_64
# rocclr bundles OpenCL 2.2 headers
# Some work is needed to unbundle this, as it fails to compile with latest
Provides: bundled(opencl-headers) = 2.2
%description
ROCm Compute Language Runtime
%package -n rocm-opencl
Summary: ROCm OpenCL platform and device tool
Requires: ocl-icd%{?_isa}
Provides: rocm-release(opencl) = %{rocm_release}
%description -n rocm-opencl
ROCm OpenCL language runtime.
Supports offline and in-process/in-memory compilation.
%package -n rocm-opencl-devel
Summary: ROCm OpenCL development package
Requires: rocm-opencl%{?_isa} = %{version}-%{release}
Requires: ocl-icd-devel%{?_isa}
Provides: rocm-release(opencl-devel) = %{rocm_release}
Requires: cmake(COMgr-ROCm) = %{rocm_release}
%description -n rocm-opencl-devel
The AMD ROCm OpenCL development package.
%package -n rocm-clinfo
Summary: ROCm OpenCL platform and device tool
%description -n rocm-clinfo
A simple ROCm OpenCL application that enumerates all possible platform and
device information.
%package -n rocm-hip
Summary: ROCm HIP platform and device tool
Provides: hip = %{version}-%{release}
Provides: rocm-release(hip) = %{rocm_release}
%description -n rocm-hip
HIP is a C++ Runtime API and Kernel Language that allows developers to create
portable applications for AMD and NVIDIA GPUs from the same source code.
%package -n rocm-hip-devel
Summary: ROCm HIP development package
Requires: rocm-hip%{?_isa} = %{version}-%{release}
Requires: cmake(COMgr-ROCm) = %{rocm_release}
Requires: rocm-release(rocm-runtime-devel) = %{rocm_release}
Requires: hipcc
Provides: hip-devel = %{version}-%{release}
Provides: rocm-release(hip-devel) = %{rocm_release}
%description -n rocm-hip-devel
ROCm HIP development package.
%package -n hip-doc
Summary: HIP API documentation package
BuildArch: noarch
%description -n hip-doc
This package contains documentation for the hip package
%prep
%autosetup -N -a 1 -n %{upstreamname}-rocm-%{version}
# ROCclr patches
%autopatch -M 9 -p1
# Enable experimental pre vega platforms
sed -i 's/\(ROC_ENABLE_PRE_VEGA.*\)false/\1true/' rocclr/utils/flags.hpp
# Disable RPATH
# https://github.com/ROCm-Developer-Tools/hipamd/issues/22
sed -i '/INSTALL_RPATH/d' \
opencl/tools/clinfo/CMakeLists.txt hipamd/CMakeLists.txt
# Upstream doesn't want OpenCL sonames because they don't guarantee API/ABI.
# For Fedora, SOVERSION can be major.minor (i.e. rocm_release) as rocm patch
# releases are very unlikely to break anything:
echo "set_target_properties(amdocl PROPERTIES VERSION %{version} SOVERSION %rocm_release)" \
>> opencl/amdocl/CMakeLists.txt
echo "libamdocl64.so.%{rocm_release}" > opencl/config/amdocl64.icd
echo "set_target_properties(cltrace PROPERTIES VERSION %{version} SOVERSION %rocm_release)" \
>> opencl/tools/cltrace/CMakeLists.txt
# Clean up unused bundled code
# Only keep opencl2.2 headers as are they needed for now:
ls -d opencl/khronos/* | grep -v headers | xargs rm -r
ls -d opencl/khronos/headers/* | grep -v opencl2.2 | xargs rm -r
# Unused opencl 2.2 test code:
rm -r opencl/khronos/headers/opencl2.2/tests/
# Don't change default C FLAGS and CXX FLAGS:
sed -i '/CMAKE_C.*_FLAGS/d' hipamd/src/CMakeLists.txt
# Stop cmake from trying to install HIPCC again:
sed -i "/install(PROGRAMS.*{[Hh][Ii][Pp][Cc]/d" hipamd/CMakeLists.txt
pushd HIP-rocm-%{version}
# HIP patches
%autopatch -m 10 -p1
# Disable doxygen timestamps:
sed -i 's/^\(HTML_TIMESTAMP.*\)YES/\1NO/' \
docs/doxygen-input/doxy.cfg
popd
sed -i -e 's@\(\$LLVM_DIR/bin/\)\([^[:space:]]*\)@\1\2-%{rocmllvm_major}@' hipamd/src/hip_embed_pch.sh
%build
export PATH=%rocmllvm_prefix/bin:$PATH
%cmake \
-DHIP_COMMON_DIR=$(realpath ../HIP-rocm-%{version}) \
-DCMAKE_INSTALL_LIBDIR=%{_lib} \
-DHIPCC_BIN_DIR=%{_bindir} \
-DHIP_PLATFORM=amd \
-DROCM_PATH=%rocmllvm_prefix \
-DBUILD_ICD=OFF \
-DCLR_BUILD_HIP=ON \
-DCLR_BUILD_OCL=ON \
-DFILE_REORG_BACKWARD_COMPATIBILITY=OFF \
-DHIP_ENABLE_ROCPROFILER_REGISTER=OFF \
-DCMAKE_BUILD_TYPE=%build_type \
-DPython3_EXECUTABLE=$(which python3.11) \
%rocmllvm_cmake_opts \
%cmake_opts
%cmake_build
%install
%cmake_install
# Install OpenCL ICD configuration:
install -D -m 644 opencl/config/amdocl64.icd \
%{buildroot}%{_sysconfdir}/OpenCL/vendors/amdocl64.icd
# Avoid file conflicts with opencl-headers package:
mkdir -p %{buildroot}%{_includedir}/%{name}
mv %{buildroot}%{_includedir}/CL %{buildroot}%{_includedir}/%{name}/CL
# Avoid file conflicts with clinfo package:
mv %{buildroot}%{_bindir}/clinfo %{buildroot}%{_bindir}/rocm-clinfo
# do not package docs
rm -rf %{buildroot}%{_docdir}
# remove Windows files:
rm -rf %{buildroot}%{_bindir}/*.bat
# TODO send upstream a patch, libhip should be installed with cmake's 'TARGETS'
chmod 755 %{buildroot}%{_libdir}/lib*.so*
%fdupes %{buildroot}%{_includedir}/%{name}
%fdupes %{buildroot}%{_includedir}/hip %{buildroot}%{_includedir}/hip_prof_str.h
%fdupes %{buildroot}%{_libdir}/cmake/hip*
%ldconfig_scriptlets -n rocm-opencl
%ldconfig_scriptlets -n rocm-opencl-devel
%ldconfig_scriptlets -n rocm-hip
%ldconfig_scriptlets -n rocm-hip-devel
%files -n rocm-opencl
%license opencl/LICENSE.txt
%dir %{_sysconfdir}/OpenCL
%dir %{_sysconfdir}/OpenCL/vendors
%config(noreplace) %{_sysconfdir}/OpenCL/vendors/amdocl64.icd
%{_libdir}/libamdocl64.so.%{rocm_major}{,.*}
%{_libdir}/libcltrace.so.%{rocm_major}{,.*}
%files -n rocm-opencl-devel
%{_libdir}/libamdocl64.so
%{_libdir}/libcltrace.so
%{_includedir}/%{name}
%files -n rocm-clinfo
%license opencl/LICENSE.txt
%{_bindir}/rocm-clinfo
%files -n rocm-hip
%license hipamd/LICENSE.txt
%{_libdir}/libamdhip64.so.%{rocm_major}{,.*}
%{_libdir}/libhiprtc.so.%{rocm_major}{,.*}
%{_libdir}/libhiprtc-builtins.so.%{rocm_major}{,.*}
%{_datadir}/hip
%files -n rocm-hip-devel
%{_bindir}/roc-*
%{_libdir}/libamdhip64.so
%{_libdir}/libhiprtc.so
%{_libdir}/libhiprtc-builtins.so
%{_libdir}/cmake/hip*
%{_bindir}/hipdemangleatp
%{_bindir}/hipcc_cmake_linker_helper
%{_includedir}/hip
%{_includedir}/hip_prof_str.h
# Unnecessary file and is not FHS compliant:
%exclude %{_libdir}/.hipInfo
# %%files -n hip-doc
# %%license HIP-rocm-%%{version}/LICENSE.txt
# %%{_docdir}/%%{name}
%changelog