dd8a410eaf
The variable 'KERNEL_ARCH' is actually a normalized version of 'ARCH'/'BR2_ARCH'. For example, 'arcle' and 'arceb' both become 'arc', just as all powerpc variants become 'powerpc'. It is presumably called 'KERNEL_ARCH' because the Linux kernel is typically the first place where support for a new architecture is added, and thus is the entity that defines the normalized name. However, the term 'KERNEL_ARCH' can also be interpreted as 'the architecture used by the kernel', which need not be exactly the same as 'the normalized name for a certain arch'. In particular, for cases where a 64-bit architecture is running a 64-bit kernel but 32-bit userspace. Examples include: * aarch64 architecture, with aarch64 kernel and 32-bit (ARM) userspace * x86_64 architecture, with x86_64 kernel and 32-bit (i386) userspace In such cases, the 'architecture used by the kernel' needs to refer to the 64-bit name (aarch64, x86_64), whereas all userspace applications need to refer the, potentially normalized, 32-bit name. This means that there need to be two different variables: KERNEL_ARCH: the architecture used by the kernel NORMALIZED_ARCH: the normalized name for the current userspace architecture At this moment, both will actually have the same content. But a subsequent patch will add basic support for situations described above, in which KERNEL_ARCH may become overwritten to the 64-bit architecture, while NORMALIZED_ARCH needs to remain the same (32-bit) case. This commit replaces use of KERNEL_ARCH where actually the userspace arch is needed. Places that use KERNEL_ARCH in combination with building of kernel modules are not touched. There may be cases where a package builds both a kernel module as userspace, in which case it may need to know about both KERNEL_ARCH and NORMALIZED_ARCH, for the case where they differ. But this is to be fixed on a per-need basis. Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> Reviewed-by: Romain Naour <romain.naour@gmail.com> [Arnout: Also rename BR2_KERNEL_ARCH to BR2_NORMALIZED_ARCH] Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
174 lines
4.8 KiB
Makefile
174 lines
4.8 KiB
Makefile
################################################################################
|
|
#
|
|
# perf
|
|
#
|
|
################################################################################
|
|
|
|
LINUX_TOOLS += perf
|
|
|
|
PERF_DEPENDENCIES = host-flex host-bison
|
|
|
|
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 \
|
|
WERROR=0 \
|
|
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_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.
|
|
define PERF_INSTALL_TARGET_CMDS
|
|
$(TARGET_MAKE_ENV) $(MAKE1) $(PERF_MAKE_FLAGS) \
|
|
-C $(LINUX_DIR)/tools/perf O=$(LINUX_DIR)/tools/perf/ install
|
|
$(RM) -rf $(TARGET_DIR)/usr/libexec/perf-core/scripts/
|
|
$(RM) -rf $(TARGET_DIR)/usr/libexec/perf-core/tests/
|
|
endef
|
|
|
|
define PERF_LINUX_CONFIG_FIXUPS
|
|
$(call KCONFIG_ENABLE_OPT,CONFIG_PERF_EVENTS)
|
|
endef
|