blob: 76553f4b529c45957a846a86594c0142f9f32b18 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
PYTHON_COMPAT=( python3_{13..14} )
ROCM_SKIP_GLOBALS=1
inherit cmake dot-a linux-info python-r1 rocm toolchain-funcs
ESMI_PN=esmi_pkg_ver
ESMI_PV=5.2.1.1
DESCRIPTION="AMD System Management Interface for managing and monitoring GPUs"
HOMEPAGE="
https://github.com/ROCm/rocm-systems/tree/develop/projects/amdsmi
https://rocm.docs.amd.com/projects/amdsmi/en/latest/
"
SRC_URI="
https://github.com/ROCm/rocm-systems/releases/download/therock-${PV%.0}/${PN}.tar.gz -> ${P}.tar.gz
https://github.com/amd/esmi_ib_library/archive/refs/tags/${ESMI_PN}-${ESMI_PV}.tar.gz
-> esmi_ib_library-${ESMI_PV}.tar.gz
"
S="${WORKDIR}/${PN}"
ESMI_S="${WORKDIR}/esmi_ib_library-${ESMI_PN}-${ESMI_PV}"
LICENSE="MIT"
SLOT="0/$(ver_cut 1-2)"
KEYWORDS="~amd64"
IUSE="test"
RESTRICT="!test? ( test )"
REQUIRED_USE="${PYTHON_REQUIRED_USE}"
RDEPEND="
${PYTHON_DEPS}
dev-libs/libnl:3
net-libs/libmnl
x11-libs/libdrm[video_cards_amdgpu]
"
DEPEND="
${RDEPEND}
dev-libs/rocm-core:${SLOT}
test? ( dev-cpp/gtest )
"
CONFIG_CHECK="~HSA_AMD ~DRM_AMDGPU"
src_prepare() {
ln -s "${ESMI_S}" esmi_ib_library || die
# Compatibility with CMake < 3.10 will be removed
sed -e "/cmake_minimum_required/ s/3\.5\.0/3.10/" \
-i goamdsmi_shim/CMakeLists.txt "${ESMI_S}"/CMakeLists.txt || die
sed -e "s/-Wall -Wextra//" \
-i CMakeLists.txt "${ESMI_S}"/CMakeLists.txt goamdsmi_shim/CMakeLists.txt || die
# Bug: https://bugs.gentoo.org/984514
sed -e "/check_cxx_compiler_flag/!s/ -Werror\(=[a-z-]*\)\?//g" \
-i CMakeLists.txt cmake_modules/help_package.cmake \
src/nic/ai-nic/amdsmi_unified/CMakeLists.txt || die
# Bug: https://bugs.gentoo.org/984513
sed -e "s/COMMAND objdump/COMMAND $(tc-getOBJDUMP)/" -i CMakeLists.txt || die
# Reset custom installation path
sed -e "/generic_add_rocm/d" -i CMakeLists.txt || die
# Install docs to correct place
sed -e "s:doc/\${CPACK_PACKAGE_NAME}:doc/${P}:" -i CMakeLists.txt || die
# Do not install /usr/share/doc/${P}-asan
sed -e "s/COMPONENT asan/COMPONENT asan EXCLUDE_FROM_ALL/" -i CMakeLists.txt || die
# libc++ does not include <cstdlib> transitively
sed -e "/#include <cstring>/i #include <cstdlib>" -i rocm_smi/src/rocm_smi_binary_parser.cc || die
cmake_src_prepare
}
src_configure() {
python_setup
# Bug: https://bugs.gentoo.org/984518
lto-guarantee-fat
local mycmakeargs=(
-DBUILD_TESTS=$(usex test)
-Wno-dev
)
use test && mycmakeargs+=( -DCMAKE_REQUIRE_FIND_PACKAGE_GTest=ON )
cmake_src_configure
}
src_test() {
# Bug: https://bugs.gentoo.org/984527
if [[ -c /dev/kfd ]]; then
check_amdgpu
else
ewarn "/dev/kfd is missing, skipping functional tests"
local -x GTEST_FILTER="*Unit.*"
fi
"${BUILD_DIR}/tests/amd_smi_test/amdsmitst" || die "Test failed"
}
src_install() {
cmake_src_install
strip-lto-bytecode
# Reinstalled below with python_domodule
rm -r "${D}$(python_get_sitedir)"/amdsmi "${ED}"/usr/bin/amd-smi || die
python_fix_shebang "${ED}"/usr/libexec/amdsmi_cli
python_domodule "${ED}"/usr/libexec/amdsmi_cli
python_domodule "${ED}"/usr/share/amd_smi/amdsmi
fperms a+x "/usr/lib/${EPYTHON}/site-packages/amdsmi_cli/amdsmi_cli.py"
dosym -r "/usr/lib/${EPYTHON}/site-packages/amdsmi_cli/amdsmi_cli.py" /usr/bin/amd-smi
rm -rf "${ED}"/usr/share/amd_smi "${ED}"/usr/libexec/amdsmi_cli || die
}
|