From patchwork Tue Sep 29 10:26:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qais Yousef X-Patchwork-Id: 1373270 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C0wYC1sl0z9sSJ for ; Tue, 29 Sep 2020 20:26:55 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 9726B8679A; Tue, 29 Sep 2020 10:26:53 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gzQa3GY9SRIQ; Tue, 29 Sep 2020 10:26:50 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id A043D867A8; Tue, 29 Sep 2020 10:26:50 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 3B7D61BF232 for ; Tue, 29 Sep 2020 10:26:49 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 2E3BE867A1 for ; Tue, 29 Sep 2020 10:26:49 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LpEzVC5x8H81 for ; Tue, 29 Sep 2020 10:26:45 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by whitealder.osuosl.org (Postfix) with ESMTP id 53B4386785 for ; Tue, 29 Sep 2020 10:26:45 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CB84031B; Tue, 29 Sep 2020 03:26:44 -0700 (PDT) Received: from e107158-lin.cambridge.arm.com (e107158-lin.cambridge.arm.com [10.1.195.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0D12F3F6CF; Tue, 29 Sep 2020 03:26:43 -0700 (PDT) From: Qais Yousef To: buildroot@buildroot.org Date: Tue, 29 Sep 2020 11:26:16 +0100 Message-Id: <20200929102618.28571-3-qais.yousef@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200929102618.28571-1-qais.yousef@arm.com> References: <20200929102618.28571-1-qais.yousef@arm.com> Subject: [Buildroot] [RFC PATCH 2/4] Add BPF Compiler Collection (BCC) Package X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joseph Kogut , Romain Naour , Qais Yousef , Valentin Korenblit MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" BCC is a toolkit for creating efficient kernel tracing and manipulation programs, and includes several useful tools and examples. Only tested to work on x86_64 and aarch64. I had issues getting i386 and aarch32 to work. More archs support can be added later hopefully after this initial support. Signed-off-by: Qais Yousef --- package/Config.in | 1 + package/bcc/0001-fix-dlinfo.patch | 17 ++++++++++ .../0002-fix-undefined-gzgets-runtime.patch | 15 ++++++++ .../0003-fix-loading-libc-python-perf.patch | 17 ++++++++++ .../0004-fix-loading-librt-python-init.patch | 17 ++++++++++ .../0005-fix-python-installation-path.patch | 15 ++++++++ package/bcc/Config.in | 34 +++++++++++++++++++ package/bcc/bcc.mk | 25 ++++++++++++++ 8 files changed, 141 insertions(+) create mode 100644 package/bcc/0001-fix-dlinfo.patch create mode 100644 package/bcc/0002-fix-undefined-gzgets-runtime.patch create mode 100644 package/bcc/0003-fix-loading-libc-python-perf.patch create mode 100644 package/bcc/0004-fix-loading-librt-python-init.patch create mode 100644 package/bcc/0005-fix-python-installation-path.patch create mode 100644 package/bcc/Config.in create mode 100644 package/bcc/bcc.mk diff --git a/package/Config.in b/package/Config.in index d7e79f4795..03ed3e5874 100644 --- a/package/Config.in +++ b/package/Config.in @@ -84,6 +84,7 @@ endmenu menu "Debugging, profiling and benchmark" source "package/blktrace/Config.in" + source "package/bcc/Config.in" source "package/bonnie/Config.in" source "package/cache-calibrator/Config.in" source "package/clinfo/Config.in" diff --git a/package/bcc/0001-fix-dlinfo.patch b/package/bcc/0001-fix-dlinfo.patch new file mode 100644 index 0000000000..b3aed784fc --- /dev/null +++ b/package/bcc/0001-fix-dlinfo.patch @@ -0,0 +1,17 @@ +Signed-off-by: Qais Yousef + +--- ./tests/cc/test_c_api.cc.old 2020-07-27 00:57:13.681656086 +0100 ++++ ./tests/cc/test_c_api.cc 2020-07-27 00:57:25.258110970 +0100 +@@ -151,10 +151,12 @@ + return -1; + } + ++ /* + if (dlinfo(dlhdl, RTLD_DI_LINKMAP, &lm) < 0) { + fprintf(stderr, "Unable to find origin of libz.so.1: %s\n", dlerror()); + return -1; + } ++ */ + + strncpy(libpath, lm->l_name, 1024); + dlclose(dlhdl); diff --git a/package/bcc/0002-fix-undefined-gzgets-runtime.patch b/package/bcc/0002-fix-undefined-gzgets-runtime.patch new file mode 100644 index 0000000000..eb85493eab --- /dev/null +++ b/package/bcc/0002-fix-undefined-gzgets-runtime.patch @@ -0,0 +1,15 @@ +Signed-off-by: Qais Yousef + +--- ./src/cc/CMakeLists.txt.old 2020-08-02 19:32:16.502841991 +0100 ++++ ./src/cc/CMakeLists.txt 2020-08-02 19:32:47.263965564 +0100 +@@ -136,8 +136,8 @@ + add_subdirectory(frontends) + + # Link against LLVM libraries +-target_link_libraries(bcc-shared ${bcc_common_libs_for_s}) +-target_link_libraries(bcc-static ${bcc_common_libs_for_a} bcc-loader-static) ++target_link_libraries(bcc-shared ${bcc_common_libs_for_s} z) ++target_link_libraries(bcc-static ${bcc_common_libs_for_a} bcc-loader-static z) + set(bcc-lua-static ${bcc-lua-static} ${bcc_common_libs_for_lua}) + + if(LIBBPF_FOUND) diff --git a/package/bcc/0003-fix-loading-libc-python-perf.patch b/package/bcc/0003-fix-loading-libc-python-perf.patch new file mode 100644 index 0000000000..0460889f39 --- /dev/null +++ b/package/bcc/0003-fix-loading-libc-python-perf.patch @@ -0,0 +1,17 @@ +Signed-off-by: Qais Yousef + +--- ./src/python/bcc/perf.py.old 2020-08-02 20:29:54.769226300 +0100 ++++ ./src/python/bcc/perf.py 2020-08-02 20:32:13.130379117 +0100 +@@ -64,7 +64,11 @@ + PERF_EVENT_IOC_ENABLE = 9216 + + # fetch syscall routines +- libc = ct.CDLL('libc.so.6', use_errno=True) ++ try: ++ libc = ct.CDLL('libc.so.6', use_errno=True) ++ except: ++ # Try lower versions; works for uClibc ++ libc = ct.CDLL('libc.so.1', use_errno=True) + syscall = libc.syscall # not declaring vararg types + ioctl = libc.ioctl # not declaring vararg types + diff --git a/package/bcc/0004-fix-loading-librt-python-init.patch b/package/bcc/0004-fix-loading-librt-python-init.patch new file mode 100644 index 0000000000..dda1810d1e --- /dev/null +++ b/package/bcc/0004-fix-loading-librt-python-init.patch @@ -0,0 +1,17 @@ +Signed-off-by: Qais Yousef + +--- ./src/python/bcc/__init__.py.old 2020-08-02 20:29:51.817116507 +0100 ++++ ./src/python/bcc/__init__.py 2020-08-02 20:30:47.971206447 +0100 +@@ -200,7 +200,11 @@ + class timespec(ct.Structure): + _fields_ = [('tv_sec', ct.c_long), ('tv_nsec', ct.c_long)] + +- _librt = ct.CDLL('librt.so.1', use_errno=True) ++ try: ++ _librt = ct.CDLL('librt.so.1', use_errno=True) ++ except: ++ # In some embedded systems (uClibc), libc contains librt ++ _librt = ct.CDLL('libc.so.1', use_errno=True) + _clock_gettime = _librt.clock_gettime + _clock_gettime.argtypes = [ct.c_int, ct.POINTER(timespec)] + diff --git a/package/bcc/0005-fix-python-installation-path.patch b/package/bcc/0005-fix-python-installation-path.patch new file mode 100644 index 0000000000..b61df6ca48 --- /dev/null +++ b/package/bcc/0005-fix-python-installation-path.patch @@ -0,0 +1,15 @@ +Signed-off-by: Qais Yousef + +--- ./src/python/CMakeLists.txt.old 2020-08-06 22:04:15.400347699 +0100 ++++ ./src/python/CMakeLists.txt 2020-08-06 22:04:28.012820888 +0100 +@@ -5,10 +5,6 @@ + set(PYTHON_CMD "python") + endif() + +-if(EXISTS "/etc/debian_version") +- set(PYTHON_FLAGS "${PYTHON_FLAGS} --install-layout deb") +-endif() +- + file(GLOB_RECURSE PYTHON_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.py) + file(GLOB_RECURSE PYTHON_INCLUDES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/package/bcc/Config.in b/package/bcc/Config.in new file mode 100644 index 0000000000..6c332977f9 --- /dev/null +++ b/package/bcc/Config.in @@ -0,0 +1,34 @@ +config BR2_PACKAGE_BCC + bool "bcc" + depends on BR2_aarch64 || BR2_aarch64_be || BR2_x86_64 + depends on BR2_INSTALL_LIBSTDCPP + depends on (BR2_TOOLCHAIN_USES_GLIBC && (BR2_aarch64 || BR2_aarch64_be)) || (!BR2_aarch64 && !BR2_aarch64_be) + depends on BR2_PACKAGE_ELFUTILS + depends on BR2_PACKAGE_PYTHON || BR2_PACKAGE_PYTHON3 + depends on BR2_PACKAGE_CLANG + depends on BR2_PACKAGE_LLVM + depends on BR2_PACKAGE_LLVM_BPF + select BR2_PACKAGE_ZLIB + select BR2_PACKAGE_TAR + help + BPF Compiler Collection + + BCC is a toolkit for creating efficient kernel tracing and + manipulation programs, and includes several useful tools and + examples. + + BCC makes BPF programs easier to write, with kernel + instrumentation in C (and includes a C wrapper around LLVM), + and front-ends in Python and lua. It is suited for many tasks, + including performance analysis and network traffic control. + + https://www.github.com/iovisor/bcc + +comment "bcc supported on aarch64 and x86_64" + depends on !(BR2_aarch64 || BR2_aarch64_be || BR2_x86_64) + +comment "bcc requires glibc on aarch64" + depends on !BR2_TOOLCHAIN_USES_GLIBC && (BR2_aarch64 || BR2_aarch64_be) + +comment "bcc needs a toolchain w/ C++, elfutils, python, clang, llvm, llvm-bpf" + depends on !BR2_INSTALL_LIBSTDCPP || !BR2_PACKAGE_ELFUTILS || (!BR2_PACKAGE_PYTHON && !BR2_PACKAGE_PYTHON3) || !BR2_PACKAGE_CLANG || !BR2_PACKAGE_LLVM || !BR2_PACKAGE_LLVM_BPF diff --git a/package/bcc/bcc.mk b/package/bcc/bcc.mk new file mode 100644 index 0000000000..b83924aa93 --- /dev/null +++ b/package/bcc/bcc.mk @@ -0,0 +1,25 @@ +################################################################################ +# +# BPF Compiler Collection (BCC) +# +################################################################################ + +BCC_VERSION = v0.15.0 +BCC_SITE = https://github.com/iovisor/bcc +BCC_SITE_METHOD = git +BCC_GIT_SUBMODULES = YES +BCC_LICENSE = Apache-2.0 +BCC_LICENSE_FILES = LICENSE.txt +BCC_INSTALL_STAGING = YES +BCC_DEPENDENCIES = host-bison host-flex host-zlib zlib tar elfutils clang llvm + +ifeq ($(BR2_PACKAGE_PYTHON),y) +BCC_DEPENDENCIES += python +else +BCC_DEPENDENCIES += python3 +endif + +BCC_CONF_OPTS += \ + -DCMAKE_CXX_FLAGS="$(TARGET_CXXFLAGS) -isystem $(HOST_DIR)/include" + +$(eval $(cmake-package))