diff options
Diffstat (limited to 'meta/recipes-kernel/perf/perf.bb')
-rw-r--r-- | meta/recipes-kernel/perf/perf.bb | 124 |
1 files changed, 101 insertions, 23 deletions
diff --git a/meta/recipes-kernel/perf/perf.bb b/meta/recipes-kernel/perf/perf.bb index 8ebd7d7cb5..11fa917649 100644 --- a/meta/recipes-kernel/perf/perf.bb +++ b/meta/recipes-kernel/perf/perf.bb @@ -7,31 +7,37 @@ and software features (software counters, tracepoints) \ as well." HOMEPAGE = "https://perf.wiki.kernel.org/index.php/Main_Page" -LICENSE = "GPLv2" +LICENSE = "GPL-2.0-only" -PR = "r9" -PACKAGECONFIG ??= "scripting tui libunwind" +PACKAGECONFIG ??= "python tui libunwind libtraceevent" PACKAGECONFIG[dwarf] = ",NO_DWARF=1" -PACKAGECONFIG[scripting] = ",NO_LIBPERL=1 NO_LIBPYTHON=1,perl python3" +PACKAGECONFIG[perl] = ",NO_LIBPERL=1,perl" +PACKAGECONFIG[python] = ",NO_LIBPYTHON=1,python3 python3-setuptools-native" # gui support was added with kernel 3.6.35 # since 3.10 libnewt was replaced by slang # to cover a wide range of kernel we add both dependencies PACKAGECONFIG[tui] = ",NO_NEWT=1,libnewt slang" PACKAGECONFIG[libunwind] = ",NO_LIBUNWIND=1 NO_LIBDW_DWARF_UNWIND=1,libunwind" PACKAGECONFIG[libnuma] = ",NO_LIBNUMA=1" +PACKAGECONFIG[bfd] = ",NO_LIBBFD=1" PACKAGECONFIG[systemtap] = ",NO_SDT=1,systemtap" PACKAGECONFIG[jvmti] = ",NO_JVMTI=1" # libaudit support would need scripting to be enabled PACKAGECONFIG[audit] = ",NO_LIBAUDIT=1,audit" PACKAGECONFIG[manpages] = ",,xmlto-native asciidoc-native" PACKAGECONFIG[cap] = ",,libcap" +PACKAGECONFIG[libtraceevent] = ",NO_LIBTRACEEVENT=1,libtraceevent" +# jevents requires host python for generating a .c file, but is +# unrelated to the python item. +PACKAGECONFIG[jevents] = ",NO_JEVENTS=1,python3-native" # Arm CoreSight PACKAGECONFIG[coresight] = "CORESIGHT=1,,opencsd" +PACKAGECONFIG[pfm4] = ",NO_LIBPFM4=1,libpfm4" +PACKAGECONFIG[babeltrace] = ",NO_LIBBABELTRACE=1,babeltrace" # libunwind is not yet ported for some architectures PACKAGECONFIG:remove:arc = "libunwind" -PACKAGECONFIG:remove:riscv64 = "libunwind" PACKAGECONFIG:remove:riscv32 = "libunwind" DEPENDS = " \ @@ -48,7 +54,7 @@ PROVIDES = "virtual/perf" inherit linux-kernel-base kernel-arch manpages # needed for building the tools/perf Python bindings -inherit ${@bb.utils.contains('PACKAGECONFIG', 'scripting', 'python3targetconfig', '', d)} +inherit_defer ${@bb.utils.contains('PACKAGECONFIG', 'python', 'python3targetconfig', '', d)} inherit python3-dir export PYTHON_SITEPACKAGES_DIR @@ -58,7 +64,7 @@ export WERROR = "0" do_populate_lic[depends] += "virtual/kernel:do_shared_workdir" # needed for building the tools/perf Perl binding -include ${@bb.utils.contains('PACKAGECONFIG', 'scripting', 'perf-perl.inc', '', d)} +include ${@bb.utils.contains('PACKAGECONFIG', 'perl', 'perf-perl.inc', '', d)} inherit kernelsrc @@ -70,8 +76,18 @@ SPDX_S = "${S}/tools/perf" # supported kernel. LDFLAGS="-ldl -lutil" +# Perf's build system adds its own optimization flags for most TUs, +# overriding the flags included here. But for some, perf does not add +# any -O option, so ensure the distro's chosen optimization gets used +# for those. Since ${SELECTED_OPTIMIZATION} always includes +# ${DEBUG_FLAGS} which in turn includes ${DEBUG_PREFIX_MAP}, this also +# ensures perf is built with appropriate -f*-prefix-map options, +# avoiding the 'buildpaths' QA warning. +TARGET_CC_ARCH += "${SELECTED_OPTIMIZATION}" + EXTRA_OEMAKE = '\ V=1 \ + VF=1 \ -C ${S}/tools/perf \ O=${B} \ CROSS_COMPILE=${TARGET_PREFIX} \ @@ -81,12 +97,13 @@ EXTRA_OEMAKE = '\ LDSHARED="${CC} -shared" \ AR="${AR}" \ LD="${LD}" \ - EXTRA_CFLAGS="-ldw" \ - YFLAGS='-y --file-prefix-map=${WORKDIR}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}' \ + EXTRA_CFLAGS="-ldw -I${S}" \ + YFLAGS='-y --file-prefix-map=${WORKDIR}=${TARGET_DBGSRC_DIR}' \ EXTRA_LDFLAGS="${PERF_EXTRA_LDFLAGS}" \ perfexecdir=${libexecdir} \ NO_GTK2=1 \ ${PACKAGECONFIG_CONFARGS} \ + PKG_CONFIG=pkg-config \ TMPDIR="${B}" \ LIBUNWIND_DIR=${STAGING_EXECPREFIXDIR} \ ' @@ -102,7 +119,7 @@ EXTRA_OEMAKE += "\ 'sharedir=${@os.path.relpath(datadir, prefix)}' \ 'mandir=${@os.path.relpath(mandir, prefix)}' \ 'infodir=${@os.path.relpath(infodir, prefix)}' \ - ${@bb.utils.contains('PACKAGECONFIG', 'scripting', 'PYTHON=python3 PYTHON_CONFIG=python3-config', '', d)} \ + ${@bb.utils.contains('PACKAGECONFIG', 'python', 'PYTHON=python3 PYTHON_CONFIG=python3-config', '', d)} \ " # During do_configure, we might run a 'make clean'. That often breaks @@ -110,8 +127,12 @@ EXTRA_OEMAKE += "\ # that it has to be done this way rather than by passing -j1, since # perf's build system by default ignores any -j argument, but does # honour a JOBS variable. -EXTRA_OEMAKE:append_task-configure = " JOBS=1" +EXTRA_OEMAKE:append:task-configure = " JOBS=1" +# the architectures that need this file can be found in +# tools/include/uapi/asm/bpf_perf_event.h +# We are only listing supported arches at the moment +PERF_BPF_EVENT_SRC ?= '${@bb.utils.contains_any("ARCH", [ "riscv", "arm64" ], "arch/${ARCH}/include/uapi/asm/bpf_perf_event.h", "", d)}' PERF_SRC ?= "Makefile \ tools/arch \ tools/build \ @@ -121,18 +142,26 @@ PERF_SRC ?= "Makefile \ tools/perf \ tools/scripts \ scripts/ \ + arch/arm64/tools \ + ${PERF_BPF_EVENT_SRC} \ arch/${ARCH}/Makefile \ " PERF_EXTRA_LDFLAGS = "" -# MIPS N32 +# MIPS N32/N64 PERF_EXTRA_LDFLAGS:mipsarchn32eb = "-m elf32btsmipn32" PERF_EXTRA_LDFLAGS:mipsarchn32el = "-m elf32ltsmipn32" +PERF_EXTRA_LDFLAGS:mipsarchn64eb = "-m elf64btsmip" +PERF_EXTRA_LDFLAGS:mipsarchn64el = "-m elf64ltsmip" do_compile() { # Linux kernel build system is expected to do the right thing unset CFLAGS + test -e ${S}/tools/lib/traceevent/plugins/Makefile && \ + sed -i -e 's|\$(libdir)/traceevent/plugins|\$(libdir)/traceevent_${KERNEL_VERSION}/plugins|g' ${S}/tools/lib/traceevent/plugins/Makefile + test -e ${S}/tools/perf/Makefile.config && \ + sed -i -e 's|\$(libdir)/traceevent/plugins|\$(libdir)/traceevent_${KERNEL_VERSION}/plugins|g' ${S}/tools/perf/Makefile.config oe_runmake all } @@ -141,8 +170,11 @@ do_install() { unset CFLAGS oe_runmake install # we are checking for this make target to be compatible with older perf versions - if ${@bb.utils.contains('PACKAGECONFIG', 'scripting', 'true', 'false', d)} && grep -q install-python_ext ${S}/tools/perf/Makefile*; then + if ${@bb.utils.contains('PACKAGECONFIG', 'python', 'true', 'false', d)} && grep -q install-python_ext ${S}/tools/perf/Makefile*; then oe_runmake DESTDIR=${D} install-python_ext + if [ -e ${D}${libdir}/python*/site-packages/perf-*/SOURCES.txt ]; then + sed -i -e 's#${WORKDIR}##g' ${D}${libdir}/python*/site-packages/perf-*/SOURCES.txt + fi fi } @@ -157,7 +189,8 @@ python copy_perf_source_from_kernel() { src = oe.path.join(src_dir, s) dest = oe.path.join(dest_dir, s) if not os.path.exists(src): - bb.fatal("Path does not exist: %s. Maybe PERF_SRC does not match the kernel version." % src) + bb.warn("Path does not exist: %s. Maybe PERF_SRC lists more files than what your kernel version provides and needs." % src) + continue if os.path.isdir(src): oe.path.copyhardlinktree(src, dest) else: @@ -202,14 +235,18 @@ do_configure:prepend () { if [ -e "${S}/tools/perf/Makefile.perf" ]; then sed -i -e 's,\ .config-detected, $(OUTPUT)/config-detected,g' \ ${S}/tools/perf/Makefile.perf - sed -i -e "s,prefix='\$(DESTDIR_SQ)/usr'$,prefix='\$(DESTDIR_SQ)/usr' --install-lib='\$(DESTDIR)\$(PYTHON_SITEPACKAGES_DIR)',g" \ + # Variant with linux-yocto-specific patch + sed -i -e "s,prefix='\$(DESTDIR_SQ)/usr'$,prefix='\$(DESTDIR_SQ)/usr' --install-lib='\$(PYTHON_SITEPACKAGES_DIR)' --root='\$(DESTDIR)',g" \ + ${S}/tools/perf/Makefile.perf + # Variant for mainline Linux + sed -i -e "s,root='/\$(DESTDIR_SQ)',prefix='\$(DESTDIR_SQ)/usr' --install-lib='\$(PYTHON_SITEPACKAGES_DIR)' --root='/\$(DESTDIR_SQ)',g" \ ${S}/tools/perf/Makefile.perf # backport https://github.com/torvalds/linux/commit/e4ffd066ff440a57097e9140fa9e16ceef905de8 sed -i -e 's,\($(Q)$(SHELL) .$(arch_errno_tbl).\) $(CC) $(arch_errno_hdr_dir),\1 $(firstword $(CC)) $(arch_errno_hdr_dir),g' \ ${S}/tools/perf/Makefile.perf fi sed -i -e "s,--root='/\$(DESTDIR_SQ)',--prefix='\$(DESTDIR_SQ)/usr' --install-lib='\$(DESTDIR)\$(PYTHON_SITEPACKAGES_DIR)',g" \ - ${S}/tools/perf/Makefile* + ${S}/tools/perf/Makefile if [ -e "${S}/tools/build/Makefile.build" ]; then sed -i -e 's,\ .config-detected, $(OUTPUT)/config-detected,g' \ @@ -226,6 +263,15 @@ do_configure:prepend () { # reproducible. sed -i -e 's,$(call get-executable-or-default\,PYTHON\,$(PYTHON_AUTO)),$(notdir $(call get-executable-or-default\,PYTHON\,$(PYTHON_AUTO))),g' \ ${S}/tools/perf/Makefile.config + # The same line is in older releases, but looking explicitly for Python 2 + sed -i -e 's,$(call get-executable-or-default\,PYTHON\,$(PYTHON2)),$(notdir $(call get-executable-or-default\,PYTHON\,$(PYTHON2))),g' \ + ${S}/tools/perf/Makefile.config + + # likewise with this substitution. Kernels with commit 18f2967418d031a39 + # [perf tools: Use Python devtools for version autodetection rather than runtime] + # need this substitution for reproducibility. + 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' \ + ${S}/tools/perf/Makefile.config # The following line: # srcdir_SQ = $(patsubst %tools/perf,tools/perf,$(subst ','\'',$(srcdir))), @@ -234,6 +280,9 @@ do_configure:prepend () { # change the Makefile line to remove everything before 'tools/perf' sed -i -e "s%srcdir_SQ = \$(subst ','\\\'',\$(srcdir))%srcdir_SQ = \$(patsubst \%tools/perf,tools/perf,\$(subst ','\\\'',\$(srcdir)))%g" \ ${S}/tools/perf/Makefile.config + # Avoid hardcoded path to python-native + sed -i -e 's#\(PYTHON_WORD := \)$(call shell-wordify,$(PYTHON))#\1 python3#g' \ + ${S}/tools/perf/Makefile.config fi if [ -e "${S}/tools/perf/tests/Build" ]; then # OUTPUT is the full path, we have python on the path so we remove it from the @@ -259,6 +308,20 @@ do_configure:prepend () { sed -i -e "s,$target,$replacement1$replacement2$replacement3,g" \ "${S}/tools/perf/pmu-events/Build" fi + if [ -e "${S}/tools/perf/pmu-events/jevents.py" ]; then + sed -i -e "s#os.scandir(path)#sorted(os.scandir(path), key=lambda e: e.name)#g" \ + "${S}/tools/perf/pmu-events/jevents.py" + fi + if [ -e "${S}/tools/perf/arch/arm64/Makefile" ]; then + sed -i 's,sysdef := $(srctree)/,sysdef := ,' ${S}/tools/perf/arch/arm64/Makefile + sed -i 's,$(incpath) $(sysdef),$(incpath) $(srctree)/$(sysdef) $(sysdef),' ${S}/tools/perf/arch/arm64/Makefile + fi + if [ -e "${S}/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl" ]; then + if ! grep -q input_rel ${S}/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl; then + sed -i 's,input=$4,input=$4\ninput_rel=$5,' ${S}/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl + fi + sed -i 's,#include \\"\$input\\",#include \\"\$input_rel\\",' ${S}/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl + fi # end reproducibility substitutions # We need to ensure the --sysroot option in CC is preserved @@ -266,6 +329,7 @@ do_configure:prepend () { sed -i 's,CC = $(CROSS_COMPILE)gcc,#CC,' ${S}/tools/perf/Makefile.perf sed -i 's,AR = $(CROSS_COMPILE)ar,#AR,' ${S}/tools/perf/Makefile.perf sed -i 's,LD = $(CROSS_COMPILE)ld,#LD,' ${S}/tools/perf/Makefile.perf + sed -i 's,PKG_CONFIG = $(CROSS_COMPILE)pkg-config,#PKG_CONFIG,' ${S}/tools/perf/Makefile.perf fi if [ -e "${S}/tools/lib/api/Makefile" ]; then sed -i 's,CC = $(CROSS_COMPILE)gcc,#CC,' ${S}/tools/lib/api/Makefile @@ -282,6 +346,9 @@ do_configure:prepend () { if [ -e "${S}/tools/build/Makefile.feature" ]; then sed -i 's,CFLAGS=,CC="\$(CC)" CFLAGS=,' ${S}/tools/build/Makefile.feature fi + # The libperl feature check produces fatal warnings due to -Werror being + # used, silence enough errors that the check passes. + sed -i 's/\(FLAGS_PERL_EMBED=.*\)/\1 -Wno-error=unused-function -Wno-error=attributes/' ${S}/tools/build/feature/Makefile # 3.17-rc1+ has a include issue for arm/powerpc. Temporarily sed in the appropriate include if [ -e "${S}/tools/perf/arch/$ARCH/util/skip-callchain-idx.c" ]; then @@ -324,13 +391,14 @@ RDEPENDS:${PN} += "elfutils bash" RDEPENDS:${PN}-archive =+ "bash" RDEPENDS:${PN}-python =+ "bash python3 python3-modules ${@bb.utils.contains('PACKAGECONFIG', 'audit', 'audit-python', '', d)}" RDEPENDS:${PN}-perl =+ "bash perl perl-modules" -RDEPENDS:${PN}-tests =+ "python3 bash" - -RSUGGESTS_SCRIPTING = "${@bb.utils.contains('PACKAGECONFIG', 'scripting', '${PN}-perl ${PN}-python', '',d)}" -RSUGGESTS:${PN} += "${PN}-archive ${PN}-tests ${RSUGGESTS_SCRIPTING}" +RDEPENDS:${PN}-tests =+ "python3 bash perl" +RSUGGESTS:${PN} += "${PN}-archive ${PN}-tests \ + ${@bb.utils.contains('PACKAGECONFIG', 'perl', '${PN}-perl', '', d)} \ + ${@bb.utils.contains('PACKAGECONFIG', 'python', '${PN}-python', '', d)} \ + " FILES_SOLIBSDEV = "" -FILES:${PN} += "${libexecdir}/perf-core ${exec_prefix}/libexec/perf-core ${libdir}/traceevent ${libdir}/libperf-jvmti.so" +FILES:${PN} += "${libexecdir}/perf-core ${exec_prefix}/libexec/perf-core ${libdir}/traceevent* ${libdir}/libperf-jvmti.so" FILES:${PN}-archive = "${libdir}/perf/perf-core/perf-archive" FILES:${PN}-tests = "${libdir}/perf/perf-core/tests ${libexecdir}/perf-core/tests" FILES:${PN}-python = " \ @@ -339,6 +407,16 @@ FILES:${PN}-python = " \ " FILES:${PN}-perl = "${libexecdir}/perf-core/scripts/perl" - -INHIBIT_PACKAGE_DEBUG_SPLIT="1" DEBUG_OPTIMIZATION:append = " -Wno-error=maybe-uninitialized" + +PACKAGESPLITFUNCS =+ "perf_fix_sources" + +perf_fix_sources () { + for f in util/parse-events-flex.h util/parse-events-flex.c util/pmu-flex.c \ + util/pmu-flex.h util/expr-flex.h util/expr-flex.c; do + f=${PKGD}${TARGET_DBGSRC_DIR}/$f + if [ -e $f ]; then + sed -i -e 's#${S}/##g' $f + fi + done +} |