Gentoo Archives: gentoo-commits

From: Guilherme Amadio <amadio@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-util/perf/, dev-util/perf/files/
Date: Thu, 07 Apr 2022 10:14:19
Message-Id: 1649326382.877502fec0e8a02f99c27cb69e5fa8ab5bce543e.amadio@gentoo
1 commit: 877502fec0e8a02f99c27cb69e5fa8ab5bce543e
2 Author: Guilherme Amadio <amadio <AT> gentoo <DOT> org>
3 AuthorDate: Thu Apr 7 09:19:55 2022 +0000
4 Commit: Guilherme Amadio <amadio <AT> gentoo <DOT> org>
5 CommitDate: Thu Apr 7 10:13:02 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=877502fe
7
8 dev-util/perf: version bump to 5.17.1
9
10 Package-Manager: Portage-3.0.30, Repoman-3.0.3
11 Signed-off-by: Guilherme Amadio <amadio <AT> gentoo.org>
12
13 dev-util/perf/Manifest | 2 +
14 dev-util/perf/files/perf-5.17.1-clang.patch | 61 +++++++
15 dev-util/perf/perf-5.17.1.ebuild | 264 ++++++++++++++++++++++++++++
16 3 files changed, 327 insertions(+)
17
18 diff --git a/dev-util/perf/Manifest b/dev-util/perf/Manifest
19 index 2b586b7e4171..24040411703d 100644
20 --- a/dev-util/perf/Manifest
21 +++ b/dev-util/perf/Manifest
22 @@ -1,3 +1,5 @@
23 DIST linux-5.12.tar.xz 118112412 BLAKE2B 842d921b9a73d2aaade763dbd2ec67bdfe0275baa6d628b775f5c87574ad7dc86f0419afcd48c10c1235f4bffa16084243f2cf4556e6afcd391e975fe8ba530b SHA512 be03b6fee1d1ea8087b09874d27c0a602c0b04fd90ad38b975bd2c8455a07e83c29b56814aaf1389e82305fae0e4c2d1701075a7f0a7295dd28149f967ec5b3d
24 DIST linux-5.15.tar.xz 121913744 BLAKE2B 3921274b23f7938abdf3ed9334534b4581e13d7484303d3a5280eddb038999aaa8b836666a487472d9c4a219af0f06b9fecccaf348fb5510ab8762f4ef4b7e83 SHA512 d25ad40b5bcd6a4c6042fd0fd84e196e7a58024734c3e9a484fd0d5d54a0c1d87db8a3c784eff55e43b6f021709dc685eb0efa18d2aec327e4f88a79f405705a
25 +DIST linux-5.17.tar.xz 128399340 BLAKE2B 82dc4a45cc25c781ac67aa6ed1e4c369544154960f41c4634d47621f381159687a227054976d078524cda28884d395a15f7542fe44ca74ce98ca6ff54a81d6d0 SHA512 89f0a7ca69d20a539d4b612a7028a30a5e98b402e4b6b88516f14237e5da4b626d7929eab8b40fccc90766e8f3bae87e9858a19077ffad20d8204acf18794f5b
26 DIST linux-5.8.tar.xz 114459324 BLAKE2B 7bd97f8fa4527840754434414c07283e89731dc8ebb1e95fa5bc1469a60af1122582c0d3b6e262e77882f023190068df3537bd8b65964b3caa820bb2c8e579c7 SHA512 45a53ecf351096ef6e98242cca4228b8da9b9139ecc6963695791ea6fb7a9484a4e1c19dcca7ce7cbfdfa49de0451b70973bb078f12bdae9cbaddbc3f8092556
27 +DIST patch-5.17.1.xz 15244 BLAKE2B f340b8a103754122153dd381fe210b18ba37b7262dae4fc7a1f99c5a62868c9bdb178e83865b35f00b82bd2d67ae127c440515d1740093825f7ec7fa4c4a490d SHA512 fb9a28ce7c68daeca82586e7631dc0be00a1a8393b4cef4c659fc1f9dac6e1f941bd60671c0350d1dea9cb035f56d627f64a394a9acb00b2b5dea8a1d44c065f
28
29 diff --git a/dev-util/perf/files/perf-5.17.1-clang.patch b/dev-util/perf/files/perf-5.17.1-clang.patch
30 new file mode 100644
31 index 000000000000..73d4506146c0
32 --- /dev/null
33 +++ b/dev-util/perf/files/perf-5.17.1-clang.patch
34 @@ -0,0 +1,61 @@
35 +
36 +Fix building against LLVM/Clang with monolithic libraries and
37 +adjust header includes for Clang >= 14.
38 +
39 +--- a/tools/build/feature/Makefile
40 ++++ b/tools/build/feature/Makefile
41 +@@ -299,7 +299,7 @@ $(OUTPUT)test-llvm.bin:
42 + $(BUILDXX) -std=gnu++14 \
43 + -I$(shell $(LLVM_CONFIG) --includedir) \
44 + -L$(shell $(LLVM_CONFIG) --libdir) \
45 +- $(shell $(LLVM_CONFIG) --libs Core BPF) \
46 ++ $(shell $(LLVM_CONFIG) --libs) \
47 + $(shell $(LLVM_CONFIG) --system-libs) \
48 + > $(@:.bin=.make.output) 2>&1
49 +
50 +@@ -312,10 +312,7 @@ $(OUTPUT)test-clang.bin:
51 + $(BUILDXX) -std=gnu++14 \
52 + -I$(shell $(LLVM_CONFIG) --includedir) \
53 + -L$(shell $(LLVM_CONFIG) --libdir) \
54 +- -Wl,--start-group -lclangBasic -lclangDriver \
55 +- -lclangFrontend -lclangEdit -lclangLex \
56 +- -lclangAST -Wl,--end-group \
57 +- $(shell $(LLVM_CONFIG) --libs Core option) \
58 ++ -lclang-cpp $(shell $(LLVM_CONFIG) --libs) \
59 + $(shell $(LLVM_CONFIG) --system-libs) \
60 + > $(@:.bin=.make.output) 2>&1
61 +
62 +--- a/tools/perf/Makefile.perf
63 ++++ b/tools/perf/Makefile.perf
64 +@@ -417,14 +417,11 @@ EXTLIBS := $(call filter-out,$(EXCLUDE_EXTLIBS),$(EXTLIBS))
65 + LIBS = -Wl,--whole-archive $(PERFLIBS) $(EXTRA_PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group
66 +
67 + ifeq ($(USE_CLANG), 1)
68 +- CLANGLIBS_LIST = AST Basic CodeGen Driver Frontend Lex Tooling Edit Sema Analysis Parse Serialization
69 +- CLANGLIBS_NOEXT_LIST = $(foreach l,$(CLANGLIBS_LIST),$(shell $(LLVM_CONFIG) --libdir)/libclang$(l))
70 +- LIBCLANG = $(foreach l,$(CLANGLIBS_NOEXT_LIST),$(wildcard $(l).a $(l).so))
71 +- LIBS += -Wl,--start-group $(LIBCLANG) -Wl,--end-group
72 ++ LIBS += -lclang-cpp
73 + endif
74 +
75 + ifeq ($(USE_LLVM), 1)
76 +- LIBLLVM = $(shell $(LLVM_CONFIG) --libs all) $(shell $(LLVM_CONFIG) --system-libs)
77 ++ LIBLLVM = $(shell $(LLVM_CONFIG) --libs) $(shell $(LLVM_CONFIG) --system-libs)
78 + LIBS += -L$(shell $(LLVM_CONFIG) --libdir) $(LIBLLVM)
79 + endif
80 +
81 +--- a/tools/perf/util/c++/clang.cpp
82 ++++ b/tools/perf/util/c++/clang.cpp
83 +@@ -20,7 +20,11 @@
84 + #include "llvm/Option/Option.h"
85 + #include "llvm/Support/FileSystem.h"
86 + #include "llvm/Support/ManagedStatic.h"
87 ++#if CLANG_VERSION_MAJOR >= 14
88 ++#include "llvm/MC/TargetRegistry.h"
89 ++#else
90 + #include "llvm/Support/TargetRegistry.h"
91 ++#endif
92 + #include "llvm/Support/TargetSelect.h"
93 + #include "llvm/Target/TargetMachine.h"
94 + #include "llvm/Target/TargetOptions.h"
95 +
96
97 diff --git a/dev-util/perf/perf-5.17.1.ebuild b/dev-util/perf/perf-5.17.1.ebuild
98 new file mode 100644
99 index 000000000000..042f82100eba
100 --- /dev/null
101 +++ b/dev-util/perf/perf-5.17.1.ebuild
102 @@ -0,0 +1,264 @@
103 +# Copyright 1999-2022 Gentoo Authors
104 +# Distributed under the terms of the GNU General Public License v2
105 +
106 +EAPI=7
107 +
108 +PYTHON_COMPAT=( python3_{8..10} )
109 +inherit bash-completion-r1 estack llvm toolchain-funcs python-r1 linux-info
110 +
111 +DESCRIPTION="Userland tools for Linux Performance Counters"
112 +HOMEPAGE="https://perf.wiki.kernel.org/"
113 +
114 +LINUX_V="${PV:0:1}.x"
115 +if [[ ${PV} == *_rc* ]] ; then
116 + LINUX_VER=$(ver_cut 1-2).$(($(ver_cut 3)-1))
117 + PATCH_VERSION=$(ver_cut 1-3)
118 + LINUX_PATCH=patch-${PV//_/-}.xz
119 + SRC_URI="https://www.kernel.org/pub/linux/kernel/v${LINUX_V}/testing/${LINUX_PATCH}
120 + https://www.kernel.org/pub/linux/kernel/v${LINUX_V}/testing/v${PATCH_VERSION}/${LINUX_PATCH}"
121 +elif [[ ${PV} == *.*.* ]] ; then
122 + # stable-release series
123 + LINUX_VER=$(ver_cut 1-2)
124 + LINUX_PATCH=patch-${PV}.xz
125 + SRC_URI="https://www.kernel.org/pub/linux/kernel/v${LINUX_V}/${LINUX_PATCH}"
126 +else
127 + LINUX_VER=${PV}
128 + SRC_URI=""
129 +fi
130 +
131 +LINUX_SOURCES="linux-${LINUX_VER}.tar.xz"
132 +SRC_URI+=" https://www.kernel.org/pub/linux/kernel/v${LINUX_V}/${LINUX_SOURCES}"
133 +
134 +LICENSE="GPL-2"
135 +SLOT="0"
136 +KEYWORDS="~amd64 ~arm ~arm64 ~mips ~ppc ~ppc64 ~riscv ~x86 ~amd64-linux ~x86-linux"
137 +IUSE="audit babeltrace clang crypt debug +doc gtk java libpfm lzma numa perl python slang systemtap unwind zlib zstd"
138 +
139 +REQUIRED_USE="${PYTHON_REQUIRED_USE}"
140 +
141 +BDEPEND="
142 + ${LINUX_PATCH+dev-util/patchutils}
143 + sys-devel/bison
144 + sys-devel/flex
145 + virtual/pkgconfig
146 + doc? (
147 + app-text/asciidoc
148 + app-text/sgml-common
149 + app-text/xmlto
150 + sys-process/time
151 + )
152 + ${PYTHON_DEPS}
153 +"
154 +
155 +RDEPEND="audit? ( sys-process/audit )
156 + babeltrace? ( dev-util/babeltrace )
157 + crypt? ( virtual/libcrypt:= )
158 + clang? (
159 + sys-devel/clang:=
160 + sys-devel/llvm:=
161 + )
162 + gtk? ( x11-libs/gtk+:2 )
163 + java? ( virtual/jre:* )
164 + libpfm? ( dev-libs/libpfm )
165 + lzma? ( app-arch/xz-utils )
166 + numa? ( sys-process/numactl )
167 + perl? ( dev-lang/perl:= )
168 + python? ( ${PYTHON_DEPS} )
169 + slang? ( sys-libs/slang )
170 + systemtap? ( dev-util/systemtap )
171 + unwind? ( sys-libs/libunwind )
172 + zlib? ( sys-libs/zlib )
173 + zstd? ( app-arch/zstd )
174 + dev-libs/elfutils
175 + sys-libs/binutils-libs:="
176 +
177 +DEPEND="${RDEPEND}
178 + >=sys-kernel/linux-headers-5.10
179 + java? ( virtual/jdk )
180 +"
181 +
182 +S_K="${WORKDIR}/linux-${LINUX_VER}"
183 +S="${S_K}/tools/perf"
184 +
185 +CONFIG_CHECK="~PERF_EVENTS ~KALLSYMS"
186 +
187 +QA_FLAGS_IGNORED=(
188 + usr/bin/perf-read-vdso32 # not linked with anything except for libc
189 + usr/libexec/perf-core/dlfilters/dlfilter-test-api-v0.so # not installed
190 +)
191 +
192 +pkg_pretend() {
193 + if ! use doc ; then
194 + ewarn "Without the doc USE flag you won't get any documentation nor man pages."
195 + ewarn "And without man pages, you won't get any --help output for perf and its"
196 + ewarn "sub-tools."
197 + fi
198 +}
199 +
200 +pkg_setup() {
201 + use clang && llvm_pkg_setup
202 + # We enable python unconditionally as libbpf always generates
203 + # API headers using python script
204 + python_setup
205 +}
206 +
207 +# src_unpack and src_prepare are copied to dev-util/bpftool since
208 +# it's building from the same tarball, please keep it in sync with bpftool
209 +src_unpack() {
210 + local paths=(
211 + tools/arch tools/build tools/include tools/lib tools/perf tools/scripts
212 + scripts include lib "arch/*/lib"
213 + )
214 +
215 + # We expect the tar implementation to support the -j option (both
216 + # GNU tar and libarchive's tar support that).
217 + echo ">>> Unpacking ${LINUX_SOURCES} (${paths[*]}) to ${PWD}"
218 + tar --wildcards -xpf "${DISTDIR}"/${LINUX_SOURCES} \
219 + "${paths[@]/#/linux-${LINUX_VER}/}" || die
220 +
221 + if [[ -n ${LINUX_PATCH} ]] ; then
222 + eshopts_push -o noglob
223 + ebegin "Filtering partial source patch"
224 + filterdiff -p1 ${paths[@]/#/-i } -z "${DISTDIR}"/${LINUX_PATCH} \
225 + > ${P}.patch
226 + eend $? || die "filterdiff failed"
227 + eshopts_pop
228 + fi
229 +
230 + local a
231 + for a in ${A}; do
232 + [[ ${a} == ${LINUX_SOURCES} ]] && continue
233 + [[ ${a} == ${LINUX_PATCH} ]] && continue
234 + unpack ${a}
235 + done
236 +}
237 +
238 +src_prepare() {
239 + default
240 + if [[ -n ${LINUX_PATCH} ]] ; then
241 + pushd "${S_K}" >/dev/null || die
242 + eapply "${WORKDIR}"/${P}.patch
243 + popd || die
244 + fi
245 +
246 + pushd "${S_K}" >/dev/null || die
247 + eapply "${FILESDIR}"/${P}-clang.patch
248 + popd || die
249 +
250 + # Drop some upstream too-developer-oriented flags and fix the
251 + # Makefile in general
252 + sed -i \
253 + -e "s:\$(sysconfdir_SQ)/bash_completion.d:$(get_bashcompdir):" \
254 + "${S}"/Makefile.perf || die
255 + # A few places still use -Werror w/out $(WERROR) protection.
256 + sed -i -e 's:-Werror::' \
257 + "${S}"/Makefile.perf "${S_K}"/tools/lib/bpf/Makefile || die
258 +
259 + # Avoid the call to make kernelversion
260 + sed -i -e '/PERF-VERSION-GEN/d' Makefile.perf || die
261 + echo "#define PERF_VERSION \"${PV}\"" > PERF-VERSION-FILE
262 +
263 + # The code likes to compile local assembly files which lack ELF markings.
264 + find -name '*.S' -exec sed -i '$a.section .note.GNU-stack,"",%progbits' {} +
265 +}
266 +
267 +puse() { usex $1 "" no; }
268 +perf_make() {
269 + # The arch parsing is a bit funky. The perf tools package is integrated
270 + # into the kernel, so it wants an ARCH that looks like the kernel arch,
271 + # but it also wants to know about the split value -- i386/x86_64 vs just
272 + # x86. We can get that by telling the func to use an older linux version.
273 + # It's kind of a hack, but not that bad ...
274 +
275 + # LIBDIR sets a search path of perf-gtk.so. Bug 515954
276 +
277 + local arch=$(tc-arch-kernel)
278 + local java_dir
279 + use java && java_dir="${EPREFIX}/etc/java-config-2/current-system-vm"
280 + # FIXME: NO_CORESIGHT
281 + emake V=1 VF=1 \
282 + HOSTCC="$(tc-getBUILD_CC)" HOSTLD="$(tc-getBUILD_LD)" \
283 + CC="$(tc-getCC)" CXX="$(tc-getCXX)" AR="$(tc-getAR)" LD="$(tc-getLD)" NM="$(tc-getNM)" \
284 + PKG_CONFIG="$(tc-getPKG_CONFIG)" \
285 + prefix="${EPREFIX}/usr" bindir_relative="bin" \
286 + tipdir="share/doc/${PF}" \
287 + EXTRA_CFLAGS="${CFLAGS}" \
288 + EXTRA_LDFLAGS="${LDFLAGS}" \
289 + ARCH="${arch}" \
290 + JDIR="${java_dir}" \
291 + LIBCLANGLLVM=$(usex clang 1 "") \
292 + LIBPFM4=$(usex libpfm 1 "") \
293 + NO_AUXTRACE="" \
294 + NO_BACKTRACE="" \
295 + NO_CORESIGHT=1 \
296 + NO_DEMANGLE= \
297 + GTK2=$(usex gtk 1 "") \
298 + feature-gtk2-infobar=$(usex gtk 1 "") \
299 + NO_JVMTI=$(puse java) \
300 + NO_LIBAUDIT=$(puse audit) \
301 + NO_LIBBABELTRACE=$(puse babeltrace) \
302 + NO_LIBBIONIC=1 \
303 + NO_LIBBPF= \
304 + NO_LIBCRYPTO=$(puse crypt) \
305 + NO_LIBDW_DWARF_UNWIND= \
306 + NO_LIBELF= \
307 + NO_LIBNUMA=$(puse numa) \
308 + NO_LIBPERL=$(puse perl) \
309 + NO_LIBPYTHON=$(puse python) \
310 + NO_LIBUNWIND=$(puse unwind) \
311 + NO_LIBZSTD=$(puse zstd) \
312 + NO_SDT=$(puse systemtap) \
313 + NO_SLANG=$(puse slang) \
314 + NO_LZMA=$(puse lzma) \
315 + NO_ZLIB=$(puse zlib) \
316 + WERROR=0 \
317 + LIBDIR="/usr/libexec/perf-core" \
318 + libdir="${EPREFIX}/usr/$(get_libdir)" \
319 + plugindir="${EPREFIX}/usr/$(get_libdir)/perf/plugins" \
320 + "$@"
321 +}
322 +
323 +src_compile() {
324 + # test-clang.bin not build with g++
325 + if use clang; then
326 + make -C "${S_K}/tools/build/feature" V=1 CXX=${CHOST}-clang++ test-clang.bin || die
327 + fi
328 + perf_make -f Makefile.perf
329 + use doc && perf_make -C Documentation man
330 +}
331 +
332 +src_test() {
333 + :
334 +}
335 +
336 +src_install() {
337 + _install_python_ext() {
338 + perf_make -f Makefile.perf install-python_ext DESTDIR="${D}"
339 + }
340 +
341 + perf_make -f Makefile.perf install DESTDIR="${D}"
342 +
343 + if use python; then
344 + python_foreach_impl _install_python_ext
345 + fi
346 +
347 + if use gtk; then
348 + local libdir
349 + libdir="$(get_libdir)"
350 + # on some arches it ends up in lib even on 64bit, ppc64 for instance.
351 + [[ -f "${ED}"/usr/lib/libperf-gtk.so ]] && libdir="lib"
352 + mv "${ED}"/usr/${libdir}/libperf-gtk.so \
353 + "${ED}"/usr/libexec/perf-core || die
354 + fi
355 +
356 + dodoc CREDITS
357 +
358 + dodoc *txt Documentation/*.txt
359 +
360 + # perf needs this decompressed to print out tips for users
361 + docompress -x /usr/share/doc/${PF}/tips.txt
362 +
363 + if use doc ; then
364 + doman Documentation/*.1
365 + fi
366 +}