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 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 10 | LICENSE = "GPL-2.0-only" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12 | |
Andrew Geissler | 5082cc7 | 2023-09-11 08:41:39 -0400 | [diff] [blame] | 13 | PACKAGECONFIG ??= "python tui libunwind libtraceevent" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 14 | PACKAGECONFIG[dwarf] = ",NO_DWARF=1" |
Andrew Geissler | 5082cc7 | 2023-09-11 08:41:39 -0400 | [diff] [blame] | 15 | PACKAGECONFIG[perl] = ",NO_LIBPERL=1,perl" |
| 16 | PACKAGECONFIG[python] = ",NO_LIBPYTHON=1,python3 python3-setuptools-native" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 17 | # gui support was added with kernel 3.6.35 |
| 18 | # since 3.10 libnewt was replaced by slang |
| 19 | # to cover a wide range of kernel we add both dependencies |
Joel Stanley | e252c31 | 2017-12-14 15:11:12 +1030 | [diff] [blame] | 20 | PACKAGECONFIG[tui] = ",NO_NEWT=1,libnewt slang" |
| 21 | PACKAGECONFIG[libunwind] = ",NO_LIBUNWIND=1 NO_LIBDW_DWARF_UNWIND=1,libunwind" |
| 22 | PACKAGECONFIG[libnuma] = ",NO_LIBNUMA=1" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 23 | PACKAGECONFIG[bfd] = ",NO_LIBBFD=1" |
Joel Stanley | e252c31 | 2017-12-14 15:11:12 +1030 | [diff] [blame] | 24 | PACKAGECONFIG[systemtap] = ",NO_SDT=1,systemtap" |
| 25 | PACKAGECONFIG[jvmti] = ",NO_JVMTI=1" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 26 | # libaudit support would need scripting to be enabled |
| 27 | PACKAGECONFIG[audit] = ",NO_LIBAUDIT=1,audit" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 28 | PACKAGECONFIG[manpages] = ",,xmlto-native asciidoc-native" |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 29 | PACKAGECONFIG[cap] = ",,libcap" |
Patrick Williams | e760df8 | 2023-05-26 11:10:49 -0500 | [diff] [blame] | 30 | PACKAGECONFIG[libtraceevent] = ",NO_LIBTRACEEVENT=1,libtraceevent" |
Andrew Geissler | b7d2861 | 2020-07-24 16:15:54 -0500 | [diff] [blame] | 31 | # Arm CoreSight |
| 32 | PACKAGECONFIG[coresight] = "CORESIGHT=1,,opencsd" |
Andrew Geissler | 5082cc7 | 2023-09-11 08:41:39 -0400 | [diff] [blame] | 33 | PACKAGECONFIG[pfm4] = ",NO_LIBPFM4=1,libpfm4" |
| 34 | PACKAGECONFIG[babeltrace] = ",NO_LIBBABELTRACE=1,babeltrace" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 35 | |
| 36 | # libunwind is not yet ported for some architectures |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 37 | PACKAGECONFIG:remove:arc = "libunwind" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 38 | PACKAGECONFIG:remove:riscv32 = "libunwind" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 39 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 40 | DEPENDS = " \ |
| 41 | virtual/${MLPREFIX}libc \ |
| 42 | ${MLPREFIX}elfutils \ |
| 43 | ${MLPREFIX}binutils \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 44 | bison-native flex-native xz \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 45 | " |
| 46 | |
| 47 | do_configure[depends] += "virtual/kernel:do_shared_workdir" |
| 48 | |
| 49 | PROVIDES = "virtual/perf" |
| 50 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 51 | inherit linux-kernel-base kernel-arch manpages |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 52 | |
| 53 | # needed for building the tools/perf Python bindings |
Andrew Geissler | 5082cc7 | 2023-09-11 08:41:39 -0400 | [diff] [blame] | 54 | inherit ${@bb.utils.contains('PACKAGECONFIG', 'python', 'python3targetconfig', '', d)} |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 55 | inherit python3-dir |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 56 | export PYTHON_SITEPACKAGES_DIR |
| 57 | |
| 58 | #kernel 3.1+ supports WERROR to disable warnings as errors |
| 59 | export WERROR = "0" |
| 60 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 61 | do_populate_lic[depends] += "virtual/kernel:do_shared_workdir" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 62 | |
| 63 | # needed for building the tools/perf Perl binding |
Andrew Geissler | 5082cc7 | 2023-09-11 08:41:39 -0400 | [diff] [blame] | 64 | include ${@bb.utils.contains('PACKAGECONFIG', 'perl', 'perf-perl.inc', '', d)} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 65 | |
| 66 | inherit kernelsrc |
| 67 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 68 | S = "${WORKDIR}/${BP}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 69 | SPDX_S = "${S}/tools/perf" |
| 70 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 71 | # The LDFLAGS is required or some old kernels fails due missing |
| 72 | # symbols and this is preferred than requiring patches to every old |
| 73 | # supported kernel. |
| 74 | LDFLAGS="-ldl -lutil" |
| 75 | |
| 76 | EXTRA_OEMAKE = '\ |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 77 | V=1 \ |
Andrew Geissler | 5082cc7 | 2023-09-11 08:41:39 -0400 | [diff] [blame] | 78 | VF=1 \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 79 | -C ${S}/tools/perf \ |
| 80 | O=${B} \ |
| 81 | CROSS_COMPILE=${TARGET_PREFIX} \ |
| 82 | ARCH=${ARCH} \ |
| 83 | CC="${CC}" \ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 84 | CCLD="${CC}" \ |
| 85 | LDSHARED="${CC} -shared" \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 86 | AR="${AR}" \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 87 | LD="${LD}" \ |
Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 88 | EXTRA_CFLAGS="-ldw -I${S}" \ |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 89 | YFLAGS='-y --file-prefix-map=${WORKDIR}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}' \ |
Joel Stanley | e252c31 | 2017-12-14 15:11:12 +1030 | [diff] [blame] | 90 | EXTRA_LDFLAGS="${PERF_EXTRA_LDFLAGS}" \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 91 | perfexecdir=${libexecdir} \ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 92 | NO_GTK2=1 \ |
Joel Stanley | e252c31 | 2017-12-14 15:11:12 +1030 | [diff] [blame] | 93 | ${PACKAGECONFIG_CONFARGS} \ |
Patrick Williams | e760df8 | 2023-05-26 11:10:49 -0500 | [diff] [blame] | 94 | PKG_CONFIG=pkg-config \ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 95 | TMPDIR="${B}" \ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 96 | LIBUNWIND_DIR=${STAGING_EXECPREFIXDIR} \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 97 | ' |
| 98 | |
| 99 | EXTRA_OEMAKE += "\ |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 100 | 'DESTDIR=${D}' \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 101 | 'prefix=${prefix}' \ |
| 102 | 'bindir=${bindir}' \ |
| 103 | 'sharedir=${datadir}' \ |
| 104 | 'sysconfdir=${sysconfdir}' \ |
| 105 | 'perfexecdir=${libexecdir}/perf-core' \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 106 | 'ETC_PERFCONFIG=${@os.path.relpath(sysconfdir, prefix)}' \ |
| 107 | 'sharedir=${@os.path.relpath(datadir, prefix)}' \ |
| 108 | 'mandir=${@os.path.relpath(mandir, prefix)}' \ |
| 109 | 'infodir=${@os.path.relpath(infodir, prefix)}' \ |
Andrew Geissler | 5082cc7 | 2023-09-11 08:41:39 -0400 | [diff] [blame] | 110 | ${@bb.utils.contains('PACKAGECONFIG', 'python', 'PYTHON=python3 PYTHON_CONFIG=python3-config', '', d)} \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 111 | " |
| 112 | |
Brad Bishop | d5ae7d9 | 2018-06-14 09:52:03 -0700 | [diff] [blame] | 113 | # During do_configure, we might run a 'make clean'. That often breaks |
| 114 | # when done in parallel, so disable parallelism for do_configure. Note |
| 115 | # that it has to be done this way rather than by passing -j1, since |
| 116 | # perf's build system by default ignores any -j argument, but does |
| 117 | # honour a JOBS variable. |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 118 | EXTRA_OEMAKE:append:task-configure = " JOBS=1" |
Brad Bishop | d5ae7d9 | 2018-06-14 09:52:03 -0700 | [diff] [blame] | 119 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 120 | PERF_SRC ?= "Makefile \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 121 | tools/arch \ |
| 122 | tools/build \ |
| 123 | tools/include \ |
| 124 | tools/lib \ |
| 125 | tools/Makefile \ |
| 126 | tools/perf \ |
| 127 | tools/scripts \ |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 128 | scripts/ \ |
| 129 | arch/${ARCH}/Makefile \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 130 | " |
| 131 | |
Joel Stanley | e252c31 | 2017-12-14 15:11:12 +1030 | [diff] [blame] | 132 | PERF_EXTRA_LDFLAGS = "" |
| 133 | |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 134 | # MIPS N32/N64 |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 135 | PERF_EXTRA_LDFLAGS:mipsarchn32eb = "-m elf32btsmipn32" |
| 136 | PERF_EXTRA_LDFLAGS:mipsarchn32el = "-m elf32ltsmipn32" |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 137 | PERF_EXTRA_LDFLAGS:mipsarchn64eb = "-m elf64btsmip" |
| 138 | PERF_EXTRA_LDFLAGS:mipsarchn64el = "-m elf64ltsmip" |
Joel Stanley | e252c31 | 2017-12-14 15:11:12 +1030 | [diff] [blame] | 139 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 140 | do_compile() { |
| 141 | # Linux kernel build system is expected to do the right thing |
| 142 | unset CFLAGS |
Patrick Williams | b542dec | 2023-06-09 01:26:37 -0500 | [diff] [blame] | 143 | test -e ${S}/tools/lib/traceevent/plugins/Makefile && \ |
| 144 | sed -i -e 's|\$(libdir)/traceevent/plugins|\$(libdir)/traceevent_${KERNEL_VERSION}/plugins|g' ${S}/tools/lib/traceevent/plugins/Makefile |
| 145 | test -e ${S}/tools/perf/Makefile.config && \ |
| 146 | sed -i -e 's|\$(libdir)/traceevent/plugins|\$(libdir)/traceevent_${KERNEL_VERSION}/plugins|g' ${S}/tools/perf/Makefile.config |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 147 | oe_runmake all |
| 148 | } |
| 149 | |
| 150 | do_install() { |
| 151 | # Linux kernel build system is expected to do the right thing |
| 152 | unset CFLAGS |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 153 | oe_runmake install |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 154 | # we are checking for this make target to be compatible with older perf versions |
Andrew Geissler | 5082cc7 | 2023-09-11 08:41:39 -0400 | [diff] [blame] | 155 | if ${@bb.utils.contains('PACKAGECONFIG', 'python', 'true', 'false', d)} && grep -q install-python_ext ${S}/tools/perf/Makefile*; then |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 156 | oe_runmake DESTDIR=${D} install-python_ext |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 157 | if [ -e ${D}${libdir}/python*/site-packages/perf-*/SOURCES.txt ]; then |
| 158 | sed -i -e 's#${WORKDIR}##g' ${D}${libdir}/python*/site-packages/perf-*/SOURCES.txt |
| 159 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 160 | fi |
| 161 | } |
| 162 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 163 | do_configure[prefuncs] += "copy_perf_source_from_kernel" |
| 164 | python copy_perf_source_from_kernel() { |
| 165 | sources = (d.getVar("PERF_SRC") or "").split() |
| 166 | src_dir = d.getVar("STAGING_KERNEL_DIR") |
| 167 | dest_dir = d.getVar("S") |
| 168 | bb.utils.mkdirhier(dest_dir) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 169 | bb.utils.prunedir(dest_dir) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 170 | for s in sources: |
| 171 | src = oe.path.join(src_dir, s) |
| 172 | dest = oe.path.join(dest_dir, s) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 173 | if not os.path.exists(src): |
| 174 | bb.fatal("Path does not exist: %s. Maybe PERF_SRC does not match the kernel version." % src) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 175 | if os.path.isdir(src): |
| 176 | oe.path.copyhardlinktree(src, dest) |
| 177 | else: |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 178 | src_path = os.path.dirname(s) |
| 179 | os.makedirs(os.path.join(dest_dir,src_path),exist_ok=True) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 180 | bb.utils.copyfile(src, dest) |
| 181 | } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 182 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 183 | do_configure:prepend () { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 184 | # If building a multlib based perf, the incorrect library path will be |
| 185 | # detected by perf, since it triggers via: ifeq ($(ARCH),x86_64). In a 32 bit |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 186 | # build, with a 64 bit multilib, the arch won't match and the detection of a |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 187 | # 64 bit build (and library) are not exected. To ensure that libraries are |
| 188 | # installed to the correct location, we can use the weak assignment in the |
| 189 | # config/Makefile. |
| 190 | # |
| 191 | # Also need to relocate .config-detected to $(OUTPUT)/config-detected |
| 192 | # for kernel sources that do not already do this |
| 193 | # as two builds (e.g. perf and lib32-perf from mutlilib can conflict |
| 194 | # with each other if its in the shared source directory |
| 195 | # |
| 196 | if [ -e "${S}/tools/perf/config/Makefile" ]; then |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 197 | perfconfig="${S}/tools/perf/config/Makefile" |
| 198 | fi |
| 199 | if [ -e "${S}/tools/perf/Makefile.config" ]; then |
| 200 | perfconfig="${S}/tools/perf/Makefile.config" |
| 201 | fi |
| 202 | if [ -n "${perfconfig}" ]; then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 203 | # Match $(prefix)/$(lib) and $(prefix)/lib |
| 204 | sed -i -e 's,^libdir = \($(prefix)/.*lib\),libdir ?= \1,' \ |
| 205 | -e 's,^perfexecdir = \(.*\),perfexecdir ?= \1,' \ |
| 206 | -e 's,\ .config-detected, $(OUTPUT)/config-detected,g' \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 207 | ${perfconfig} |
| 208 | fi |
| 209 | # The man pages installation is "$(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)" |
| 210 | # in ${S}/tools/perf/Documentation/Makefile, if the mandir set to '?=', it |
| 211 | # will use the relative path 'share/man', in the way it will resulting in |
| 212 | # incorrect installation for man pages. |
| 213 | if [ -e "${S}/tools/perf/Documentation/Makefile" ]; then |
| 214 | sed -i 's,^mandir?=,mandir:=,' ${S}/tools/perf/Documentation/Makefile |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 215 | fi |
| 216 | if [ -e "${S}/tools/perf/Makefile.perf" ]; then |
| 217 | sed -i -e 's,\ .config-detected, $(OUTPUT)/config-detected,g' \ |
| 218 | ${S}/tools/perf/Makefile.perf |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 219 | sed -i -e "s,prefix='\$(DESTDIR_SQ)/usr'$,prefix='\$(DESTDIR_SQ)/usr' --install-lib='\$(PYTHON_SITEPACKAGES_DIR)' --root='\$(DESTDIR)',g" \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 220 | ${S}/tools/perf/Makefile.perf |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 221 | # backport https://github.com/torvalds/linux/commit/e4ffd066ff440a57097e9140fa9e16ceef905de8 |
| 222 | sed -i -e 's,\($(Q)$(SHELL) .$(arch_errno_tbl).\) $(CC) $(arch_errno_hdr_dir),\1 $(firstword $(CC)) $(arch_errno_hdr_dir),g' \ |
| 223 | ${S}/tools/perf/Makefile.perf |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 224 | fi |
| 225 | 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] | 226 | ${S}/tools/perf/Makefile* |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 227 | |
| 228 | if [ -e "${S}/tools/build/Makefile.build" ]; then |
| 229 | sed -i -e 's,\ .config-detected, $(OUTPUT)/config-detected,g' \ |
| 230 | ${S}/tools/build/Makefile.build |
| 231 | fi |
| 232 | |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 233 | # start reproducibility substitutions |
| 234 | if [ -e "${S}/tools/perf/Makefile.config" ]; then |
| 235 | # The following line in the Makefle: |
| 236 | # override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON_AUTO)) |
| 237 | # "PYTHON" / "PYTHON_AUTO" have the full path as part of the variable. We've |
| 238 | # ensure that the environment is setup and we do not need the full path to be |
| 239 | # captured, since the symbol gets built into the executable, making it not |
| 240 | # reproducible. |
| 241 | sed -i -e 's,$(call get-executable-or-default\,PYTHON\,$(PYTHON_AUTO)),$(notdir $(call get-executable-or-default\,PYTHON\,$(PYTHON_AUTO))),g' \ |
| 242 | ${S}/tools/perf/Makefile.config |
Patrick Williams | db4c27e | 2022-08-05 08:10:29 -0500 | [diff] [blame] | 243 | # The same line is in older releases, but looking explicitly for Python 2 |
| 244 | sed -i -e 's,$(call get-executable-or-default\,PYTHON\,$(PYTHON2)),$(notdir $(call get-executable-or-default\,PYTHON\,$(PYTHON2))),g' \ |
| 245 | ${S}/tools/perf/Makefile.config |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 246 | |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 247 | # likewise with this substitution. Kernels with commit 18f2967418d031a39 |
| 248 | # [perf tools: Use Python devtools for version autodetection rather than runtime] |
| 249 | # need this substitution for reproducibility. |
| 250 | 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' \ |
| 251 | ${S}/tools/perf/Makefile.config |
| 252 | |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 253 | # The following line: |
| 254 | # srcdir_SQ = $(patsubst %tools/perf,tools/perf,$(subst ','\'',$(srcdir))), |
| 255 | # Captures the full src path of perf, which of course makes it not |
| 256 | # reproducible. We really only need the relative location 'tools/perf', so we |
| 257 | # change the Makefile line to remove everything before 'tools/perf' |
| 258 | sed -i -e "s%srcdir_SQ = \$(subst ','\\\'',\$(srcdir))%srcdir_SQ = \$(patsubst \%tools/perf,tools/perf,\$(subst ','\\\'',\$(srcdir)))%g" \ |
| 259 | ${S}/tools/perf/Makefile.config |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 260 | # Avoid hardcoded path to python-native |
| 261 | sed -i -e 's#\(PYTHON_WORD := \)$(call shell-wordify,$(PYTHON))#\1 python3#g' \ |
| 262 | ${S}/tools/perf/Makefile.config |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 263 | fi |
| 264 | if [ -e "${S}/tools/perf/tests/Build" ]; then |
| 265 | # OUTPUT is the full path, we have python on the path so we remove it from the |
| 266 | # definition. This is captured in the perf binary, so breaks reproducibility |
| 267 | sed -i -e 's,PYTHONPATH="BUILD_STR($(OUTPUT)python)",PYTHONPATH="BUILD_STR(python)",g' \ |
| 268 | ${S}/tools/perf/tests/Build |
| 269 | fi |
| 270 | if [ -e "${S}/tools/perf/util/Build" ]; then |
| 271 | # To avoid bison generating #ifdefs that have captured paths, we make sure |
| 272 | # all the calls have YFLAGS, which contains prefix mapping information. |
| 273 | sed -i -e 's,$(BISON),$(BISON) $(YFLAGS),g' ${S}/tools/perf/util/Build |
| 274 | fi |
| 275 | if [ -e "${S}/scripts/Makefile.host" ]; then |
| 276 | # To avoid yacc (bison) generating #ifdefs that have captured paths, we make sure |
| 277 | # all the calls have YFLAGS, which contains prefix mapping information. |
| 278 | sed -i -e 's,$(YACC),$(YACC) $(YFLAGS),g' ${S}/scripts/Makefile.host |
| 279 | fi |
| 280 | if [ -e "${S}/tools/perf/pmu-events/Build" ]; then |
| 281 | target='$(OUTPUT)pmu-events/pmu-events.c $(V)' |
| 282 | replacement1='$(OUTPUT)pmu-events/pmu-events.c $(V)\n' |
| 283 | replacement2='\t$(srctree)/sort-pmuevents.py $(OUTPUT)pmu-events/pmu-events.c $(OUTPUT)pmu-events/pmu-events.c.new\n' |
| 284 | replacement3='\tcp $(OUTPUT)pmu-events/pmu-events.c.new $(OUTPUT)pmu-events/pmu-events.c' |
| 285 | sed -i -e "s,$target,$replacement1$replacement2$replacement3,g" \ |
| 286 | "${S}/tools/perf/pmu-events/Build" |
| 287 | fi |
Patrick Williams | 864cc43 | 2023-02-09 14:54:44 -0600 | [diff] [blame] | 288 | if [ -e "${S}/tools/perf/pmu-events/jevents.py" ]; then |
| 289 | sed -i -e "s#os.scandir(path)#sorted(os.scandir(path), key=lambda e: e.name)#g" \ |
| 290 | "${S}/tools/perf/pmu-events/jevents.py" |
| 291 | fi |
Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 292 | if [ -e "${S}/tools/perf/arch/arm64/Makefile" ]; then |
| 293 | sed -i 's,sysdef := $(srctree)/,sysdef := ,' ${S}/tools/perf/arch/arm64/Makefile |
| 294 | sed -i 's,$(incpath) $(sysdef),$(incpath) $(srctree)/$(sysdef) $(sysdef),' ${S}/tools/perf/arch/arm64/Makefile |
| 295 | fi |
| 296 | if [ -e "${S}/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl" ]; then |
| 297 | if ! grep -q input_rel ${S}/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl; then |
| 298 | sed -i 's,input=$4,input=$4\ninput_rel=$5,' ${S}/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl |
| 299 | fi |
| 300 | sed -i 's,#include \\"\$input\\",#include \\"\$input_rel\\",' ${S}/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl |
| 301 | fi |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 302 | # end reproducibility substitutions |
| 303 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 304 | # We need to ensure the --sysroot option in CC is preserved |
| 305 | if [ -e "${S}/tools/perf/Makefile.perf" ]; then |
| 306 | sed -i 's,CC = $(CROSS_COMPILE)gcc,#CC,' ${S}/tools/perf/Makefile.perf |
| 307 | 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] | 308 | sed -i 's,LD = $(CROSS_COMPILE)ld,#LD,' ${S}/tools/perf/Makefile.perf |
Patrick Williams | e760df8 | 2023-05-26 11:10:49 -0500 | [diff] [blame] | 309 | sed -i 's,PKG_CONFIG = $(CROSS_COMPILE)pkg-config,#PKG_CONFIG,' ${S}/tools/perf/Makefile.perf |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 310 | fi |
| 311 | if [ -e "${S}/tools/lib/api/Makefile" ]; then |
| 312 | sed -i 's,CC = $(CROSS_COMPILE)gcc,#CC,' ${S}/tools/lib/api/Makefile |
| 313 | 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] | 314 | 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] | 315 | fi |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 316 | if [ -e "${S}/tools/lib/subcmd/Makefile" ]; then |
| 317 | sed -i 's,CC = $(CROSS_COMPILE)gcc,#CC,' ${S}/tools/lib/subcmd/Makefile |
| 318 | sed -i 's,AR = $(CROSS_COMPILE)ar,#AR,' ${S}/tools/lib/subcmd/Makefile |
| 319 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 320 | if [ -e "${S}/tools/perf/config/feature-checks/Makefile" ]; then |
| 321 | sed -i 's,CC := $(CROSS_COMPILE)gcc -MD,CC += -MD,' ${S}/tools/perf/config/feature-checks/Makefile |
| 322 | fi |
| 323 | if [ -e "${S}/tools/build/Makefile.feature" ]; then |
| 324 | sed -i 's,CFLAGS=,CC="\$(CC)" CFLAGS=,' ${S}/tools/build/Makefile.feature |
| 325 | fi |
Andrew Geissler | 5082cc7 | 2023-09-11 08:41:39 -0400 | [diff] [blame] | 326 | # The libperl feature check produces fatal warnings due to -Werror being |
| 327 | # used, silence enough errors that the check passes. |
| 328 | sed -i 's/\(FLAGS_PERL_EMBED=.*\)/\1 -Wno-error=unused-function -Wno-error=attributes/' ${S}/tools/build/feature/Makefile |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 329 | |
| 330 | # 3.17-rc1+ has a include issue for arm/powerpc. Temporarily sed in the appropriate include |
| 331 | if [ -e "${S}/tools/perf/arch/$ARCH/util/skip-callchain-idx.c" ]; then |
| 332 | 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 |
| 333 | fi |
| 334 | if [ -e "${S}/tools/perf/arch/arm/util/unwind-libunwind.c" ] && [ -e "${S}/tools/perf/arch/arm/tests/dwarf-unwind.c" ]; then |
| 335 | 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 |
| 336 | 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 |
| 337 | fi |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 338 | |
| 339 | # use /usr/bin/env instead of version specific python |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 340 | for s in `find ${S}/tools/perf/ -name '*.py'` `find ${S}/scripts/ -name 'bpf_helpers_doc.py'`; do |
| 341 | sed -i -e "s,#!.*python.*,#!${USRBINPATH}/env python3," ${s} |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 342 | done |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 343 | |
| 344 | # unistd.h can be out of sync between libc-headers and the captured version in the perf source |
| 345 | # so we copy it from the sysroot unistd.h to the perf unistd.h |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 346 | install -D -m0644 ${STAGING_INCDIR}/asm-generic/unistd.h ${S}/tools/include/uapi/asm-generic/unistd.h |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 347 | install -D -m0644 ${STAGING_INCDIR}/asm-generic/unistd.h ${S}/include/uapi/asm-generic/unistd.h |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 348 | |
| 349 | # the fetcher is inhibited by the 'inherit kernelsrc', so we do a quick check and |
| 350 | # copy for a helper script we need |
| 351 | for p in $(echo ${FILESPATH} | tr ':' '\n'); do |
| 352 | if [ -e $p/sort-pmuevents.py ]; then |
| 353 | cp $p/sort-pmuevents.py ${S} |
| 354 | fi |
| 355 | done |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 356 | } |
| 357 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 358 | python do_package:prepend() { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 359 | d.setVar('PKGV', d.getVar("KERNEL_VERSION").split("-")[0]) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 360 | } |
| 361 | |
| 362 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
| 363 | |
| 364 | |
| 365 | PACKAGES =+ "${PN}-archive ${PN}-tests ${PN}-perl ${PN}-python" |
| 366 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 367 | RDEPENDS:${PN} += "elfutils bash" |
| 368 | RDEPENDS:${PN}-archive =+ "bash" |
| 369 | RDEPENDS:${PN}-python =+ "bash python3 python3-modules ${@bb.utils.contains('PACKAGECONFIG', 'audit', 'audit-python', '', d)}" |
| 370 | RDEPENDS:${PN}-perl =+ "bash perl perl-modules" |
| 371 | RDEPENDS:${PN}-tests =+ "python3 bash" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 372 | |
Andrew Geissler | 5082cc7 | 2023-09-11 08:41:39 -0400 | [diff] [blame] | 373 | RSUGGESTS:${PN} += "${PN}-archive ${PN}-tests \ |
| 374 | ${@bb.utils.contains('PACKAGECONFIG', 'perl', '${PN}-perl', '', d)} \ |
| 375 | ${@bb.utils.contains('PACKAGECONFIG', 'python', '${PN}-python', '', d)} \ |
| 376 | " |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 377 | FILES_SOLIBSDEV = "" |
Patrick Williams | b542dec | 2023-06-09 01:26:37 -0500 | [diff] [blame] | 378 | FILES:${PN} += "${libexecdir}/perf-core ${exec_prefix}/libexec/perf-core ${libdir}/traceevent* ${libdir}/libperf-jvmti.so" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 379 | FILES:${PN}-archive = "${libdir}/perf/perf-core/perf-archive" |
| 380 | FILES:${PN}-tests = "${libdir}/perf/perf-core/tests ${libexecdir}/perf-core/tests" |
| 381 | FILES:${PN}-python = " \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 382 | ${PYTHON_SITEPACKAGES_DIR} \ |
| 383 | ${libexecdir}/perf-core/scripts/python \ |
| 384 | " |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 385 | FILES:${PN}-perl = "${libexecdir}/perf-core/scripts/perl" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 386 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 387 | DEBUG_OPTIMIZATION:append = " -Wno-error=maybe-uninitialized" |
Patrick Williams | 864cc43 | 2023-02-09 14:54:44 -0600 | [diff] [blame] | 388 | |
| 389 | PACKAGESPLITFUNCS =+ "perf_fix_sources" |
| 390 | |
| 391 | perf_fix_sources () { |
| 392 | for f in util/parse-events-flex.h util/parse-events-flex.c util/pmu-flex.c \ |
Andrew Geissler | 8f84068 | 2023-07-21 09:09:43 -0500 | [diff] [blame] | 393 | util/pmu-flex.h util/expr-flex.h util/expr-flex.c; do |
Patrick Williams | 864cc43 | 2023-02-09 14:54:44 -0600 | [diff] [blame] | 394 | f=${PKGD}/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}/$f |
| 395 | if [ -e $f ]; then |
| 396 | sed -i -e 's#${S}/##g' $f |
| 397 | fi |
| 398 | done |
| 399 | } |