From 8fe6d3de5c934573def22938230b3dc6a5519f13 Mon Sep 17 00:00:00 2001 From: Matthias Reichl Date: Mon, 5 Feb 2018 13:50:53 +0100 Subject: [PATCH 1/6] elfutils: update to 0.170 Signed-off-by: Matthias Reichl --- packages/devel/elfutils/package.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/devel/elfutils/package.mk b/packages/devel/elfutils/package.mk index c5a7e7bef4..02f68da329 100644 --- a/packages/devel/elfutils/package.mk +++ b/packages/devel/elfutils/package.mk @@ -17,8 +17,8 @@ ################################################################################ PKG_NAME="elfutils" -PKG_VERSION="0.168" -PKG_SHA256="b88d07893ba1373c7dd69a7855974706d05377766568a7d9002706d5de72c276" +PKG_VERSION="0.170" +PKG_SHA256="1f844775576b79bdc9f9c717a50058d08620323c1e935458223a12f249c9e066" PKG_ARCH="any" PKG_LICENSE="GPL" PKG_SITE="https://sourceware.org/elfutils/" From 032cf5a44b4bbb763d627f0b5322fb6b09a93088 Mon Sep 17 00:00:00 2001 From: Matthias Reichl Date: Mon, 5 Feb 2018 11:34:42 +0100 Subject: [PATCH 2/6] elfutils: install libdwfl, libebl and version.h to sysroot Needed by perf to parse and display debug symbols. Signed-off-by: Matthias Reichl --- packages/devel/elfutils/package.mk | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/devel/elfutils/package.mk b/packages/devel/elfutils/package.mk index 02f68da329..b005f6d9b4 100644 --- a/packages/devel/elfutils/package.mk +++ b/packages/devel/elfutils/package.mk @@ -45,14 +45,21 @@ make_target() { make V=1 -C libelf libelf.a make V=1 -C libebl libebl.a make V=1 -C libdwfl libdwfl.a + make V=1 -C libdwelf libdwelf.a make V=1 -C libdw libdw.a } makeinstall_target() { make DESTDIR="$SYSROOT_PREFIX" -C libelf install-includeHEADERS install-pkgincludeHEADERS + make DESTDIR="$SYSROOT_PREFIX" -C libdwfl install-pkgincludeHEADERS make DESTDIR="$SYSROOT_PREFIX" -C libdw install-includeHEADERS install-pkgincludeHEADERS mkdir -p $SYSROOT_PREFIX/usr/lib cp libelf/libelf.a $SYSROOT_PREFIX/usr/lib + cp libebl/libebl.a $SYSROOT_PREFIX/usr/lib + cp libdwfl/libdwfl.a $SYSROOT_PREFIX/usr/lib cp libdw/libdw.a $SYSROOT_PREFIX/usr/lib + + mkdir -p $SYSROOT_PREFIX/usr/include/elfutils + cp version.h $SYSROOT_PREFIX/usr/include/elfutils } From 088e6a765e4a87966333300bc6ba0ef9d3c49a5b Mon Sep 17 00:00:00 2001 From: Matthias Reichl Date: Mon, 5 Feb 2018 11:29:08 +0100 Subject: [PATCH 3/6] binutils: build libiberty for target Libiberty is needed by perf to demangle symbols. Signed-off-by: Matthias Reichl --- packages/devel/binutils/package.mk | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/packages/devel/binutils/package.mk b/packages/devel/binutils/package.mk index a0cd2d844b..d0aa389917 100644 --- a/packages/devel/binutils/package.mk +++ b/packages/devel/binutils/package.mk @@ -24,6 +24,7 @@ PKG_LICENSE="GPL" PKG_SITE="http://www.gnu.org/software/binutils/" PKG_URL="http://ftpmirror.gnu.org/binutils/$PKG_NAME-$PKG_VERSION.tar.gz" PKG_DEPENDS_HOST="ccache:host bison:host flex:host linux:host" +PKG_DEPENDS_TARGET="toolchain binutils:host" PKG_SECTION="toolchain/devel" PKG_SHORTDESC="binutils: A GNU collection of binary utilities" PKG_LONGDESC="The GNU binutils are utilities of use when dealing with object files. the packages includes ld - the GNU linker, as - the GNU assembler, addr2line - converts addresses into filenames and line numbers, ar - a utility for creating, modifying and extracting from archives, c++filt - filter to demangle encoded C++ symbols, gprof - displays profiling information, nlmconv - converts object code into an NLM, nm - lists symbols from object files, objcopy - Copys and translates object files, objdump - displays information from object files, ranlib - generates an index to the contents of an archive, readelf - displays information from any ELF format object file, size - lists the section sizes of an object or archive file, strings - lists printable strings from files, strip - discards symbols as well as windres - a compiler for Windows resource files." @@ -44,6 +45,21 @@ PKG_CONFIGURE_OPTS_HOST="--target=$TARGET_NAME \ --enable-lto \ --disable-nls" +PKG_CONFIGURE_OPTS_TARGET="--target=$TARGET_NAME \ + --with-sysroot=$SYSROOT_PREFIX \ + --with-lib-path=$SYSROOT_PREFIX/lib:$SYSROOT_PREFIX/usr/lib \ + --without-ppl \ + --without-cloog \ + --disable-werror \ + --disable-multilib \ + --disable-libada \ + --disable-libssp \ + --disable-plugins \ + --disable-gold \ + --disable-ld \ + --disable-lto \ + --disable-nls" + pre_configure_host() { unset CPPFLAGS unset CFLAGS @@ -60,3 +76,13 @@ makeinstall_host() { cp -v ../include/libiberty.h $SYSROOT_PREFIX/usr/include make install } + +make_target() { + make configure-host + make -C libiberty libiberty.a +} + +makeinstall_target() { + mkdir -p $SYSROOT_PREFIX/usr/lib + cp libiberty/libiberty.a $SYSROOT_PREFIX/usr/lib +} From dbc790f4d165dc35f43d8db79f39d833895485a4 Mon Sep 17 00:00:00 2001 From: Matthias Reichl Date: Mon, 5 Feb 2018 11:37:16 +0100 Subject: [PATCH 4/6] libunwind: new package Signed-off-by: Matthias Reichl --- packages/debug/libunwind/package.mk | 31 +++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 packages/debug/libunwind/package.mk diff --git a/packages/debug/libunwind/package.mk b/packages/debug/libunwind/package.mk new file mode 100644 index 0000000000..9384798aa6 --- /dev/null +++ b/packages/debug/libunwind/package.mk @@ -0,0 +1,31 @@ +################################################################################ +# This file is part of LibreELEC - https://libreelec.tv +# Copyright (C) 2018-present Team LibreELEC +# +# LibreELEC is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# LibreELEC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with LibreELEC. If not, see . +################################################################################ + +PKG_NAME="libunwind" +PKG_VERSION="1.2.1" +PKG_SHA256="3f3ecb90e28cbe53fba7a4a27ccce7aad188d3210bb1964a923a731a27a75acb" +PKG_ARCH="any" +PKG_LICENSE="GPL" +PKG_SITE="http://www.nongnu.org/libunwind/" +PKG_URL="http://download.savannah.nongnu.org/releases/libunwind/libunwind-${PKG_VERSION}.tar.gz" +PKG_SECTION="debug" +PKG_SHORTDESC="library to determine the call-chain of a program" +PKG_LONGDESC="library to determine the call-chain of a program" + +PKG_CONFIGURE_OPTS_TARGET="--enable-static \ + --disable-shared" From 65490c26dd6e6137b327fbbebc2b22981e5219e4 Mon Sep 17 00:00:00 2001 From: Matthias Reichl Date: Mon, 5 Feb 2018 15:35:31 +0100 Subject: [PATCH 5/6] linux: move config file selection out of post_patch Also prefix KERNEL_CFG_FILE/CFG_FILE with PKG_ Signed-off-by: Matthias Reichl --- packages/linux/package.mk | 44 +++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/packages/linux/package.mk b/packages/linux/package.mk index 24a694d509..e621e1d3e4 100644 --- a/packages/linux/package.mk +++ b/packages/linux/package.mk @@ -29,6 +29,27 @@ PKG_SHORTDESC="linux26: The Linux kernel 2.6 precompiled kernel binary image and PKG_LONGDESC="This package contains a precompiled kernel image and the modules." PKG_IS_KERNEL_PKG="yes" +PKG_CFG_FILE="$PKG_NAME.${TARGET_PATCH_ARCH:-$TARGET_ARCH}.conf" +if [ -n "$DEVICE" -a -f $PROJECT_DIR/$PROJECT/devices/$DEVICE/$PKG_NAME/$PKG_VERSION/$PKG_CFG_FILE ]; then + PKG_KERNEL_CFG_FILE=$PROJECT_DIR/$PROJECT/devices/$DEVICE/$PKG_NAME/$PKG_VERSION/$PKG_CFG_FILE +elif [ -n "$DEVICE" -a -f $PROJECT_DIR/$PROJECT/devices/$DEVICE/$PKG_NAME/$LINUX/$PKG_CFG_FILE ]; then + PKG_KERNEL_CFG_FILE=$PROJECT_DIR/$PROJECT/devices/$DEVICE/$PKG_NAME/$LINUX/$PKG_CFG_FILE +elif [ -n "$DEVICE" -a -f $PROJECT_DIR/$PROJECT/devices/$DEVICE/$PKG_NAME/$PKG_CFG_FILE ]; then + PKG_KERNEL_CFG_FILE=$PROJECT_DIR/$PROJECT/devices/$DEVICE/$PKG_NAME/$PKG_CFG_FILE +elif [ -f $PROJECT_DIR/$PROJECT/$PKG_NAME/$PKG_VERSION/$PKG_CFG_FILE ]; then + PKG_KERNEL_CFG_FILE=$PROJECT_DIR/$PROJECT/$PKG_NAME/$PKG_VERSION/$PKG_CFG_FILE +elif [ -f $PROJECT_DIR/$PROJECT/$PKG_NAME/$LINUX/$PKG_CFG_FILE ]; then + PKG_KERNEL_CFG_FILE=$PROJECT_DIR/$PROJECT/$PKG_NAME/$LINUX/$PKG_CFG_FILE +elif [ -f $PROJECT_DIR/$PROJECT/$PKG_NAME/$PKG_CFG_FILE ]; then + PKG_KERNEL_CFG_FILE=$PROJECT_DIR/$PROJECT/$PKG_NAME/$PKG_CFG_FILE +elif [ -f $PKG_DIR/config/$PKG_VERSION/$PKG_CFG_FILE ]; then + PKG_KERNEL_CFG_FILE=$PKG_DIR/config/$PKG_VERSION/$PKG_CFG_FILE +elif [ -f $PKG_DIR/config/$LINUX/$PKG_CFG_FILE ]; then + PKG_KERNEL_CFG_FILE=$PKG_DIR/config/$LINUX/$PKG_CFG_FILE +else + PKG_KERNEL_CFG_FILE=$PKG_DIR/config/$PKG_CFG_FILE +fi + case "$LINUX" in amlogic-3.10) PKG_VERSION="02fdb27" @@ -74,34 +95,13 @@ if [ "$BUILD_ANDROID_BOOTIMG" = "yes" ]; then fi post_patch() { - CFG_FILE="$PKG_NAME.${TARGET_PATCH_ARCH:-$TARGET_ARCH}.conf" - if [ -n "$DEVICE" -a -f $PROJECT_DIR/$PROJECT/devices/$DEVICE/$PKG_NAME/$PKG_VERSION/$CFG_FILE ]; then - KERNEL_CFG_FILE=$PROJECT_DIR/$PROJECT/devices/$DEVICE/$PKG_NAME/$PKG_VERSION/$CFG_FILE - elif [ -n "$DEVICE" -a -f $PROJECT_DIR/$PROJECT/devices/$DEVICE/$PKG_NAME/$LINUX/$CFG_FILE ]; then - KERNEL_CFG_FILE=$PROJECT_DIR/$PROJECT/devices/$DEVICE/$PKG_NAME/$LINUX/$CFG_FILE - elif [ -n "$DEVICE" -a -f $PROJECT_DIR/$PROJECT/devices/$DEVICE/$PKG_NAME/$CFG_FILE ]; then - KERNEL_CFG_FILE=$PROJECT_DIR/$PROJECT/devices/$DEVICE/$PKG_NAME/$CFG_FILE - elif [ -f $PROJECT_DIR/$PROJECT/$PKG_NAME/$PKG_VERSION/$CFG_FILE ]; then - KERNEL_CFG_FILE=$PROJECT_DIR/$PROJECT/$PKG_NAME/$PKG_VERSION/$CFG_FILE - elif [ -f $PROJECT_DIR/$PROJECT/$PKG_NAME/$LINUX/$CFG_FILE ]; then - KERNEL_CFG_FILE=$PROJECT_DIR/$PROJECT/$PKG_NAME/$LINUX/$CFG_FILE - elif [ -f $PROJECT_DIR/$PROJECT/$PKG_NAME/$CFG_FILE ]; then - KERNEL_CFG_FILE=$PROJECT_DIR/$PROJECT/$PKG_NAME/$CFG_FILE - elif [ -f $PKG_DIR/config/$PKG_VERSION/$CFG_FILE ]; then - KERNEL_CFG_FILE=$PKG_DIR/config/$PKG_VERSION/$CFG_FILE - elif [ -f $PKG_DIR/config/$LINUX/$CFG_FILE ]; then - KERNEL_CFG_FILE=$PKG_DIR/config/$LINUX/$CFG_FILE - else - KERNEL_CFG_FILE=$PKG_DIR/config/$CFG_FILE - fi - sed -i -e "s|^HOSTCC[[:space:]]*=.*$|HOSTCC = $TOOLCHAIN/bin/host-gcc|" \ -e "s|^HOSTCXX[[:space:]]*=.*$|HOSTCXX = $TOOLCHAIN/bin/host-g++|" \ -e "s|^ARCH[[:space:]]*?=.*$|ARCH = $TARGET_KERNEL_ARCH|" \ -e "s|^CROSS_COMPILE[[:space:]]*?=.*$|CROSS_COMPILE = $PKG_TARGET_PREFIX|" \ $PKG_BUILD/Makefile - cp $KERNEL_CFG_FILE $PKG_BUILD/.config + cp $PKG_KERNEL_CFG_FILE $PKG_BUILD/.config if [ ! "$BUILD_ANDROID_BOOTIMG" = "yes" ]; then sed -i -e "s|^CONFIG_INITRAMFS_SOURCE=.*$|CONFIG_INITRAMFS_SOURCE=\"$BUILD/image/initramfs.cpio\"|" $PKG_BUILD/.config sed -i -e '/^CONFIG_INITRAMFS_SOURCE=*./ a CONFIG_INITRAMFS_ROOT_UID=0\nCONFIG_INITRAMFS_ROOT_GID=0' $PKG_BUILD/.config From a7bac9930ec43fc3b6746d7a468c9d72d1dfcf7b Mon Sep 17 00:00:00 2001 From: Matthias Reichl Date: Mon, 5 Feb 2018 15:38:18 +0100 Subject: [PATCH 6/6] linux: install perf in development builds perf will be built if CONFIG_PERF_EVENTS is enabled in the kernel config. elfutils, binutils and libunwind are needed to get symbols of userspace programs in perf output. zlib is an implicit dependency of elfutils and and optional one for perf - but better add it here. openssl/libcrypto is an optional dependency for perf, add it so that the perf configuration on clean build is identical to an unclean rebuild. Signed-off-by: Matthias Reichl --- packages/linux/package.mk | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/packages/linux/package.mk b/packages/linux/package.mk index e621e1d3e4..f8fb1763eb 100644 --- a/packages/linux/package.mk +++ b/packages/linux/package.mk @@ -50,6 +50,11 @@ else PKG_KERNEL_CFG_FILE=$PKG_DIR/config/$PKG_CFG_FILE fi +if [ "$DEVTOOLS" = "yes" ] && grep -q ^CONFIG_PERF_EVENTS= $PKG_KERNEL_CFG_FILE ; then + PKG_BUILD_PERF="yes" + PKG_DEPENDS_TARGET="$PKG_DEPENDS_TARGET binutils elfutils libunwind zlib openssl" +fi + case "$LINUX" in amlogic-3.10) PKG_VERSION="02fdb27" @@ -175,6 +180,25 @@ make_target() { rm -f $INSTALL/$(get_kernel_overlay_dir)/lib/modules/*/build rm -f $INSTALL/$(get_kernel_overlay_dir)/lib/modules/*/source + if [ "$PKG_BUILD_PERF" = "yes" ] ; then + ( cd tools/perf + WERROR=0 \ + NO_LIBPERL=1 \ + NO_LIBPYTHON=1 \ + NO_SLANG=1 \ + NO_GTK2=1 \ + NO_LIBNUMA=1 \ + NO_LIBAUDIT=1 \ + NO_LZMA=1 \ + NO_SDT=1 \ + LDFLAGS="-ldw -ldwfl -lebl -lelf -ldl -lz" \ + EXTRA_PERFLIBS="-lebl" \ + make + mkdir -p $INSTALL/usr/bin + cp perf $INSTALL/usr/bin + ) + fi + ( cd $ROOT rm -rf $BUILD/initramfs $SCRIPTS/install initramfs