perf.bb 20 KB

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