Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | SUMMARY = "Performance analysis tools for Linux" |
| 2 | DESCRIPTION = "Performance counters for Linux are a new kernel-based \ |
| 3 | subsystem that provide a framework for all things \ |
| 4 | performance analysis. It covers hardware level \ |
| 5 | (CPU/PMU, Performance Monitoring Unit) features \ |
| 6 | and software features (software counters, tracepoints) \ |
| 7 | as well." |
Joel Stanley | e252c31 | 2017-12-14 15:11:12 +1030 | [diff] [blame] | 8 | HOMEPAGE = "https://perf.wiki.kernel.org/index.php/Main_Page" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9 | |
| 10 | LICENSE = "GPLv2" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11 | |
| 12 | PR = "r9" |
| 13 | |
Joel Stanley | e252c31 | 2017-12-14 15:11:12 +1030 | [diff] [blame] | 14 | PACKAGECONFIG ??= "scripting tui libunwind" |
| 15 | PACKAGECONFIG[scripting] = ",NO_LIBPERL=1 NO_LIBPYTHON=1,perl python" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 16 | # gui support was added with kernel 3.6.35 |
| 17 | # since 3.10 libnewt was replaced by slang |
| 18 | # to cover a wide range of kernel we add both dependencies |
Joel Stanley | e252c31 | 2017-12-14 15:11:12 +1030 | [diff] [blame] | 19 | PACKAGECONFIG[tui] = ",NO_NEWT=1,libnewt slang" |
| 20 | PACKAGECONFIG[libunwind] = ",NO_LIBUNWIND=1 NO_LIBDW_DWARF_UNWIND=1,libunwind" |
| 21 | PACKAGECONFIG[libnuma] = ",NO_LIBNUMA=1" |
| 22 | PACKAGECONFIG[systemtap] = ",NO_SDT=1,systemtap" |
| 23 | PACKAGECONFIG[jvmti] = ",NO_JVMTI=1" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 24 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 25 | # libaudit support would need scripting to be enabled |
| 26 | PACKAGECONFIG[audit] = ",NO_LIBAUDIT=1,audit" |
| 27 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 28 | DEPENDS = " \ |
| 29 | virtual/${MLPREFIX}libc \ |
| 30 | ${MLPREFIX}elfutils \ |
| 31 | ${MLPREFIX}binutils \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 32 | bison-native flex-native xz \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 33 | xmlto-native \ |
| 34 | asciidoc-native \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 35 | " |
| 36 | |
| 37 | do_configure[depends] += "virtual/kernel:do_shared_workdir" |
| 38 | |
| 39 | PROVIDES = "virtual/perf" |
| 40 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 41 | inherit linux-kernel-base kernel-arch |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 42 | |
| 43 | # needed for building the tools/perf Python bindings |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 44 | inherit ${@bb.utils.contains('PACKAGECONFIG', 'scripting', 'pythonnative', '', d)} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 45 | inherit python-dir |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 46 | export PYTHON_SITEPACKAGES_DIR |
| 47 | |
| 48 | #kernel 3.1+ supports WERROR to disable warnings as errors |
| 49 | export WERROR = "0" |
| 50 | |
| 51 | do_populate_lic[depends] += "virtual/kernel:do_patch" |
| 52 | |
| 53 | # needed for building the tools/perf Perl binding |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 54 | inherit ${@bb.utils.contains('PACKAGECONFIG', 'scripting', 'perlnative', '', d)} |
| 55 | inherit cpan-base |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 56 | # Env var which tells perl if it should use host (no) or target (yes) settings |
| 57 | export PERLCONFIGTARGET = "${@is_target(d)}" |
| 58 | export PERL_INC = "${STAGING_LIBDIR}${PERL_OWN_DIR}/perl/${@get_perl_version(d)}/CORE" |
| 59 | export PERL_LIB = "${STAGING_LIBDIR}${PERL_OWN_DIR}/perl/${@get_perl_version(d)}" |
| 60 | export PERL_ARCHLIB = "${STAGING_LIBDIR}${PERL_OWN_DIR}/perl/${@get_perl_version(d)}" |
| 61 | |
| 62 | inherit kernelsrc |
| 63 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 64 | S = "${WORKDIR}/${BP}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 65 | SPDX_S = "${S}/tools/perf" |
| 66 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 67 | # The LDFLAGS is required or some old kernels fails due missing |
| 68 | # symbols and this is preferred than requiring patches to every old |
| 69 | # supported kernel. |
| 70 | LDFLAGS="-ldl -lutil" |
| 71 | |
| 72 | EXTRA_OEMAKE = '\ |
| 73 | -C ${S}/tools/perf \ |
| 74 | O=${B} \ |
| 75 | CROSS_COMPILE=${TARGET_PREFIX} \ |
| 76 | ARCH=${ARCH} \ |
| 77 | CC="${CC}" \ |
| 78 | AR="${AR}" \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 79 | LD="${LD}" \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 80 | EXTRA_CFLAGS="-ldw" \ |
Joel Stanley | e252c31 | 2017-12-14 15:11:12 +1030 | [diff] [blame] | 81 | EXTRA_LDFLAGS="${PERF_EXTRA_LDFLAGS}" \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 82 | perfexecdir=${libexecdir} \ |
Joel Stanley | e252c31 | 2017-12-14 15:11:12 +1030 | [diff] [blame] | 83 | NO_GTK2=1 NO_DWARF=1 \ |
| 84 | ${PACKAGECONFIG_CONFARGS} \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 85 | ' |
| 86 | |
| 87 | EXTRA_OEMAKE += "\ |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 88 | 'DESTDIR=${D}' \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 89 | 'prefix=${prefix}' \ |
| 90 | 'bindir=${bindir}' \ |
| 91 | 'sharedir=${datadir}' \ |
| 92 | 'sysconfdir=${sysconfdir}' \ |
| 93 | 'perfexecdir=${libexecdir}/perf-core' \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 94 | 'ETC_PERFCONFIG=${@os.path.relpath(sysconfdir, prefix)}' \ |
| 95 | 'sharedir=${@os.path.relpath(datadir, prefix)}' \ |
| 96 | 'mandir=${@os.path.relpath(mandir, prefix)}' \ |
| 97 | 'infodir=${@os.path.relpath(infodir, prefix)}' \ |
| 98 | " |
| 99 | |
Brad Bishop | d5ae7d9 | 2018-06-14 09:52:03 -0700 | [diff] [blame] | 100 | # During do_configure, we might run a 'make clean'. That often breaks |
| 101 | # when done in parallel, so disable parallelism for do_configure. Note |
| 102 | # that it has to be done this way rather than by passing -j1, since |
| 103 | # perf's build system by default ignores any -j argument, but does |
| 104 | # honour a JOBS variable. |
| 105 | EXTRA_OEMAKE_append_task-configure = " JOBS=1" |
| 106 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 107 | PERF_SRC ?= "Makefile \ |
| 108 | include \ |
| 109 | tools/arch \ |
| 110 | tools/build \ |
| 111 | tools/include \ |
| 112 | tools/lib \ |
| 113 | tools/Makefile \ |
| 114 | tools/perf \ |
| 115 | tools/scripts \ |
| 116 | " |
| 117 | |
Joel Stanley | e252c31 | 2017-12-14 15:11:12 +1030 | [diff] [blame] | 118 | PERF_EXTRA_LDFLAGS = "" |
| 119 | |
| 120 | # MIPS N32 |
| 121 | PERF_EXTRA_LDFLAGS_mipsarchn32eb = "-m elf32btsmipn32" |
| 122 | PERF_EXTRA_LDFLAGS_mipsarchn32el = "-m elf32ltsmipn32" |
| 123 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 124 | do_compile() { |
| 125 | # Linux kernel build system is expected to do the right thing |
| 126 | unset CFLAGS |
| 127 | oe_runmake all |
| 128 | } |
| 129 | |
| 130 | do_install() { |
| 131 | # Linux kernel build system is expected to do the right thing |
| 132 | unset CFLAGS |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 133 | oe_runmake install |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 134 | # we are checking for this make target to be compatible with older perf versions |
Joel Stanley | e252c31 | 2017-12-14 15:11:12 +1030 | [diff] [blame] | 135 | if ${@bb.utils.contains('PACKAGECONFIG', 'scripting', 'true', 'false', d)} && grep -q install-python_ext ${S}/tools/perf/Makefile*; then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 136 | oe_runmake DESTDIR=${D} install-python_ext |
| 137 | fi |
| 138 | } |
| 139 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 140 | do_configure[prefuncs] += "copy_perf_source_from_kernel" |
| 141 | python copy_perf_source_from_kernel() { |
| 142 | sources = (d.getVar("PERF_SRC") or "").split() |
| 143 | src_dir = d.getVar("STAGING_KERNEL_DIR") |
| 144 | dest_dir = d.getVar("S") |
| 145 | bb.utils.mkdirhier(dest_dir) |
| 146 | for s in sources: |
| 147 | src = oe.path.join(src_dir, s) |
| 148 | dest = oe.path.join(dest_dir, s) |
| 149 | if os.path.isdir(src): |
| 150 | oe.path.copyhardlinktree(src, dest) |
| 151 | else: |
| 152 | bb.utils.copyfile(src, dest) |
| 153 | } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 154 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 155 | do_configure_prepend () { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 156 | # If building a multlib based perf, the incorrect library path will be |
| 157 | # detected by perf, since it triggers via: ifeq ($(ARCH),x86_64). In a 32 bit |
| 158 | # build, with a 64 bit multilib, the arch won't match and the detection of a |
| 159 | # 64 bit build (and library) are not exected. To ensure that libraries are |
| 160 | # installed to the correct location, we can use the weak assignment in the |
| 161 | # config/Makefile. |
| 162 | # |
| 163 | # Also need to relocate .config-detected to $(OUTPUT)/config-detected |
| 164 | # for kernel sources that do not already do this |
| 165 | # as two builds (e.g. perf and lib32-perf from mutlilib can conflict |
| 166 | # with each other if its in the shared source directory |
| 167 | # |
| 168 | if [ -e "${S}/tools/perf/config/Makefile" ]; then |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 169 | perfconfig="${S}/tools/perf/config/Makefile" |
| 170 | fi |
| 171 | if [ -e "${S}/tools/perf/Makefile.config" ]; then |
| 172 | perfconfig="${S}/tools/perf/Makefile.config" |
| 173 | fi |
| 174 | if [ -n "${perfconfig}" ]; then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 175 | # Match $(prefix)/$(lib) and $(prefix)/lib |
| 176 | sed -i -e 's,^libdir = \($(prefix)/.*lib\),libdir ?= \1,' \ |
| 177 | -e 's,^perfexecdir = \(.*\),perfexecdir ?= \1,' \ |
| 178 | -e 's,\ .config-detected, $(OUTPUT)/config-detected,g' \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 179 | ${perfconfig} |
| 180 | fi |
| 181 | # The man pages installation is "$(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)" |
| 182 | # in ${S}/tools/perf/Documentation/Makefile, if the mandir set to '?=', it |
| 183 | # will use the relative path 'share/man', in the way it will resulting in |
| 184 | # incorrect installation for man pages. |
| 185 | if [ -e "${S}/tools/perf/Documentation/Makefile" ]; then |
| 186 | sed -i 's,^mandir?=,mandir:=,' ${S}/tools/perf/Documentation/Makefile |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 187 | fi |
| 188 | if [ -e "${S}/tools/perf/Makefile.perf" ]; then |
| 189 | sed -i -e 's,\ .config-detected, $(OUTPUT)/config-detected,g' \ |
| 190 | ${S}/tools/perf/Makefile.perf |
| 191 | sed -i -e "s,prefix='\$(DESTDIR_SQ)/usr'$,prefix='\$(DESTDIR_SQ)/usr' --install-lib='\$(DESTDIR)\$(PYTHON_SITEPACKAGES_DIR)',g" \ |
| 192 | ${S}/tools/perf/Makefile.perf |
| 193 | fi |
| 194 | sed -i -e "s,--root='/\$(DESTDIR_SQ)',--prefix='\$(DESTDIR_SQ)/usr' --install-lib='\$(DESTDIR)\$(PYTHON_SITEPACKAGES_DIR)',g" \ |
Patrick Williams | d7e9631 | 2015-09-22 08:09:05 -0500 | [diff] [blame] | 195 | ${S}/tools/perf/Makefile* |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 196 | |
| 197 | if [ -e "${S}/tools/build/Makefile.build" ]; then |
| 198 | sed -i -e 's,\ .config-detected, $(OUTPUT)/config-detected,g' \ |
| 199 | ${S}/tools/build/Makefile.build |
| 200 | fi |
| 201 | |
| 202 | # We need to ensure the --sysroot option in CC is preserved |
| 203 | if [ -e "${S}/tools/perf/Makefile.perf" ]; then |
| 204 | sed -i 's,CC = $(CROSS_COMPILE)gcc,#CC,' ${S}/tools/perf/Makefile.perf |
| 205 | sed -i 's,AR = $(CROSS_COMPILE)ar,#AR,' ${S}/tools/perf/Makefile.perf |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 206 | sed -i 's,LD = $(CROSS_COMPILE)ld,#LD,' ${S}/tools/perf/Makefile.perf |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 207 | fi |
| 208 | if [ -e "${S}/tools/lib/api/Makefile" ]; then |
| 209 | sed -i 's,CC = $(CROSS_COMPILE)gcc,#CC,' ${S}/tools/lib/api/Makefile |
| 210 | sed -i 's,AR = $(CROSS_COMPILE)ar,#AR,' ${S}/tools/lib/api/Makefile |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 211 | sed -i 's,LD = $(CROSS_COMPILE)ld,#LD,' ${S}/tools/lib/api/Makefile |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 212 | fi |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 213 | if [ -e "${S}/tools/lib/subcmd/Makefile" ]; then |
| 214 | sed -i 's,CC = $(CROSS_COMPILE)gcc,#CC,' ${S}/tools/lib/subcmd/Makefile |
| 215 | sed -i 's,AR = $(CROSS_COMPILE)ar,#AR,' ${S}/tools/lib/subcmd/Makefile |
| 216 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 217 | if [ -e "${S}/tools/perf/config/feature-checks/Makefile" ]; then |
| 218 | sed -i 's,CC := $(CROSS_COMPILE)gcc -MD,CC += -MD,' ${S}/tools/perf/config/feature-checks/Makefile |
| 219 | fi |
| 220 | if [ -e "${S}/tools/build/Makefile.feature" ]; then |
| 221 | sed -i 's,CFLAGS=,CC="\$(CC)" CFLAGS=,' ${S}/tools/build/Makefile.feature |
| 222 | fi |
| 223 | |
| 224 | # 3.17-rc1+ has a include issue for arm/powerpc. Temporarily sed in the appropriate include |
| 225 | if [ -e "${S}/tools/perf/arch/$ARCH/util/skip-callchain-idx.c" ]; then |
| 226 | sed -i 's,#include "util/callchain.h",#include "util/callchain.h"\n#include "util/debug.h",' ${S}/tools/perf/arch/$ARCH/util/skip-callchain-idx.c |
| 227 | fi |
| 228 | if [ -e "${S}/tools/perf/arch/arm/util/unwind-libunwind.c" ] && [ -e "${S}/tools/perf/arch/arm/tests/dwarf-unwind.c" ]; then |
| 229 | sed -i 's,#include "tests/tests.h",#include "tests/tests.h"\n#include "util/debug.h",' ${S}/tools/perf/arch/arm/tests/dwarf-unwind.c |
| 230 | sed -i 's,#include "perf_regs.h",#include "perf_regs.h"\n#include "util/debug.h",' ${S}/tools/perf/arch/arm/util/unwind-libunwind.c |
| 231 | fi |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 232 | |
| 233 | # use /usr/bin/env instead of version specific python |
| 234 | for s in `find ${S}/tools/perf/scripts/python/ -name '*.py'`; do |
| 235 | sed -i 's,/usr/bin/python2,/usr/bin/env python,' "${s}" |
| 236 | done |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | python do_package_prepend() { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 240 | d.setVar('PKGV', d.getVar("KERNEL_VERSION").split("-")[0]) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
| 244 | |
| 245 | |
| 246 | PACKAGES =+ "${PN}-archive ${PN}-tests ${PN}-perl ${PN}-python" |
| 247 | |
| 248 | RDEPENDS_${PN} += "elfutils bash" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 249 | RDEPENDS_${PN}-doc += "man" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 250 | RDEPENDS_${PN}-archive =+ "bash" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 251 | RDEPENDS_${PN}-python =+ "bash python python-modules ${@bb.utils.contains('PACKAGECONFIG', 'audit', 'audit-python', '', d)}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 252 | RDEPENDS_${PN}-perl =+ "bash perl perl-modules" |
| 253 | RDEPENDS_${PN}-tests =+ "python" |
| 254 | |
Joel Stanley | e252c31 | 2017-12-14 15:11:12 +1030 | [diff] [blame] | 255 | RSUGGESTS_SCRIPTING = "${@bb.utils.contains('PACKAGECONFIG', 'scripting', '${PN}-perl ${PN}-python', '',d)}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 256 | RSUGGESTS_${PN} += "${PN}-archive ${PN}-tests ${RSUGGESTS_SCRIPTING}" |
| 257 | |
| 258 | FILES_${PN} += "${libexecdir}/perf-core ${exec_prefix}/libexec/perf-core ${libdir}/traceevent" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 259 | FILES_${PN}-archive = "${libdir}/perf/perf-core/perf-archive" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 260 | FILES_${PN}-tests = "${libdir}/perf/perf-core/tests ${libexecdir}/perf-core/tests" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 261 | FILES_${PN}-python = " \ |
| 262 | ${PYTHON_SITEPACKAGES_DIR} \ |
| 263 | ${libexecdir}/perf-core/scripts/python \ |
| 264 | " |
| 265 | FILES_${PN}-perl = "${libexecdir}/perf-core/scripts/perl" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 266 | |
| 267 | |
| 268 | INHIBIT_PACKAGE_DEBUG_SPLIT="1" |