Gentoo Archives: gentoo-commits

From: Mike Frysinger <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-libs/libhugetlbfs/, sys-libs/libhugetlbfs/files/
Date: Mon, 14 Dec 2015 19:26:11
Message-Id: 1450121140.8f3aa6dadf4c787c54fabb212d7079c9fa5327a8.vapier@gentoo
1 commit: 8f3aa6dadf4c787c54fabb212d7079c9fa5327a8
2 Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
3 AuthorDate: Mon Dec 14 19:24:44 2015 +0000
4 Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
5 CommitDate: Mon Dec 14 19:25:40 2015 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8f3aa6da
7
8 sys-libs/libhugetlbfs: version bump to 2.20
9
10 sys-libs/libhugetlbfs/Manifest | 1 +
11 .../files/libhugetlbfs-2.20-noexec-stack.patch | 135 +++++++++++++++++
12 sys-libs/libhugetlbfs/libhugetlbfs-2.20.ebuild | 167 +++++++++++++++++++++
13 3 files changed, 303 insertions(+)
14
15 diff --git a/sys-libs/libhugetlbfs/Manifest b/sys-libs/libhugetlbfs/Manifest
16 index 5a7e936..e91b029 100644
17 --- a/sys-libs/libhugetlbfs/Manifest
18 +++ b/sys-libs/libhugetlbfs/Manifest
19 @@ -1,2 +1,3 @@
20 DIST libhugetlbfs-2.18.tar.gz 181275 SHA256 8c6ed5e884988e0c879a3705455ece153cf805f69cb9c710334e2711acbb6a06 SHA512 6dcdbf571d6a723a40c15e10b24533f16d65f67fe149aa2d25bee48a034d003419d4cf4b6e55fcd385e1214fc4f6b4dda72ba429b9eea9b38be9b1a393528746 WHIRLPOOL da0b17ca4d2a61be919ea47733b3da485714ce29cdc5e854e143ef0e9c0e45517a37649cb056eeeb74efe8c538f566267152aaad5d53ff837a3a15a9e11070cd
21 DIST libhugetlbfs-2.19.tar.gz 181504 SHA256 a5ecb6e925ab2e491bcaa4049fbd6484740950da47d474e7af06dfc6bd1f690b SHA512 d21781fe68736eb3bbafeb8f36f4f34d30f290f2f6744b52c1a40161caf2e28b823cd8e9b9c74ec4e6d11f7d398d909f80eb736cc39a64ecc7bf571018bfec7c WHIRLPOOL bd76e6334acd11e55dec790170781aa418a74e4b1bd0007a15c0b65f5c0f4fd977d02eb89d6b16d48b4e4c7fd980ed2bd7ac9a8246179c0480874afe901da851
22 +DIST libhugetlbfs-2.20.tar.gz 186750 SHA256 feb51a17456e6ec9806e78720d4ae17a1211a5db8c9bb4ae654b7251a3f76166 SHA512 817fca3f8e3b127b9b877e0a03d0a94bf0c3ec481d3becf995986ce6ae0532629c5460100eb9f2ef3452ed59a3b9d3ac8362df8f87b387803c36d35ab7af0902 WHIRLPOOL e6c0244d47cee5966f1a51d7f39ea1cd0f26a7b1698b4471c6813ed9b2f194bc72d4087f62f72f5c2e5d99fcf00226b72b783a993ec39016625106f8ed17baca
23
24 diff --git a/sys-libs/libhugetlbfs/files/libhugetlbfs-2.20-noexec-stack.patch b/sys-libs/libhugetlbfs/files/libhugetlbfs-2.20-noexec-stack.patch
25 new file mode 100644
26 index 0000000..04c8bae
27 --- /dev/null
28 +++ b/sys-libs/libhugetlbfs/files/libhugetlbfs-2.20-noexec-stack.patch
29 @@ -0,0 +1,135 @@
30 +https://github.com/libhugetlbfs/libhugetlbfs/pull/9
31 +
32 +From 1c41d751d57a598919c40ab9c27514a98da93273 Mon Sep 17 00:00:00 2001
33 +From: "Robin H. Johnson" <robbat2@g.o>
34 +Date: Sat, 31 Oct 2009 07:59:57 +0000
35 +Subject: [PATCH] set noexec markers in the asm file directly
36 +
37 +Using -Wl,-z,noexecstack can hide real exec stack issues coming from other
38 +files, and is a bit unportable. Instead, set proper section markers in the
39 +assembly files directly. It also means people using the static libraries
40 +won't have to use -Wl,-z,noexecstack when they link their code.
41 +---
42 + Makefile | 2 +-
43 + sys-aarch64elf.S | 4 ++++
44 + sys-armelf_linux_eabi.S | 4 ++++
45 + sys-elf32ppclinux.S | 4 ++++
46 + sys-elf64_s390.S | 4 ++++
47 + sys-elf64ppc.S | 4 ++++
48 + sys-elf_i386.S | 4 ++++
49 + sys-elf_s390.S | 4 ++++
50 + sys-elf_x86_64.S | 4 ++++
51 + 9 files changed, 33 insertions(+), 1 deletion(-)
52 +
53 +diff --git a/Makefile b/Makefile
54 +index 73ebad7..ca987d9 100644
55 +--- a/Makefile
56 ++++ b/Makefile
57 +@@ -27,7 +27,7 @@ NODEPTARGETS=<version.h> <clean>
58 +
59 + INSTALL = install
60 +
61 +-LDFLAGS += -Wl,-z,noexecstack -ldl
62 ++LDFLAGS += -ldl
63 + CFLAGS ?= -O2 -g
64 + CFLAGS += -Wall -fPIC
65 + CPPFLAGS += -D__LIBHUGETLBFS__
66 +diff --git a/sys-aarch64elf.S b/sys-aarch64elf.S
67 +index 54799d3..210558b 100644
68 +--- a/sys-aarch64elf.S
69 ++++ b/sys-aarch64elf.S
70 +@@ -32,3 +32,7 @@ direct_syscall:
71 + mov x6, x7
72 + svc 0x0
73 + ret
74 ++
75 ++#if defined(__linux__) && defined(__ELF__)
76 ++ .section .note.GNU-stack,"",%progbits
77 ++#endif
78 +diff --git a/sys-armelf_linux_eabi.S b/sys-armelf_linux_eabi.S
79 +index dfa7407..265b75d 100644
80 +--- a/sys-armelf_linux_eabi.S
81 ++++ b/sys-armelf_linux_eabi.S
82 +@@ -31,3 +31,7 @@ direct_syscall:
83 + swi 0x0
84 + ldmfd sp!, {r4, r5, r6, r7}
85 + bx lr
86 ++
87 ++#if defined(__linux__) && defined(__ELF__)
88 ++ .section .note.GNU-stack,"",%progbits
89 ++#endif
90 +diff --git a/sys-elf32ppclinux.S b/sys-elf32ppclinux.S
91 +index 65d8b3f..6ba3f22 100644
92 +--- a/sys-elf32ppclinux.S
93 ++++ b/sys-elf32ppclinux.S
94 +@@ -32,3 +32,7 @@ direct_syscall:
95 + mr 8,9
96 + sc
97 + blr
98 ++
99 ++#if defined(__linux__) && defined(__ELF__)
100 ++ .section .note.GNU-stack,"",%progbits
101 ++#endif
102 +diff --git a/sys-elf64_s390.S b/sys-elf64_s390.S
103 +index 425a387..5c31899 100644
104 +--- a/sys-elf64_s390.S
105 ++++ b/sys-elf64_s390.S
106 +@@ -20,3 +20,7 @@ direct_syscall:
107 + lgr %r5,%r6
108 + svc 0
109 + br %r14
110 ++
111 ++#if defined(__linux__) && defined(__ELF__)
112 ++ .section .note.GNU-stack,"",%progbits
113 ++#endif
114 +diff --git a/sys-elf64ppc.S b/sys-elf64ppc.S
115 +index d50f4a6..b57a345 100644
116 +--- a/sys-elf64ppc.S
117 ++++ b/sys-elf64ppc.S
118 +@@ -46,3 +46,7 @@ direct_syscall:
119 + mr 8,9
120 + sc
121 + blr
122 ++
123 ++#if defined(__linux__) && defined(__ELF__)
124 ++ .section .note.GNU-stack,"",%progbits
125 ++#endif
126 +diff --git a/sys-elf_i386.S b/sys-elf_i386.S
127 +index ab30c8d..6182b3d 100644
128 +--- a/sys-elf_i386.S
129 ++++ b/sys-elf_i386.S
130 +@@ -40,3 +40,7 @@ direct_syscall:
131 + pop %edi
132 + pop %ebp
133 + ret
134 ++
135 ++#if defined(__linux__) && defined(__ELF__)
136 ++ .section .note.GNU-stack,"",%progbits
137 ++#endif
138 +diff --git a/sys-elf_s390.S b/sys-elf_s390.S
139 +index 40630d1..e6a9a96 100644
140 +--- a/sys-elf_s390.S
141 ++++ b/sys-elf_s390.S
142 +@@ -20,3 +20,7 @@ direct_syscall:
143 + lr %r5,%r6
144 + svc 0
145 + br %r14
146 ++
147 ++#if defined(__linux__) && defined(__ELF__)
148 ++ .section .note.GNU-stack,"",%progbits
149 ++#endif
150 +diff --git a/sys-elf_x86_64.S b/sys-elf_x86_64.S
151 +index 6af06ad..561f49b 100644
152 +--- a/sys-elf_x86_64.S
153 ++++ b/sys-elf_x86_64.S
154 +@@ -32,3 +32,7 @@ direct_syscall:
155 + mov 0x8(%rsp),%r9
156 + syscall
157 + retq
158 ++
159 ++#if defined(__linux__) && defined(__ELF__)
160 ++ .section .note.GNU-stack,"",%progbits
161 ++#endif
162 +--
163 +2.6.2
164 +
165
166 diff --git a/sys-libs/libhugetlbfs/libhugetlbfs-2.20.ebuild b/sys-libs/libhugetlbfs/libhugetlbfs-2.20.ebuild
167 new file mode 100644
168 index 0000000..3f61f83
169 --- /dev/null
170 +++ b/sys-libs/libhugetlbfs/libhugetlbfs-2.20.ebuild
171 @@ -0,0 +1,167 @@
172 +# Copyright 1999-2015 Gentoo Foundation
173 +# Distributed under the terms of the GNU General Public License v2
174 +# $Id$
175 +
176 +EAPI="5"
177 +
178 +PYTHON_COMPAT=( python2_7 )
179 +
180 +inherit eutils multilib toolchain-funcs perl-functions python-any-r1
181 +
182 +DESCRIPTION="easy hugepage access"
183 +HOMEPAGE="https://github.com/libhugetlbfs/libhugetlbfs"
184 +SRC_URI="https://github.com/libhugetlbfs/libhugetlbfs/archive/${PV}.tar.gz -> ${P}.tar.gz"
185 +
186 +LICENSE="GPL-2"
187 +SLOT="0"
188 +KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~s390 ~x86"
189 +IUSE="perl static-libs test"
190 +
191 +DEPEND="test? ( ${PYTHON_DEPS} )"
192 +RDEPEND="perl? ( dev-lang/perl:= )"
193 +
194 +src_prepare() {
195 + perl_set_version
196 +
197 + epatch "${FILESDIR}"/${PN}-2.9-build.patch #332517
198 + epatch "${FILESDIR}"/${PN}-2.20-noexec-stack.patch
199 + epatch "${FILESDIR}"/${PN}-2.6-fixup-testsuite.patch
200 + sed -i \
201 + -e '/^PREFIX/s:/local::' \
202 + -e '1iBUILDTYPE = NATIVEONLY' \
203 + -e '1iV = 1' \
204 + -e '/gzip.*MANDIR/d' \
205 + -e "/^LIB\(32\)/s:=.*:= $(get_libdir):" \
206 + -e '/^CC\(32\|64\)/s:=.*:= $(CC):' \
207 + -e "/^PMDIR = .*\/perl5\/TLBC/s::PMDIR = ${VENDOR_LIB}\/TLBC:" \
208 + Makefile || die "sed failed"
209 + if [ "$(get_libdir)" == "lib64" ]; then
210 + sed -i \
211 + -e "/^LIB\(32\)/s:=.*:= lib32:" \
212 + Makefile
213 + fi
214 +
215 + # Tarballs from github don't have the version set.
216 + # https://github.com/libhugetlbfs/libhugetlbfs/issues/7
217 + [[ -f version ]] || echo "${PV}" > version
218 +}
219 +
220 +src_compile() {
221 + tc-export AR
222 + emake CC="$(tc-getCC)" libs tools
223 +}
224 +
225 +src_install() {
226 + default
227 + use static-libs || rm -f "${ED}"/usr/$(get_libdir)/*.a
228 + rm "${ED}"/usr/bin/oprofile* || die
229 + if ! use perl ; then
230 + rm -r \
231 + "${ED}"/usr/bin/cpupcstat \
232 + "${ED}"/usr/share/man/man8/cpupcstat.8 \
233 + "${ED}/${VENDOR_LIB}" \
234 + || die
235 + fi
236 +}
237 +
238 +src_test_alloc_one() {
239 + hugeadm="$1"
240 + sign="$2"
241 + pagesize="$3"
242 + pagecount="$4"
243 + ${hugeadm} \
244 + --pool-pages-max ${pagesize}:${sign}${pagecount} \
245 + && \
246 + ${hugeadm} \
247 + --pool-pages-min ${pagesize}:${sign}${pagecount}
248 + return $?
249 +}
250 +
251 +# die is NOT allowed in this src_test block after the marked point, so that we
252 +# can clean up memory allocation. You'll leak at LEAST 64MiB per run otherwise.
253 +src_test() {
254 + [[ $UID -eq 0 ]] || die "Need FEATURES=-userpriv to run this testsuite"
255 + einfo "Building testsuite"
256 + emake -j1 tests || die "Failed to build tests"
257 +
258 + hugeadm='obj/hugeadm'
259 + allocated=''
260 + rc=0
261 + # the testcases need 64MiB per pagesize.
262 + MIN_HUGEPAGE_RAM=$((64*1024*1024))
263 +
264 + einfo "Planning allocation"
265 + PAGESIZES="$(${hugeadm} --page-sizes-all)"
266 +
267 + # Need to do this before we can create the mountpoints.
268 + for pagesize in ${PAGESIZES} ; do
269 + # The kernel depends on the location :-(
270 + mkdir -p /var/lib/hugetlbfs/pagesize-${pagesize}
271 + addwrite /var/lib/hugetlbfs/pagesize-${pagesize}
272 + done
273 + addwrite /proc/sys/vm/
274 + addwrite /proc/sys/kernel/shmall
275 + addwrite /proc/sys/kernel/shmmax
276 + addwrite /proc/sys/kernel/shmmni
277 +
278 + einfo "Checking HugeTLB mountpoints"
279 + ${hugeadm} --create-mounts || die "Failed to set up hugetlb mountpoints."
280 +
281 + # -----------------------------------------------------
282 + # --------- die is unsafe after this point. -----------
283 + # -----------------------------------------------------
284 +
285 + einfo "Starting allocation"
286 + for pagesize in ${PAGESIZES} ; do
287 + pagecount=$((${MIN_HUGEPAGE_RAM}/${pagesize}))
288 + einfo " ${pagecount} @ ${pagesize}"
289 + addwrite /var/lib/hugetlbfs/pagesize-${pagesize}
290 + src_test_alloc_one "$hugeadm" "+" "${pagesize}" "${pagecount}"
291 + rc=$?
292 + if [[ $rc -eq 0 ]]; then
293 + allocated="${allocated} ${pagesize}:${pagecount}"
294 + else
295 + eerror "Failed to add ${pagecount} pages of size ${pagesize}"
296 + fi
297 + done
298 +
299 + einfo "Allocation status"
300 + ${hugeadm} --pool-list
301 +
302 + if [[ -n "${allocated}" ]]; then
303 + # All our allocations worked, so time to run.
304 + einfo "Starting tests"
305 + cd "${S}"/tests
306 + TESTOPTS="-t func"
307 + case $ARCH in
308 + amd64|ppc64)
309 + TESTOPTS="${TESTOPTS} -b 64"
310 + ;;
311 + x86)
312 + TESTOPTS="${TESTOPTS} -b 32"
313 + ;;
314 + esac
315 + # This needs a bit of work to give a nice exit code still.
316 + ./run_tests.py ${TESTOPTS}
317 + rc=$?
318 + else
319 + eerror "Failed to make HugeTLB allocations."
320 + rc=1
321 + fi
322 +
323 + einfo "Cleaning up memory"
324 + cd "${S}"
325 + # Cleanup memory allocation
326 + for alloc in ${allocated} ; do
327 + pagesize="${alloc/:*}"
328 + pagecount="${alloc/*:}"
329 + einfo " ${pagecount} @ ${pagesize}"
330 + src_test_alloc_one "$hugeadm" "-" "${pagesize}" "${pagecount}"
331 + done
332 +
333 + # ---------------------------------------------------------
334 + # --------- die is safe again after this point. -----------
335 + # ---------------------------------------------------------
336 +
337 + return $rc
338 +}