Gentoo Archives: gentoo-commits

From: Thomas Deutschmann <whissi@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-libs/libhugetlbfs/
Date: Wed, 09 Sep 2020 21:43:19
Message-Id: 1599687789.39fc2ebd4d6f9a7f866485735704745e2c1e88a9.whissi@gentoo
1 commit: 39fc2ebd4d6f9a7f866485735704745e2c1e88a9
2 Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
3 AuthorDate: Wed Sep 9 21:31:51 2020 +0000
4 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
5 CommitDate: Wed Sep 9 21:43:09 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=39fc2ebd
7
8 sys-libs/libhugetlbfs: bump to v2.23
9
10 Package-Manager: Portage-3.0.6, Repoman-3.0.1
11 Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>
12
13 sys-libs/libhugetlbfs/Manifest | 1 +
14 sys-libs/libhugetlbfs/libhugetlbfs-2.23.ebuild | 159 +++++++++++++++++++++++++
15 2 files changed, 160 insertions(+)
16
17 diff --git a/sys-libs/libhugetlbfs/Manifest b/sys-libs/libhugetlbfs/Manifest
18 index 64af61835b8..a5167aec9e3 100644
19 --- a/sys-libs/libhugetlbfs/Manifest
20 +++ b/sys-libs/libhugetlbfs/Manifest
21 @@ -1 +1,2 @@
22 DIST libhugetlbfs-2.22.tar.gz 175099 BLAKE2B e67a6a678065b10492d510b733b7c6e2926f4f01dd741d49f6e76cedde002fa81d7dad6a6fd8922443c6aacd527c9b3df35f84b8da7332c04e3fcf8c52e23084 SHA512 7f38f9fa576841f36c7cd5192a9ee3f79b275b7b64d7e2a838a43636489cf88627bdba3a045d6b3302a4a509cf64627972b569b4c2c3c4fe05d5aa4ae1d66fd8
23 +DIST libhugetlbfs-2.23.tar.gz 175459 BLAKE2B f469ff9a65364e9f0e04c11c8010c958855ebd4d50e1dd719576cda7c280586623404304be64a794907a5fb1d97bd9c0620a91d7a2492577e04fa40ff432b4c7 SHA512 fc9a7d59bcda9d3ca9c9e43a3a348f989c9cbdbbb77f21a43a06e71eacd05bbe5a7b2b51e20ae9ea00da9f1c4d1130da529bbfb702e8c9d11cab6efadd3dc168
24
25 diff --git a/sys-libs/libhugetlbfs/libhugetlbfs-2.23.ebuild b/sys-libs/libhugetlbfs/libhugetlbfs-2.23.ebuild
26 new file mode 100644
27 index 00000000000..255bcb160f2
28 --- /dev/null
29 +++ b/sys-libs/libhugetlbfs/libhugetlbfs-2.23.ebuild
30 @@ -0,0 +1,159 @@
31 +# Copyright 1999-2020 Gentoo Authors
32 +# Distributed under the terms of the GNU General Public License v2
33 +
34 +EAPI=7
35 +
36 +PYTHON_COMPAT=( python3_{6,7,8,9} )
37 +
38 +inherit multilib toolchain-funcs python-any-r1
39 +
40 +DESCRIPTION="easy hugepage access"
41 +HOMEPAGE="https://github.com/libhugetlbfs/libhugetlbfs"
42 +SRC_URI="https://github.com/libhugetlbfs/libhugetlbfs/archive/${PV}.tar.gz -> ${P}.tar.gz"
43 +
44 +LICENSE="GPL-2"
45 +SLOT="0"
46 +KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~s390 ~x86"
47 +IUSE="static-libs test"
48 +RESTRICT="!test? ( test )"
49 +
50 +DEPEND="test? ( ${PYTHON_DEPS} )"
51 +
52 +PATCHES=(
53 + "${FILESDIR}"/${PN}-2.6-fixup-testsuite.patch
54 +)
55 +
56 +src_prepare() {
57 + default
58 + sed -i \
59 + -e '/^PREFIX/s:/local::' \
60 + -e '1iBUILDTYPE = NATIVEONLY' \
61 + -e '1iV = 1' \
62 + -e '/gzip.*MANDIR/d' \
63 + -e "/^LIB\(32\)/s:=.*:= $(get_libdir):" \
64 + -e '/^CC\(32\|64\)/s:=.*:= $(CC):' \
65 + -e 's@^\(ARCH\) ?=@\1 =@' \
66 + Makefile || die "sed failed"
67 + if [ "$(get_libdir)" == "lib64" ]; then
68 + sed -i \
69 + -e "/^LIB\(32\)/s:=.*:= lib32:" \
70 + Makefile
71 + fi
72 +
73 + # Tarballs from github don't have the version set.
74 + # https://github.com/libhugetlbfs/libhugetlbfs/issues/7
75 + [[ -f version ]] || echo "${PV}" > version
76 +}
77 +
78 +src_compile() {
79 + tc-export AR
80 + emake CC="$(tc-getCC)" libs tools
81 +}
82 +
83 +src_install() {
84 + default
85 + use static-libs || rm -f "${ED}"/usr/$(get_libdir)/*.a
86 +}
87 +
88 +src_test_alloc_one() {
89 + hugeadm="$1"
90 + sign="$2"
91 + pagesize="$3"
92 + pagecount="$4"
93 + ${hugeadm} \
94 + --pool-pages-max ${pagesize}:${sign}${pagecount} \
95 + && \
96 + ${hugeadm} \
97 + --pool-pages-min ${pagesize}:${sign}${pagecount}
98 + return $?
99 +}
100 +
101 +# die is NOT allowed in this src_test block after the marked point, so that we
102 +# can clean up memory allocation. You'll leak at LEAST 64MiB per run otherwise.
103 +src_test() {
104 + [[ $UID -eq 0 ]] || die "Need FEATURES=-userpriv to run this testsuite"
105 + einfo "Building testsuite"
106 + emake -j1 tests
107 +
108 + local hugeadm='obj/hugeadm'
109 + local allocated=''
110 + local rc=0
111 + # the testcases need 64MiB per pagesize.
112 + local MIN_HUGEPAGE_RAM=$((64*1024*1024))
113 +
114 + einfo "Planning allocation"
115 + local PAGESIZES="$(${hugeadm} --page-sizes-all)"
116 +
117 + # Need to do this before we can create the mountpoints.
118 + local pagesize pagecount
119 + for pagesize in ${PAGESIZES} ; do
120 + # The kernel depends on the location :-(
121 + mkdir -p /var/lib/hugetlbfs/pagesize-${pagesize}
122 + addwrite /var/lib/hugetlbfs/pagesize-${pagesize}
123 + done
124 + addwrite /proc/sys/vm/
125 + addwrite /proc/sys/kernel/shmall
126 + addwrite /proc/sys/kernel/shmmax
127 + addwrite /proc/sys/kernel/shmmni
128 +
129 + einfo "Checking HugeTLB mountpoints"
130 + ${hugeadm} --create-mounts || die "Failed to set up hugetlb mountpoints."
131 +
132 + # -----------------------------------------------------
133 + # --------- die is unsafe after this point. -----------
134 + # -----------------------------------------------------
135 +
136 + einfo "Starting allocation"
137 + for pagesize in ${PAGESIZES} ; do
138 + pagecount=$((${MIN_HUGEPAGE_RAM}/${pagesize}))
139 + einfo " ${pagecount} @ ${pagesize}"
140 + addwrite /var/lib/hugetlbfs/pagesize-${pagesize}
141 + src_test_alloc_one "${hugeadm}" "+" "${pagesize}" "${pagecount}"
142 + rc=$?
143 + if [[ ${rc} -eq 0 ]]; then
144 + allocated="${allocated} ${pagesize}:${pagecount}"
145 + else
146 + eerror "Failed to add ${pagecount} pages of size ${pagesize}"
147 + fi
148 + done
149 +
150 + einfo "Allocation status"
151 + ${hugeadm} --pool-list
152 +
153 + if [[ -n "${allocated}" ]]; then
154 + # All our allocations worked, so time to run.
155 + einfo "Starting tests"
156 + cd "${S}"/tests || die
157 + local TESTOPTS="-t func"
158 + case ${ARCH} in
159 + amd64|ppc64)
160 + TESTOPTS="${TESTOPTS} -b 64"
161 + ;;
162 + x86)
163 + TESTOPTS="${TESTOPTS} -b 32"
164 + ;;
165 + esac
166 + # This needs a bit of work to give a nice exit code still.
167 + ./run_tests.py ${TESTOPTS}
168 + rc=$?
169 + else
170 + eerror "Failed to make HugeTLB allocations."
171 + rc=1
172 + fi
173 +
174 + einfo "Cleaning up memory"
175 + cd "${S}" || die
176 + # Cleanup memory allocation
177 + for alloc in ${allocated} ; do
178 + pagesize="${alloc/:*}"
179 + pagecount="${alloc/*:}"
180 + einfo " ${pagecount} @ ${pagesize}"
181 + src_test_alloc_one "$hugeadm" "-" "${pagesize}" "${pagecount}"
182 + done
183 +
184 + # ---------------------------------------------------------
185 + # --------- die is safe again after this point. -----------
186 + # ---------------------------------------------------------
187 +
188 + return ${rc}
189 +}