summaryrefslogtreecommitdiff
path: root/linux/linux-tool-perf.mk
diff options
context:
space:
mode:
authorYann E. MORIN <yann.morin.1998@free.fr>2016-09-06 16:29:14 +0200
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>2016-09-22 12:32:34 +0200
commit20b144666909e5173d8531b3bb0e179d2254e6d7 (patch)
treea685a5da4658dff6991d2324a16b9a89efb5d96f /linux/linux-tool-perf.mk
parentd5f041c3308ebb7dfa1ea3a57ea74cec2678e130 (diff)
linux/tools: make it a real, separate package
The kernel source tree also contains the sources for various userland tools, of which cpupower, perf or selftests. Currently, we have support for building those tools as part of the kernel build procedure. This looked the correct thing to do so far, because, well, they *are* part of the kernel source tree and some really have to be the same version as the kernel that will run. However, this is causing quite a non-trivial-to-break circular dependency in some configurations. For example, this defconfig fails to build (similar to the one reported by Paul): BR2_arm=y BR2_cortex_a7=y BR2_ARM_FPU_NEON_VFPV4=y BR2_TOOLCHAIN_EXTERNAL=y BR2_INIT_SYSTEMD=y BR2_LINUX_KERNEL=y BR2_LINUX_KERNEL_CUSTOM_GIT=y BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/raspberrypi/linux.git" BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="26f3b72a9c049be10e6af196252283e1f6ab9d1f" BR2_LINUX_KERNEL_DEFCONFIG="bcm2709" BR2_PACKAGE_LINUX_TOOLS_CPUPOWER=y BR2_PACKAGE_CRYPTODEV=y BR2_PACKAGE_OPENSSL=y BR2_PACKAGE_LIBCURL=y This causes a circular dependency, as explained by Thomas: - When libcurl is enabled, systemd depends on it - When OpenSSL is enabled, obviously, will use it for SSL support - When cryptodev-linux is enabled, OpenSSL will depend on it to use crypto accelerators supported in the kernel via cryptodev-linux. - cryptodev-linux being a kernel module, it depends on linux - linux by itself (the kernel) does not depend on pciutils, but the linux tool "cpupower" (managed in linux-tool-cpupower) depends on pciutils - pciutils depends on udev when available - udev is provided by systemd. And indeed, during the build, we can see that make warns (it's only reported as a *warning*, not as an actual error): [...] make[1]: Circular /home/ymorin/dev/buildroot/O/build/openssl-1.0.2h/.stamp_configured <- cryptodev-linux dependency dropped. >>> openssl 1.0.2h Downloading [...] So the build fails later on, when openssl is actually built: eng_cryptodev.c:57:31: fatal error: crypto/cryptodev.h: No such file or directory compilation terminated. <builtin>: recipe for target 'eng_cryptodev.o' failed Furthermore, graph-depends also detects the circular dependency, but treats it as a hard-error: Recursion detected for : cryptodev-linux which is a dependency of: openssl which is a dependency of: libcurl which is a dependency of: systemd which is a dependency of: udev which is a dependency of: pciutils which is a dependency of: linux which is a dependency of: cryptodev-linux Makefile:738: recipe for target 'graph-depends' failed Of course, there is no way to break the loop without losing functionality in either one of the involved packages *and* keep our infrastructure and packages as-is. The only solution is to break the loop at the linux-tools level, by moving them away into their own package, so that the linux package will no longer have the opportunity to depend on another package via a dependency of one the tools. All three linux tools are thus moved away to their own package. The package infrastructure only knows of three types of packages: those in package/ , in boot/ , in toolchain/ and the one in linux/ . So we create that new linux-tools package in package/ so that we don't have to fiddle with yet another special case in the infra. Still, we want its configure options to appear in the kernel's sub-menu. So, we make it a prompt-less package, with only the tools visible as options of that package, but without the usual dependency on their master symbol; they only depend on the Linux kernel. Furthermore, because the kernel is such a huge pile of code, we would not be very happy to extract it a second time just for the sake of a few tools. We can't extract only the tools/ sub-directory from the kernel source either, because some tools have hard-coded path to includes from the kernel (arch and stuff). Instead, we just use the linux source tree as our own build tree, and ensure the linux tree is extracted and patched before linux-tools is configured and built. Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Cc: Paul Ashford <paul.ashford@zurria.co.uk> [Thomas: - fix typo #(@D) -> $(@D) - fix the inclusion of the per-tool .mk files.] Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Diffstat (limited to 'linux/linux-tool-perf.mk')
-rw-r--r--linux/linux-tool-perf.mk134
1 files changed, 0 insertions, 134 deletions
diff --git a/linux/linux-tool-perf.mk b/linux/linux-tool-perf.mk
deleted file mode 100644
index 8143474b0..000000000
--- a/linux/linux-tool-perf.mk
+++ /dev/null
@@ -1,134 +0,0 @@
-################################################################################
-#
-# perf
-#
-################################################################################
-
-LINUX_TOOLS += perf
-
-PERF_DEPENDENCIES = host-flex host-bison
-
-ifeq ($(KERNEL_ARCH),x86_64)
-PERF_ARCH=x86
-else
-PERF_ARCH=$(KERNEL_ARCH)
-endif
-
-PERF_MAKE_FLAGS = \
- $(LINUX_MAKE_FLAGS) \
- JOBS=$(PARALLEL_JOBS) \
- ARCH=$(PERF_ARCH) \
- DESTDIR=$(TARGET_DIR) \
- prefix=/usr \
- WERROR=0 \
- NO_LIBAUDIT=1 \
- NO_NEWT=1 \
- NO_GTK2=1 \
- NO_LIBPERL=1 \
- NO_LIBPYTHON=1 \
- NO_LIBBIONIC=1
-
-# We need to pass an argument to ld for setting the endianness when
-# building it for MIPS architecture, otherwise the default one will
-# always be used (which is big endian) and the compilation for little
-# endian will always fail showing an error like this one:
-# LD foo.o
-# mips-linux-gnu-ld: foo.o: compiled for a little endian system and
-# target is big endian
-ifeq ($(BR2_mips)$(BR2_mips64),y)
-PERF_MAKE_FLAGS += LD="$(TARGET_LD) -EB"
-else ifeq ($(BR2_mipsel)$(BR2_mips64el),y)
-PERF_MAKE_FLAGS += LD="$(TARGET_LD) -EL"
-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_SLANG),y)
-PERF_DEPENDENCIES += slang
-else
-PERF_MAKE_FLAGS += NO_SLANG=1
-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_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 $(@D)/tools/perf/Documentation/Makefile ]; then \
- printf "%%:\n\t@:\n" >$(@D)/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 $(@D)/tools/perf/ and not just
-# $(@D) so that it isn't built in the root directory of the kernel
-# sources.
-define PERF_BUILD_CMDS
- $(Q)if test ! -f $(@D)/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 $(@D)/tools/perf/Makefile* ; then \
- if ! test -r $(@D)/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
- $(TARGET_MAKE_ENV) $(MAKE1) $(PERF_MAKE_FLAGS) \
- -C $(@D)/tools/perf O=$(@D)/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 $(@D)/tools/perf O=$(@D)/tools/perf/ install
- $(RM) -rf $(TARGET_DIR)/usr/libexec/perf-core/scripts/
- $(RM) -rf $(TARGET_DIR)/usr/libexec/perf-core/tests/
-endef