summaryrefslogtreecommitdiffstats
path: root/meta/recipes-kernel/perf/perf.bb
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-kernel/perf/perf.bb')
-rw-r--r--meta/recipes-kernel/perf/perf.bb229
1 files changed, 182 insertions, 47 deletions
diff --git a/meta/recipes-kernel/perf/perf.bb b/meta/recipes-kernel/perf/perf.bb
index 868cde7353..4f29bd5bbc 100644
--- a/meta/recipes-kernel/perf/perf.bb
+++ b/meta/recipes-kernel/perf/perf.bb
@@ -7,31 +7,36 @@ and software features (software counters, tracepoints) \
7as well." 7as well."
8HOMEPAGE = "https://perf.wiki.kernel.org/index.php/Main_Page" 8HOMEPAGE = "https://perf.wiki.kernel.org/index.php/Main_Page"
9 9
10LICENSE = "GPLv2" 10LICENSE = "GPL-2.0-only"
11 11
12PR = "r9" 12# zstd is required for kernels 6.14+ when libelf-zstd is detected
13 13PACKAGECONFIG ??= "python tui libunwind libtraceevent zstd"
14PACKAGECONFIG ??= "scripting tui libunwind"
15PACKAGECONFIG[dwarf] = ",NO_DWARF=1" 14PACKAGECONFIG[dwarf] = ",NO_DWARF=1"
16PACKAGECONFIG[scripting] = ",NO_LIBPERL=1 NO_LIBPYTHON=1,perl python3" 15PACKAGECONFIG[perl] = ",NO_LIBPERL=1,perl"
17# gui support was added with kernel 3.6.35 16PACKAGECONFIG[python] = ",NO_LIBPYTHON=1,python3 python3-setuptools-native"
18# since 3.10 libnewt was replaced by slang 17PACKAGECONFIG[tui] = ",NO_SLANG=1,slang"
19# to cover a wide range of kernel we add both dependencies
20PACKAGECONFIG[tui] = ",NO_NEWT=1,libnewt slang"
21PACKAGECONFIG[libunwind] = ",NO_LIBUNWIND=1 NO_LIBDW_DWARF_UNWIND=1,libunwind" 18PACKAGECONFIG[libunwind] = ",NO_LIBUNWIND=1 NO_LIBDW_DWARF_UNWIND=1,libunwind"
22PACKAGECONFIG[libnuma] = ",NO_LIBNUMA=1" 19PACKAGECONFIG[libnuma] = ",NO_LIBNUMA=1"
20PACKAGECONFIG[bfd] = ",NO_LIBBFD=1"
23PACKAGECONFIG[systemtap] = ",NO_SDT=1,systemtap" 21PACKAGECONFIG[systemtap] = ",NO_SDT=1,systemtap"
24PACKAGECONFIG[jvmti] = ",NO_JVMTI=1" 22PACKAGECONFIG[jvmti] = ",NO_JVMTI=1"
25# libaudit support would need scripting to be enabled 23# libaudit support would need scripting to be enabled
26PACKAGECONFIG[audit] = ",NO_LIBAUDIT=1,audit" 24PACKAGECONFIG[audit] = ",NO_LIBAUDIT=1,audit"
27PACKAGECONFIG[manpages] = ",,xmlto-native asciidoc-native" 25PACKAGECONFIG[manpages] = ",,xmlto-native asciidoc-native"
28PACKAGECONFIG[cap] = ",,libcap" 26PACKAGECONFIG[cap] = ",,libcap"
27PACKAGECONFIG[libtraceevent] = ",NO_LIBTRACEEVENT=1,libtraceevent"
28# jevents requires host python for generating a .c file, but is
29# unrelated to the python item.
30PACKAGECONFIG[jevents] = ",NO_JEVENTS=1,python3-native"
29# Arm CoreSight 31# Arm CoreSight
30PACKAGECONFIG[coresight] = "CORESIGHT=1,,opencsd" 32PACKAGECONFIG[coresight] = "CORESIGHT=1,,opencsd"
33PACKAGECONFIG[pfm4] = ",NO_LIBPFM4=1,libpfm4"
34PACKAGECONFIG[babeltrace] = ",NO_LIBBABELTRACE=1,babeltrace"
35PACKAGECONFIG[zstd] = ",NO_LIBZSTD=1,zstd"
31 36
32# libunwind is not yet ported for some architectures 37# libunwind is not yet ported for some architectures
33PACKAGECONFIG_remove_arc = "libunwind" 38PACKAGECONFIG:remove:arc = "libunwind"
34PACKAGECONFIG_remove_riscv64 = "libunwind" 39PACKAGECONFIG:remove:riscv32 = "libunwind"
35 40
36DEPENDS = " \ 41DEPENDS = " \
37 virtual/${MLPREFIX}libc \ 42 virtual/${MLPREFIX}libc \
@@ -47,7 +52,7 @@ PROVIDES = "virtual/perf"
47inherit linux-kernel-base kernel-arch manpages 52inherit linux-kernel-base kernel-arch manpages
48 53
49# needed for building the tools/perf Python bindings 54# needed for building the tools/perf Python bindings
50inherit ${@bb.utils.contains('PACKAGECONFIG', 'scripting', 'python3native', '', d)} 55inherit_defer ${@bb.utils.contains('PACKAGECONFIG', 'python', 'python3targetconfig', '', d)}
51inherit python3-dir 56inherit python3-dir
52export PYTHON_SITEPACKAGES_DIR 57export PYTHON_SITEPACKAGES_DIR
53 58
@@ -57,20 +62,38 @@ export WERROR = "0"
57do_populate_lic[depends] += "virtual/kernel:do_shared_workdir" 62do_populate_lic[depends] += "virtual/kernel:do_shared_workdir"
58 63
59# needed for building the tools/perf Perl binding 64# needed for building the tools/perf Perl binding
60include ${@bb.utils.contains('PACKAGECONFIG', 'scripting', 'perf-perl.inc', '', d)} 65include ${@bb.utils.contains('PACKAGECONFIG', 'perl', 'perf-perl.inc', '', d)}
61 66
62inherit kernelsrc 67inherit kernelsrc
63 68
64S = "${WORKDIR}/${BP}" 69S = "${UNPACKDIR}/${BP}"
65SPDX_S = "${S}/tools/perf"
66 70
67# The LDFLAGS is required or some old kernels fails due missing 71# The LDFLAGS is required or some old kernels fails due missing
68# symbols and this is preferred than requiring patches to every old 72# symbols and this is preferred than requiring patches to every old
69# supported kernel. 73# supported kernel.
70LDFLAGS="-ldl -lutil" 74LDFLAGS = "-ldl -lutil"
75
76# Perf's build system adds its own optimization flags for most TUs,
77# overriding the flags included here. But for some, perf does not add
78# any -O option, so ensure the distro's chosen optimization gets used
79# for those. Also include ${DEBUG_PREFIX_MAP} which ensures perf is
80# built with appropriate -f*-prefix-map options,
81# avoiding the 'buildpaths' QA warning.
82TARGET_CC_ARCH += "${SELECTED_OPTIMIZATION} ${DEBUG_PREFIX_MAP}"
83
84#| libbpf.c: In function 'find_kernel_btf_id.constprop':
85#| libbpf.c:10009:33: error: 'mod_len' may be used uninitialized [-Werror=maybe-uninitialized]
86#| 10009 | if (mod_name && strncmp(mod->name, mod_name, mod_len) != 0)
87#| | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
88#| libbpf.c:9979:21: note: 'mod_len' was declared here
89#| 9979 | int ret, i, mod_len;
90#| | ^~~~~~~
91#| cc1: all warnings being treated as errors
92TARGET_CC_ARCH:append:toolchain-clang:arm = " -fno-error=maybe-uninitialized"
71 93
72EXTRA_OEMAKE = '\ 94EXTRA_OEMAKE = '\
73 V=1 \ 95 V=1 \
96 VF=1 \
74 -C ${S}/tools/perf \ 97 -C ${S}/tools/perf \
75 O=${B} \ 98 O=${B} \
76 CROSS_COMPILE=${TARGET_PREFIX} \ 99 CROSS_COMPILE=${TARGET_PREFIX} \
@@ -80,11 +103,13 @@ EXTRA_OEMAKE = '\
80 LDSHARED="${CC} -shared" \ 103 LDSHARED="${CC} -shared" \
81 AR="${AR}" \ 104 AR="${AR}" \
82 LD="${LD}" \ 105 LD="${LD}" \
83 EXTRA_CFLAGS="-ldw" \ 106 EXTRA_CFLAGS="-ldw -I${S}" \
107 YFLAGS='-y --file-prefix-map=${WORKDIR}=${TARGET_DBGSRC_DIR}' \
84 EXTRA_LDFLAGS="${PERF_EXTRA_LDFLAGS}" \ 108 EXTRA_LDFLAGS="${PERF_EXTRA_LDFLAGS}" \
85 perfexecdir=${libexecdir} \ 109 perfexecdir=${libexecdir} \
86 NO_GTK2=1 \ 110 NO_GTK2=1 \
87 ${PACKAGECONFIG_CONFARGS} \ 111 ${PACKAGECONFIG_CONFARGS} \
112 PKG_CONFIG=pkg-config \
88 TMPDIR="${B}" \ 113 TMPDIR="${B}" \
89 LIBUNWIND_DIR=${STAGING_EXECPREFIXDIR} \ 114 LIBUNWIND_DIR=${STAGING_EXECPREFIXDIR} \
90' 115'
@@ -100,7 +125,7 @@ EXTRA_OEMAKE += "\
100 'sharedir=${@os.path.relpath(datadir, prefix)}' \ 125 'sharedir=${@os.path.relpath(datadir, prefix)}' \
101 'mandir=${@os.path.relpath(mandir, prefix)}' \ 126 'mandir=${@os.path.relpath(mandir, prefix)}' \
102 'infodir=${@os.path.relpath(infodir, prefix)}' \ 127 'infodir=${@os.path.relpath(infodir, prefix)}' \
103 ${@bb.utils.contains('PACKAGECONFIG', 'scripting', 'PYTHON=python3 PYTHON_CONFIG=python3-config', '', d)} \ 128 ${@bb.utils.contains('PACKAGECONFIG', 'python', 'PYTHON=python3 PYTHON_CONFIG=python3-config', '', d)} \
104" 129"
105 130
106# During do_configure, we might run a 'make clean'. That often breaks 131# During do_configure, we might run a 'make clean'. That often breaks
@@ -108,8 +133,12 @@ EXTRA_OEMAKE += "\
108# that it has to be done this way rather than by passing -j1, since 133# that it has to be done this way rather than by passing -j1, since
109# perf's build system by default ignores any -j argument, but does 134# perf's build system by default ignores any -j argument, but does
110# honour a JOBS variable. 135# honour a JOBS variable.
111EXTRA_OEMAKE_append_task-configure = " JOBS=1" 136EXTRA_OEMAKE:append:task-configure = " JOBS=1"
112 137
138# the architectures that need this file can be found in
139# tools/include/uapi/asm/bpf_perf_event.h
140# We are only listing supported arches at the moment
141PERF_BPF_EVENT_SRC ?= '${@bb.utils.contains_any("ARCH", [ "riscv", "arm64" ], "arch/${ARCH}/include/uapi/asm/bpf_perf_event.h", "", d)}'
113PERF_SRC ?= "Makefile \ 142PERF_SRC ?= "Makefile \
114 tools/arch \ 143 tools/arch \
115 tools/build \ 144 tools/build \
@@ -119,18 +148,27 @@ PERF_SRC ?= "Makefile \
119 tools/perf \ 148 tools/perf \
120 tools/scripts \ 149 tools/scripts \
121 scripts/ \ 150 scripts/ \
151 arch/arm64/tools \
152 ${PERF_BPF_EVENT_SRC} \
122 arch/${ARCH}/Makefile \ 153 arch/${ARCH}/Makefile \
154 include/uapi/asm-generic/Kbuild \
123" 155"
124 156
125PERF_EXTRA_LDFLAGS = "" 157PERF_EXTRA_LDFLAGS = ""
126 158
127# MIPS N32 159# MIPS N32/N64
128PERF_EXTRA_LDFLAGS_mipsarchn32eb = "-m elf32btsmipn32" 160PERF_EXTRA_LDFLAGS:mipsarchn32eb = "-m elf32btsmipn32"
129PERF_EXTRA_LDFLAGS_mipsarchn32el = "-m elf32ltsmipn32" 161PERF_EXTRA_LDFLAGS:mipsarchn32el = "-m elf32ltsmipn32"
162PERF_EXTRA_LDFLAGS:mipsarchn64eb = "-m elf64btsmip"
163PERF_EXTRA_LDFLAGS:mipsarchn64el = "-m elf64ltsmip"
130 164
131do_compile() { 165do_compile() {
132 # Linux kernel build system is expected to do the right thing 166 # Linux kernel build system is expected to do the right thing
133 unset CFLAGS 167 unset CFLAGS
168 test -e ${S}/tools/lib/traceevent/plugins/Makefile && \
169 sed -i -e 's|\$(libdir)/traceevent/plugins|\$(libdir)/traceevent_${KERNEL_VERSION}/plugins|g' ${S}/tools/lib/traceevent/plugins/Makefile
170 test -e ${S}/tools/perf/Makefile.config && \
171 sed -i -e 's|\$(libdir)/traceevent/plugins|\$(libdir)/traceevent_${KERNEL_VERSION}/plugins|g' ${S}/tools/perf/Makefile.config
134 oe_runmake all 172 oe_runmake all
135} 173}
136 174
@@ -139,8 +177,11 @@ do_install() {
139 unset CFLAGS 177 unset CFLAGS
140 oe_runmake install 178 oe_runmake install
141 # we are checking for this make target to be compatible with older perf versions 179 # we are checking for this make target to be compatible with older perf versions
142 if ${@bb.utils.contains('PACKAGECONFIG', 'scripting', 'true', 'false', d)} && grep -q install-python_ext ${S}/tools/perf/Makefile*; then 180 if ${@bb.utils.contains('PACKAGECONFIG', 'python', 'true', 'false', d)} && grep -q install-python_ext ${S}/tools/perf/Makefile*; then
143 oe_runmake DESTDIR=${D} install-python_ext 181 oe_runmake DESTDIR=${D} install-python_ext
182 if [ -e ${D}${libdir}/python*/site-packages/perf-*/SOURCES.txt ]; then
183 sed -i -e 's#${WORKDIR}##g' ${D}${libdir}/python*/site-packages/perf-*/SOURCES.txt
184 fi
144 fi 185 fi
145} 186}
146 187
@@ -155,7 +196,8 @@ python copy_perf_source_from_kernel() {
155 src = oe.path.join(src_dir, s) 196 src = oe.path.join(src_dir, s)
156 dest = oe.path.join(dest_dir, s) 197 dest = oe.path.join(dest_dir, s)
157 if not os.path.exists(src): 198 if not os.path.exists(src):
158 bb.fatal("Path does not exist: %s. Maybe PERF_SRC does not match the kernel version." % src) 199 bb.warn("Path does not exist: %s. Maybe PERF_SRC lists more files than what your kernel version provides and needs." % src)
200 continue
159 if os.path.isdir(src): 201 if os.path.isdir(src):
160 oe.path.copyhardlinktree(src, dest) 202 oe.path.copyhardlinktree(src, dest)
161 else: 203 else:
@@ -164,10 +206,10 @@ python copy_perf_source_from_kernel() {
164 bb.utils.copyfile(src, dest) 206 bb.utils.copyfile(src, dest)
165} 207}
166 208
167do_configure_prepend () { 209do_configure:prepend () {
168 # If building a multlib based perf, the incorrect library path will be 210 # If building a multlib based perf, the incorrect library path will be
169 # detected by perf, since it triggers via: ifeq ($(ARCH),x86_64). In a 32 bit 211 # detected by perf, since it triggers via: ifeq ($(ARCH),x86_64). In a 32 bit
170 # build, with a 64 bit multilib, the arch won't match and the detection of a 212 # build, with a 64 bit multilib, the arch won't match and the detection of a
171 # 64 bit build (and library) are not exected. To ensure that libraries are 213 # 64 bit build (and library) are not exected. To ensure that libraries are
172 # installed to the correct location, we can use the weak assignment in the 214 # installed to the correct location, we can use the weak assignment in the
173 # config/Makefile. 215 # config/Makefile.
@@ -200,25 +242,101 @@ do_configure_prepend () {
200 if [ -e "${S}/tools/perf/Makefile.perf" ]; then 242 if [ -e "${S}/tools/perf/Makefile.perf" ]; then
201 sed -i -e 's,\ .config-detected, $(OUTPUT)/config-detected,g' \ 243 sed -i -e 's,\ .config-detected, $(OUTPUT)/config-detected,g' \
202 ${S}/tools/perf/Makefile.perf 244 ${S}/tools/perf/Makefile.perf
203 sed -i -e "s,prefix='\$(DESTDIR_SQ)/usr'$,prefix='\$(DESTDIR_SQ)/usr' --install-lib='\$(DESTDIR)\$(PYTHON_SITEPACKAGES_DIR)',g" \ 245 # Variant with linux-yocto-specific patch
246 sed -i -e "s,prefix='\$(DESTDIR_SQ)/usr'$,prefix='\$(DESTDIR_SQ)/usr' --install-lib='\$(PYTHON_SITEPACKAGES_DIR)' --root='\$(DESTDIR)',g" \
247 ${S}/tools/perf/Makefile.perf
248 # Variant for mainline Linux
249 sed -i -e "s,root='/\$(DESTDIR_SQ)',prefix='\$(DESTDIR_SQ)/usr' --install-lib='\$(PYTHON_SITEPACKAGES_DIR)' --root='/\$(DESTDIR_SQ)',g" \
204 ${S}/tools/perf/Makefile.perf 250 ${S}/tools/perf/Makefile.perf
205 # backport https://github.com/torvalds/linux/commit/e4ffd066ff440a57097e9140fa9e16ceef905de8 251 # backport https://github.com/torvalds/linux/commit/e4ffd066ff440a57097e9140fa9e16ceef905de8
206 sed -i -e 's,\($(Q)$(SHELL) .$(arch_errno_tbl).\) $(CC) $(arch_errno_hdr_dir),\1 $(firstword $(CC)) $(arch_errno_hdr_dir),g' \ 252 sed -i -e 's,\($(Q)$(SHELL) .$(arch_errno_tbl).\) $(CC) $(arch_errno_hdr_dir),\1 $(firstword $(CC)) $(arch_errno_hdr_dir),g' \
207 ${S}/tools/perf/Makefile.perf 253 ${S}/tools/perf/Makefile.perf
208 fi 254 fi
209 sed -i -e "s,--root='/\$(DESTDIR_SQ)',--prefix='\$(DESTDIR_SQ)/usr' --install-lib='\$(DESTDIR)\$(PYTHON_SITEPACKAGES_DIR)',g" \ 255 sed -i -e "s,--root='/\$(DESTDIR_SQ)',--prefix='\$(DESTDIR_SQ)/usr' --install-lib='\$(DESTDIR)\$(PYTHON_SITEPACKAGES_DIR)',g" \
210 ${S}/tools/perf/Makefile* 256 ${S}/tools/perf/Makefile
211 257
212 if [ -e "${S}/tools/build/Makefile.build" ]; then 258 if [ -e "${S}/tools/build/Makefile.build" ]; then
213 sed -i -e 's,\ .config-detected, $(OUTPUT)/config-detected,g' \ 259 sed -i -e 's,\ .config-detected, $(OUTPUT)/config-detected,g' \
214 ${S}/tools/build/Makefile.build 260 ${S}/tools/build/Makefile.build
215 fi 261 fi
216 262
263 # start reproducibility substitutions
264 if [ -e "${S}/tools/perf/Makefile.config" ]; then
265 # The following line in the Makefle:
266 # override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON_AUTO))
267 # "PYTHON" / "PYTHON_AUTO" have the full path as part of the variable. We've
268 # ensure that the environment is setup and we do not need the full path to be
269 # captured, since the symbol gets built into the executable, making it not
270 # reproducible.
271 sed -i -e 's,$(call get-executable-or-default\,PYTHON\,$(PYTHON_AUTO)),$(notdir $(call get-executable-or-default\,PYTHON\,$(PYTHON_AUTO))),g' \
272 ${S}/tools/perf/Makefile.config
273 # The same line is in older releases, but looking explicitly for Python 2
274 sed -i -e 's,$(call get-executable-or-default\,PYTHON\,$(PYTHON2)),$(notdir $(call get-executable-or-default\,PYTHON\,$(PYTHON2))),g' \
275 ${S}/tools/perf/Makefile.config
276
277 # likewise with this substitution. Kernels with commit 18f2967418d031a39
278 # [perf tools: Use Python devtools for version autodetection rather than runtime]
279 # need this substitution for reproducibility.
280 sed -i -e 's,$(call get-executable-or-default\,PYTHON\,$(subst -config\,\,$(PYTHON_AUTO))),$(notdir $(call get-executable-or-default\,PYTHON\,$(subst -config\,\,$(PYTHON_AUTO)))),g' \
281 ${S}/tools/perf/Makefile.config
282
283 # The following line:
284 # srcdir_SQ = $(patsubst %tools/perf,tools/perf,$(subst ','\'',$(srcdir))),
285 # Captures the full src path of perf, which of course makes it not
286 # reproducible. We really only need the relative location 'tools/perf', so we
287 # change the Makefile line to remove everything before 'tools/perf'
288 sed -i -e "s%srcdir_SQ = \$(subst ','\\\'',\$(srcdir))%srcdir_SQ = \$(patsubst \%tools/perf,tools/perf,\$(subst ','\\\'',\$(srcdir)))%g" \
289 ${S}/tools/perf/Makefile.config
290 # Avoid hardcoded path to python-native
291 sed -i -e 's#\(PYTHON_WORD := \)$(call shell-wordify,$(PYTHON))#\1 python3#g' \
292 ${S}/tools/perf/Makefile.config
293 fi
294 if [ -e "${S}/tools/perf/tests/Build" ]; then
295 # OUTPUT is the full path, we have python on the path so we remove it from the
296 # definition. This is captured in the perf binary, so breaks reproducibility
297 sed -i -e 's,PYTHONPATH="BUILD_STR($(OUTPUT)python)",PYTHONPATH="BUILD_STR(python)",g' \
298 ${S}/tools/perf/tests/Build
299 fi
300 if [ -e "${S}/tools/perf/util/Build" ]; then
301 # To avoid bison generating #ifdefs that have captured paths, we make sure
302 # all the calls have YFLAGS, which contains prefix mapping information.
303 sed -i -e 's,$(BISON),$(BISON) $(YFLAGS),g' ${S}/tools/perf/util/Build
304 fi
305 if [ -e "${S}/scripts/Makefile.host" ]; then
306 # To avoid yacc (bison) generating #ifdefs that have captured paths, we make sure
307 # all the calls have YFLAGS, which contains prefix mapping information.
308 sed -i -e 's,$(YACC),$(YACC) $(YFLAGS),g' ${S}/scripts/Makefile.host
309 fi
310 if [ -e "${S}/tools/perf/pmu-events/Build" ]; then
311 target='$(OUTPUT)pmu-events/pmu-events.c $(V)'
312 replacement1='$(OUTPUT)pmu-events/pmu-events.c $(V)\n'
313 replacement2='\t$(srctree)/sort-pmuevents.py $(OUTPUT)pmu-events/pmu-events.c $(OUTPUT)pmu-events/pmu-events.c.new\n'
314 replacement3='\tcp $(OUTPUT)pmu-events/pmu-events.c.new $(OUTPUT)pmu-events/pmu-events.c'
315 sed -i -e "s,$target,$replacement1$replacement2$replacement3,g" \
316 "${S}/tools/perf/pmu-events/Build"
317 fi
318 if [ -e "${S}/tools/perf/pmu-events/jevents.py" ]; then
319 sed -i -e "s#os.scandir(path)#sorted(os.scandir(path), key=lambda e: e.name)#g" \
320 "${S}/tools/perf/pmu-events/jevents.py"
321 fi
322 if [ -e "${S}/tools/perf/arch/arm64/Makefile" ]; then
323 sed -i 's,sysdef := $(srctree)/,sysdef := ,' ${S}/tools/perf/arch/arm64/Makefile
324 sed -i 's,$(incpath) $(sysdef),$(incpath) $(srctree)/$(sysdef) $(sysdef),' ${S}/tools/perf/arch/arm64/Makefile
325 fi
326 if [ -e "${S}/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl" ]; then
327 if ! grep -q input_rel ${S}/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl; then
328 sed -i 's,input=$4,input=$4\ninput_rel=$5,' ${S}/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
329 fi
330 sed -i 's,#include \\"\$input\\",#include \\"\$input_rel\\",' ${S}/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
331 fi
332 # end reproducibility substitutions
333
217 # We need to ensure the --sysroot option in CC is preserved 334 # We need to ensure the --sysroot option in CC is preserved
218 if [ -e "${S}/tools/perf/Makefile.perf" ]; then 335 if [ -e "${S}/tools/perf/Makefile.perf" ]; then
219 sed -i 's,CC = $(CROSS_COMPILE)gcc,#CC,' ${S}/tools/perf/Makefile.perf 336 sed -i 's,CC = $(CROSS_COMPILE)gcc,#CC,' ${S}/tools/perf/Makefile.perf
220 sed -i 's,AR = $(CROSS_COMPILE)ar,#AR,' ${S}/tools/perf/Makefile.perf 337 sed -i 's,AR = $(CROSS_COMPILE)ar,#AR,' ${S}/tools/perf/Makefile.perf
221 sed -i 's,LD = $(CROSS_COMPILE)ld,#LD,' ${S}/tools/perf/Makefile.perf 338 sed -i 's,LD = $(CROSS_COMPILE)ld,#LD,' ${S}/tools/perf/Makefile.perf
339 sed -i 's,PKG_CONFIG = $(CROSS_COMPILE)pkg-config,#PKG_CONFIG,' ${S}/tools/perf/Makefile.perf
222 fi 340 fi
223 if [ -e "${S}/tools/lib/api/Makefile" ]; then 341 if [ -e "${S}/tools/lib/api/Makefile" ]; then
224 sed -i 's,CC = $(CROSS_COMPILE)gcc,#CC,' ${S}/tools/lib/api/Makefile 342 sed -i 's,CC = $(CROSS_COMPILE)gcc,#CC,' ${S}/tools/lib/api/Makefile
@@ -235,6 +353,9 @@ do_configure_prepend () {
235 if [ -e "${S}/tools/build/Makefile.feature" ]; then 353 if [ -e "${S}/tools/build/Makefile.feature" ]; then
236 sed -i 's,CFLAGS=,CC="\$(CC)" CFLAGS=,' ${S}/tools/build/Makefile.feature 354 sed -i 's,CFLAGS=,CC="\$(CC)" CFLAGS=,' ${S}/tools/build/Makefile.feature
237 fi 355 fi
356 # The libperl feature check produces fatal warnings due to -Werror being
357 # used, silence enough errors that the check passes.
358 sed -i 's/\(FLAGS_PERL_EMBED=.*\)/\1 -Wno-error=unused-function -Wno-error=attributes/' ${S}/tools/build/feature/Makefile
238 359
239 # 3.17-rc1+ has a include issue for arm/powerpc. Temporarily sed in the appropriate include 360 # 3.17-rc1+ has a include issue for arm/powerpc. Temporarily sed in the appropriate include
240 if [ -e "${S}/tools/perf/arch/$ARCH/util/skip-callchain-idx.c" ]; then 361 if [ -e "${S}/tools/perf/arch/$ARCH/util/skip-callchain-idx.c" ]; then
@@ -254,36 +375,50 @@ do_configure_prepend () {
254 # so we copy it from the sysroot unistd.h to the perf unistd.h 375 # so we copy it from the sysroot unistd.h to the perf unistd.h
255 install -D -m0644 ${STAGING_INCDIR}/asm-generic/unistd.h ${S}/tools/include/uapi/asm-generic/unistd.h 376 install -D -m0644 ${STAGING_INCDIR}/asm-generic/unistd.h ${S}/tools/include/uapi/asm-generic/unistd.h
256 install -D -m0644 ${STAGING_INCDIR}/asm-generic/unistd.h ${S}/include/uapi/asm-generic/unistd.h 377 install -D -m0644 ${STAGING_INCDIR}/asm-generic/unistd.h ${S}/include/uapi/asm-generic/unistd.h
257}
258 378
259python do_package_prepend() { 379 # the fetcher is inhibited by the 'inherit kernelsrc', so we do a quick check and
260 d.setVar('PKGV', d.getVar("KERNEL_VERSION").split("-")[0]) 380 # copy for a helper script we need
381 for p in $(echo ${FILESPATH} | tr ':' '\n'); do
382 if [ -e $p/sort-pmuevents.py ]; then
383 cp $p/sort-pmuevents.py ${S}
384 fi
385 done
261} 386}
262 387
263PACKAGE_ARCH = "${MACHINE_ARCH}" 388PACKAGE_ARCH = "${MACHINE_ARCH}"
264 389
265
266PACKAGES =+ "${PN}-archive ${PN}-tests ${PN}-perl ${PN}-python" 390PACKAGES =+ "${PN}-archive ${PN}-tests ${PN}-perl ${PN}-python"
267 391
268RDEPENDS_${PN} += "elfutils bash" 392RDEPENDS:${PN} += "elfutils bash"
269RDEPENDS_${PN}-archive =+ "bash" 393RDEPENDS:${PN}-archive =+ "bash"
270RDEPENDS_${PN}-python =+ "bash python3 python3-modules ${@bb.utils.contains('PACKAGECONFIG', 'audit', 'audit-python3', '', d)}" 394RDEPENDS:${PN}-python =+ "bash python3 python3-modules ${@bb.utils.contains('PACKAGECONFIG', 'audit', 'audit-python', '', d)}"
271RDEPENDS_${PN}-perl =+ "bash perl perl-modules" 395RDEPENDS:${PN}-perl =+ "bash perl perl-modules"
272RDEPENDS_${PN}-tests =+ "python3" 396RDEPENDS:${PN}-tests =+ "python3 bash perl"
273
274RSUGGESTS_SCRIPTING = "${@bb.utils.contains('PACKAGECONFIG', 'scripting', '${PN}-perl ${PN}-python', '',d)}"
275RSUGGESTS_${PN} += "${PN}-archive ${PN}-tests ${RSUGGESTS_SCRIPTING}"
276 397
398RSUGGESTS:${PN} += "${PN}-archive ${PN}-tests \
399 ${@bb.utils.contains('PACKAGECONFIG', 'perl', '${PN}-perl', '', d)} \
400 ${@bb.utils.contains('PACKAGECONFIG', 'python', '${PN}-python', '', d)} \
401 "
277FILES_SOLIBSDEV = "" 402FILES_SOLIBSDEV = ""
278FILES_${PN} += "${libexecdir}/perf-core ${exec_prefix}/libexec/perf-core ${libdir}/traceevent ${libdir}/libperf-jvmti.so" 403FILES:${PN} += "${libexecdir}/perf-core ${exec_prefix}/libexec/perf-core ${libdir}/traceevent* ${libdir}/libperf-jvmti.so"
279FILES_${PN}-archive = "${libdir}/perf/perf-core/perf-archive" 404FILES:${PN}-archive = "${libdir}/perf/perf-core/perf-archive"
280FILES_${PN}-tests = "${libdir}/perf/perf-core/tests ${libexecdir}/perf-core/tests" 405FILES:${PN}-tests = "${libdir}/perf/perf-core/tests ${libexecdir}/perf-core/tests"
281FILES_${PN}-python = " \ 406FILES:${PN}-python = " \
282 ${PYTHON_SITEPACKAGES_DIR} \ 407 ${PYTHON_SITEPACKAGES_DIR} \
283 ${libexecdir}/perf-core/scripts/python \ 408 ${libexecdir}/perf-core/scripts/python \
284 " 409 "
285FILES_${PN}-perl = "${libexecdir}/perf-core/scripts/perl" 410FILES:${PN}-perl = "${libexecdir}/perf-core/scripts/perl"
286 411
412DEBUG_OPTIMIZATION:append = " -Wno-error=maybe-uninitialized"
287 413
288INHIBIT_PACKAGE_DEBUG_SPLIT="1" 414PACKAGESPLITFUNCS =+ "perf_fix_sources"
289DEBUG_OPTIMIZATION_append = " -Wno-error=maybe-uninitialized" 415
416perf_fix_sources () {
417 for f in util/parse-events-flex.h util/parse-events-flex.c util/pmu-flex.c \
418 util/pmu-flex.h util/expr-flex.h util/expr-flex.c; do
419 f=${PKGD}${TARGET_DBGSRC_DIR}/$f
420 if [ -e $f ]; then
421 sed -i -e 's#${S}/##g' $f
422 fi
423 done
424}