kumquat-buildroot/package/linux-tools/linux-tool-perf.mk.in
Sergey Matyukevich 286928d9b5 package/linux-tools: perf: add host-python3 dependency
Linux kernel commit 00facc760903 ("perf jevents: Switch build to use
jevents.py") switched to auto-generation of arch-specific PMU events
using python script. Now custom PMU events for different platforms of
the selected target architecture are not embedded into perf binary if
an appropriate host python interpreter is not present. In practice it
means that perf is successfully built, but 'perf list pmu' will show
no custom events on a target platform even if those events are supported
and properly defined in tools/perf/pmu-events/arch/<target arch>
directory in the kernel source tree.

Since building host-python3 is not instantaneous, add a config option,
like we have in the kernel for a bunch of host packages, to id=ndicate
that host-python3 is required, and only add the dependency in that case.

Signed-off-by: Sergey Matyukevich <geomatsi@gmail.com>
[yann.morin.1998@free.fr:
  - add BR2_PACKAGE_LINUX_TOOLS_PERF_NEEDS_HOST_PYTHON3
  - extend commit log accordingly
]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2022-09-05 22:11:32 +02:00

183 lines
5.1 KiB
Makefile

################################################################################
#
# perf
#
################################################################################
LINUX_TOOLS += perf
PERF_DEPENDENCIES = host-flex host-bison
ifeq ($(BR2_PACKAGE_LINUX_TOOLS_PERF_NEEDS_HOST_PYTHON3),y)
PERF_DEPENDENCIES += host-python3
endif
ifeq ($(NORMALIZED_ARCH),x86_64)
PERF_ARCH=x86
else
PERF_ARCH=$(NORMALIZED_ARCH)
endif
PERF_MAKE_FLAGS = \
$(LINUX_MAKE_FLAGS) \
JOBS=$(PARALLEL_JOBS) \
ARCH=$(PERF_ARCH) \
DESTDIR=$(TARGET_DIR) \
prefix=/usr \
NO_GTK2=1 \
NO_LIBPERL=1 \
NO_LIBPYTHON=1 \
NO_LIBBIONIC=1
# We need to pass an argument to ld for setting the emulation when
# building for MIPS architecture, otherwise the default one will always
# be used and the compilation for most variants will fail.
ifeq ($(BR2_mips),y)
PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32btsmip"
else ifeq ($(BR2_mipsel),y)
PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32ltsmip"
else ifeq ($(BR2_mips64),y)
ifeq ($(BR2_MIPS_NABI32),y)
PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32btsmipn32"
else
PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf64btsmip"
endif
else ifeq ($(BR2_mips64el),y)
ifeq ($(BR2_MIPS_NABI32),y)
PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32ltsmipn32"
else
PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf64ltsmip"
endif
endif
# The call to backtrace() function fails for ARC, because for some
# reason the unwinder from libgcc returns early. Thus the usage of
# backtrace() should be disabled in perf explicitly: at build time
# backtrace() appears to be available, but it fails at runtime: the
# backtrace will contain only several functions from the top of stack,
# instead of the complete backtrace.
ifeq ($(BR2_arc),y)
PERF_MAKE_FLAGS += NO_BACKTRACE=1
endif
ifeq ($(BR2_PACKAGE_LINUX_TOOLS_PERF_TUI),y)
PERF_DEPENDENCIES += slang
else
PERF_MAKE_FLAGS += NO_NEWT=1 NO_SLANG=1
endif
ifeq ($(BR2_PACKAGE_AUDIT),y)
PERF_DEPENDENCIES += audit
else
PERF_MAKE_FLAGS += NO_LIBAUDIT=1
endif
ifeq ($(BR2_PACKAGE_ZSTD),y)
PERF_DEPENDENCIES += zstd
endif
ifeq ($(BR2_PACKAGE_LIBUNWIND),y)
PERF_DEPENDENCIES += libunwind
else
PERF_MAKE_FLAGS += NO_LIBUNWIND=1
endif
ifeq ($(BR2_PACKAGE_NUMACTL),y)
PERF_DEPENDENCIES += numactl
else
PERF_MAKE_FLAGS += NO_LIBNUMA=1
endif
ifeq ($(BR2_PACKAGE_ELFUTILS),y)
PERF_DEPENDENCIES += elfutils
else
PERF_MAKE_FLAGS += NO_LIBELF=1 NO_DWARF=1
endif
ifeq ($(BR2_PACKAGE_BINUTILS),y)
PERF_DEPENDENCIES += binutils
else
PERF_MAKE_FLAGS += NO_DEMANGLE=1
endif
ifeq ($(BR2_PACKAGE_OPENSSL),y)
PERF_DEPENDENCIES += openssl
else
PERF_MAKE_FLAGS += NO_LIBCRYPTO=1
endif
ifeq ($(BR2_PACKAGE_ZLIB),y)
PERF_DEPENDENCIES += zlib
else
PERF_MAKE_FLAGS += NO_ZLIB=1
endif
# lzma is provided by xz
ifeq ($(BR2_PACKAGE_XZ),y)
PERF_DEPENDENCIES += xz
else
PERF_MAKE_FLAGS += NO_LZMA=1
endif
# We really do not want to build the perf documentation, because it
# has stringent requirement on the documentation generation tools,
# like xmlto and asciidoc), which may be lagging behind on some
# distributions.
# We name it 'GNUmakefile' so that GNU make will use it instead of
# the existing 'Makefile'.
define PERF_DISABLE_DOCUMENTATION
if [ -f $(LINUX_DIR)/tools/perf/Documentation/Makefile ]; then \
printf "%%:\n\t@:\n" >$(LINUX_DIR)/tools/perf/Documentation/GNUmakefile; \
fi
endef
LINUX_TOOLS_POST_PATCH_HOOKS += PERF_DISABLE_DOCUMENTATION
# O must be redefined here to overwrite the one used by Buildroot for
# out of tree build. We build perf in $(LINUX_DIR)/tools/perf/ and not just
# $(LINUX_DIR) so that it isn't built in the root directory of the kernel
# sources.
define PERF_BUILD_CMDS
$(Q)if test ! -f $(LINUX_DIR)/tools/perf/Makefile ; then \
echo "Your kernel version is too old and does not have the perf tool." ; \
echo "At least kernel 2.6.31 must be used." ; \
exit 1 ; \
fi
$(Q)if test "$(BR2_PACKAGE_ELFUTILS)" = "" ; then \
if ! grep -q NO_LIBELF $(LINUX_DIR)/tools/perf/Makefile* ; then \
if ! test -r $(LINUX_DIR)/tools/perf/config/Makefile ; then \
echo "The perf tool in your kernel cannot be built without libelf." ; \
echo "Either upgrade your kernel to >= 3.7, or enable the elfutils package." ; \
exit 1 ; \
fi \
fi \
fi
$(Q)if test "$(BR2_PACKAGE_LINUX_TOOLS_PERF_TUI)" = "y" ; then \
if ! grep -q NO_SLANG $(LINUX_DIR)/tools/perf/Makefile* ; then \
echo "The perf tool in your kernel cannot be build with the TUI." ; \
echo "Either upgrade your kernel to >= 3.10, or disable the TUI." ; \
exit 1 ; \
fi \
fi
$(TARGET_MAKE_ENV) $(MAKE1) $(PERF_MAKE_FLAGS) \
-C $(LINUX_DIR)/tools/perf O=$(LINUX_DIR)/tools/perf/
endef
# After installation, we remove the Perl and Python scripts from the
# target unless BR2_PACKAGE_LINUX_TOOLS_PERF_SCRIPTS is enabled
ifeq ($(BR2_PACKAGE_LINUX_TOOLS_PERF_SCRIPTS),)
define PERF_INSTALL_REMOVE_SCRIPTS
$(RM) -rf $(TARGET_DIR)/usr/libexec/perf-core/scripts/
$(RM) -rf $(TARGET_DIR)/usr/libexec/perf-core/tests/
endef
endif
define PERF_INSTALL_TARGET_CMDS
$(TARGET_MAKE_ENV) $(MAKE1) $(PERF_MAKE_FLAGS) \
-C $(LINUX_DIR)/tools/perf O=$(LINUX_DIR)/tools/perf/ install
$(PERF_INSTALL_REMOVE_SCRIPTS)
endef
define PERF_LINUX_CONFIG_FIXUPS
$(call KCONFIG_ENABLE_OPT,CONFIG_PERF_EVENTS)
endef