Message ID | 20200929102618.28571-4-qais.yousef@arm.com |
---|---|
State | Changes Requested |
Headers | show |
Series | add BCC and bpftrace packages | expand |
Hi Qais, Le 29/09/2020 à 12:26, Qais Yousef a écrit : > bpftrace is a high-level tracing language for Linux enhanced Berkeley > Packet Filter (eBPF) available in recent Linux kernels (4.x). > > Only tested on x86_64 and aarch64. The package doesn't support i386 and > aarch32. This is new, we didn't worked on bpftrace yet. > > Signed-off-by: Qais Yousef <qais.yousef@arm.com> > --- > package/Config.in | 1 + > .../0001-fix-no-sys-auxv-header.patch | 22 +++++++++++++++ > ...02-fix-missing-def-ADDR_NO_RANDOMIZE.patch | 13 +++++++++ > package/bpftrace/0003-install-libparser.patch | 12 +++++++++ > .../bpftrace/0004-install-libresources.patch | 12 +++++++++ > package/bpftrace/0005-install-libarch.patch | 10 +++++++ > package/bpftrace/0006-install-libast.patch | 11 ++++++++ > package/bpftrace/Config.in | 27 +++++++++++++++++++ > package/bpftrace/bpftrace.mk | 17 ++++++++++++ > 9 files changed, 125 insertions(+) > create mode 100644 package/bpftrace/0001-fix-no-sys-auxv-header.patch > create mode 100644 package/bpftrace/0002-fix-missing-def-ADDR_NO_RANDOMIZE.patch > create mode 100644 package/bpftrace/0003-install-libparser.patch > create mode 100644 package/bpftrace/0004-install-libresources.patch > create mode 100644 package/bpftrace/0005-install-libarch.patch > create mode 100644 package/bpftrace/0006-install-libast.patch > create mode 100644 package/bpftrace/Config.in > create mode 100644 package/bpftrace/bpftrace.mk > > diff --git a/package/Config.in b/package/Config.in > index 03ed3e5874..c7e352be82 100644 > --- a/package/Config.in > +++ b/package/Config.in > @@ -86,6 +86,7 @@ menu "Debugging, profiling and benchmark" > source "package/blktrace/Config.in" > source "package/bcc/Config.in" > source "package/bonnie/Config.in" > + source "package/bpftrace/Config.in" > source "package/cache-calibrator/Config.in" > source "package/clinfo/Config.in" > source "package/dacapo/Config.in" > diff --git a/package/bpftrace/0001-fix-no-sys-auxv-header.patch b/package/bpftrace/0001-fix-no-sys-auxv-header.patch > new file mode 100644 > index 0000000000..c89fbe51ee > --- /dev/null > +++ b/package/bpftrace/0001-fix-no-sys-auxv-header.patch > @@ -0,0 +1,22 @@ > +Signed-off-by: Qais Yousef <qais.yousef@arm.com> > + > +--- ./src/attached_probe.cpp.old 2020-07-28 13:23:20.599528129 +0100 > ++++ ./src/attached_probe.cpp 2020-07-28 13:23:49.199715578 +0100 > +@@ -8,7 +8,7 @@ > + #include <linux/limits.h> > + #include <linux/perf_event.h> > + #include <regex> > +-#include <sys/auxv.h> > ++//#include <sys/auxv.h> Why? > + #include <sys/utsname.h> > + #include <tuple> > + #include <unistd.h> > +@@ -612,7 +612,7 @@ > + // the build-time constant if unavailable. This always matches the > + // running kernel, but is not supported on arm32. > + unsigned code = 0; > +- unsigned long base = getauxval(AT_SYSINFO_EHDR); > ++ unsigned long base = 0; //getauxval(AT_SYSINFO_EHDR); Why? > + if (base && !memcmp(reinterpret_cast<void *>(base), ELFMAG, 4)) > + code = _find_version_note(base); > + if (! code) > diff --git a/package/bpftrace/0002-fix-missing-def-ADDR_NO_RANDOMIZE.patch b/package/bpftrace/0002-fix-missing-def-ADDR_NO_RANDOMIZE.patch > new file mode 100644 > index 0000000000..0481348068 > --- /dev/null > +++ b/package/bpftrace/0002-fix-missing-def-ADDR_NO_RANDOMIZE.patch > @@ -0,0 +1,13 @@ > +Signed-off-by: Qais Yousef <qais.yousef@arm.com> > + > +--- ./src/bpftrace.cpp.old 2020-07-28 13:24:42.322117517 +0100 > ++++ ./src/bpftrace.cpp 2020-07-28 13:25:08.651880968 +0100 > +@@ -37,6 +37,8 @@ > + #include "triggers.h" > + #include "utils.h" > + > ++#define ADDR_NO_RANDOMIZE 0x0040000 This define come from the kernel source (include/uapi/linux/personality.h) > ++ > + namespace libbpf { > + #define __BPF_NAME_FN(x) #x > + const char *bpf_func_name[] = { __BPF_FUNC_MAPPER(__BPF_NAME_FN) }; > diff --git a/package/bpftrace/0003-install-libparser.patch b/package/bpftrace/0003-install-libparser.patch > new file mode 100644 > index 0000000000..9cf368cb7a > --- /dev/null > +++ b/package/bpftrace/0003-install-libparser.patch > @@ -0,0 +1,12 @@ > +Signed-off-by: Qais Yousef <qais.yousef@arm.com> > + > +--- ./CMakeLists.txt.old 2020-07-28 23:08:33.068910392 +0100 > ++++ ./CMakeLists.txt 2020-07-28 23:08:41.529166766 +0100 > +@@ -94,6 +94,7 @@ > + add_library(parser ${BISON_bison_parser_OUTPUTS} ${FLEX_flex_lexer_OUTPUTS}) > + target_compile_options(parser PRIVATE "-w") > + target_include_directories(parser PUBLIC src src/ast ${CMAKE_BINARY_DIR}) > ++install(TARGETS parser LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) Maybe libparser should be forced to build as a static library by bpftrace and not installed. > + > + include(CheckSymbolExists) > + set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) > diff --git a/package/bpftrace/0004-install-libresources.patch b/package/bpftrace/0004-install-libresources.patch > new file mode 100644 > index 0000000000..4c1902e2b3 > --- /dev/null > +++ b/package/bpftrace/0004-install-libresources.patch > @@ -0,0 +1,12 @@ > +Signed-off-by: Qais Yousef <qais.yousef@arm.com> > + > +--- ./resources/CMakeLists.txt.old 2020-07-28 23:08:53.037515482 +0100 > ++++ ./resources/CMakeLists.txt 2020-07-28 23:09:24.934482032 +0100 > +@@ -1,6 +1,7 @@ > + add_library(resources headers.cpp) > + > + target_include_directories(resources PUBLIC ../src) > ++install(TARGETS resources LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) same for libresources. > + > + function(embed_headers output) > + file(WRITE ${output} "#include \"headers.h\"\n\nnamespace bpftrace {\n") > diff --git a/package/bpftrace/0005-install-libarch.patch b/package/bpftrace/0005-install-libarch.patch > new file mode 100644 > index 0000000000..04812ff313 > --- /dev/null > +++ b/package/bpftrace/0005-install-libarch.patch > @@ -0,0 +1,10 @@ > +Signed-off-by: Qais Yousef <qais.yousef@arm.com> > + > +--- ./src/arch/CMakeLists.txt.old 2020-07-28 23:01:18.283735497 +0100 > ++++ ./src/arch/CMakeLists.txt 2020-07-28 23:02:13.865419746 +0100 > +@@ -11,3 +11,5 @@ > + else() > + message(FATAL_ERROR "Unsupported architecture: ${CMAKE_SYSTEM_PROCESSOR}") > + endif() > ++ > ++install(TARGETS arch LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) same for libarch. > diff --git a/package/bpftrace/0006-install-libast.patch b/package/bpftrace/0006-install-libast.patch > new file mode 100644 > index 0000000000..c84991d360 > --- /dev/null > +++ b/package/bpftrace/0006-install-libast.patch > @@ -0,0 +1,11 @@ > +Signed-off-by: Qais Yousef <qais.yousef@arm.com> > + > +--- ./src/ast/CMakeLists.txt.old 2020-07-28 23:00:16.837873565 +0100 > ++++ ./src/ast/CMakeLists.txt 2020-07-28 23:04:08.320887977 +0100 > +@@ -67,4 +67,6 @@ > + target_link_libraries(ast ${llvm_libs}) > + endif() > + target_link_libraries(ast libclang) > ++ > ++ install(TARGETS ast LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) same for libast. > + endif() > diff --git a/package/bpftrace/Config.in b/package/bpftrace/Config.in > new file mode 100644 > index 0000000000..a4bae478dc > --- /dev/null > +++ b/package/bpftrace/Config.in > @@ -0,0 +1,27 @@ > +config BR2_PACKAGE_BPFTRACE > + bool "bpftrace" > + depends on BR2_aarch64 || BR2_aarch64_be || BR2_x86_64 > + depends on BR2_PACKAGE_BCC > + depends on BR2_PACKAGE_LLVM_RTTI Why llvm rtti is needed ? > + help > + BPFTrace > + > + bpftrace is a high-level tracing language for Linux enhanced > + Berkeley Packet Filter (eBPF) available in recent Linux > + kernels (4.x). > + > + bpftrace uses LLVM as a backend to compile scripts to > + BPF-bytecode and makes use of BCC for interacting with the > + Linux BPF system, as well as existing Linux tracing > + capabilities: kernel dynamic tracing (kprobes), user-level > + dynamic tracing (uprobes), and tracepoints. The bpftrace > + language is inspired by awk and C, and predecessor tracers > + such as DTrace and SystemTap. > + > + https://www.github.com/iovisor/bpftrace > + > +comment "bpftrace supported on aarch64 and x86_64" > + depends on !(BR2_aarch64 || BR2_aarch64_be || BR2_x86_64) > + > +comment "bpftrace needs bcc, llvm-rtti" > + depends on !BR2_PACKAGE_BCC || !BR2_PACKAGE_LLVM_RTTI > diff --git a/package/bpftrace/bpftrace.mk b/package/bpftrace/bpftrace.mk > new file mode 100644 > index 0000000000..d5975618f1 > --- /dev/null > +++ b/package/bpftrace/bpftrace.mk > @@ -0,0 +1,17 @@ > +################################################################################ > +# > +# BPFTrace > +# > +################################################################################ > + > +BPFTRACE_VERSION = v0.11.0 > +BPFTRACE_SITE = https://github.com/iovisor/bpftrace > +BPFTRACE_SITE_METHOD = git > +BPFTRACE_LICENSE = Apache-2.0 > +BPFTRACE_LICENSE_FILES = LICENSE > +BPFTRACE_INSTALL_STAGING = YES If no library is installed by bpftrace, we can remove this line. > +BPFTRACE_DEPENDENCIES = bcc > + > +BPFTRACE_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release Usually the CMAKE_BUILD_TYPE is handled by the Buildroot package infra. There are some exceptions like for llvm/clang where the build blowup with - -DCMAKE_BUILD_TYPE=Debug... The bpftrace.hash file is missing, see http://nightly.buildroot.org/manual.html#adding-packages-hash I forgot to mention the DEVELOPERS file entry in my previous review: http://nightly.buildroot.org/manual.html#DEVELOPERS You need to add you as developer of bpftrace package. Feel free to add you to other packages such bcc. Best regards, Romain > + > +$(eval $(cmake-package)) >
Hi Romain On 09/29/20 22:55, Romain Naour wrote: [...] > > +--- ./src/attached_probe.cpp.old 2020-07-28 13:23:20.599528129 +0100 > > ++++ ./src/attached_probe.cpp 2020-07-28 13:23:49.199715578 +0100 > > +@@ -8,7 +8,7 @@ > > + #include <linux/limits.h> > > + #include <linux/perf_event.h> > > + #include <regex> > > +-#include <sys/auxv.h> > > ++//#include <sys/auxv.h> > > Why? Let me reproduce all these issues again and write a better log and patches. > > > + #include <sys/utsname.h> > > + #include <tuple> > > + #include <unistd.h> > > +@@ -612,7 +612,7 @@ > > + // the build-time constant if unavailable. This always matches the > > + // running kernel, but is not supported on arm32. > > + unsigned code = 0; > > +- unsigned long base = getauxval(AT_SYSINFO_EHDR); > > ++ unsigned long base = 0; //getauxval(AT_SYSINFO_EHDR); > > Why? > > > + if (base && !memcmp(reinterpret_cast<void *>(base), ELFMAG, 4)) > > + code = _find_version_note(base); > > + if (! code) > > diff --git a/package/bpftrace/0002-fix-missing-def-ADDR_NO_RANDOMIZE.patch b/package/bpftrace/0002-fix-missing-def-ADDR_NO_RANDOMIZE.patch > > new file mode 100644 > > index 0000000000..0481348068 > > --- /dev/null > > +++ b/package/bpftrace/0002-fix-missing-def-ADDR_NO_RANDOMIZE.patch > > @@ -0,0 +1,13 @@ > > +Signed-off-by: Qais Yousef <qais.yousef@arm.com> > > + > > +--- ./src/bpftrace.cpp.old 2020-07-28 13:24:42.322117517 +0100 > > ++++ ./src/bpftrace.cpp 2020-07-28 13:25:08.651880968 +0100 > > +@@ -37,6 +37,8 @@ > > + #include "triggers.h" > > + #include "utils.h" > > + > > ++#define ADDR_NO_RANDOMIZE 0x0040000 > > This define come from the kernel source (include/uapi/linux/personality.h) It includes <sys/personality.h>. Maybe because I was building with uClibc first and it didn't have an updated header. I realized much later when I was getting weird aarch64 errors that I must switch to glibc for aarch64 at least. Probably this can be dropped if we depend on glibc all the time. > > > ++ > > + namespace libbpf { > > + #define __BPF_NAME_FN(x) #x > > + const char *bpf_func_name[] = { __BPF_FUNC_MAPPER(__BPF_NAME_FN) }; > > diff --git a/package/bpftrace/0003-install-libparser.patch b/package/bpftrace/0003-install-libparser.patch > > new file mode 100644 > > index 0000000000..9cf368cb7a > > --- /dev/null > > +++ b/package/bpftrace/0003-install-libparser.patch > > @@ -0,0 +1,12 @@ > > +Signed-off-by: Qais Yousef <qais.yousef@arm.com> > > + > > +--- ./CMakeLists.txt.old 2020-07-28 23:08:33.068910392 +0100 > > ++++ ./CMakeLists.txt 2020-07-28 23:08:41.529166766 +0100 > > +@@ -94,6 +94,7 @@ > > + add_library(parser ${BISON_bison_parser_OUTPUTS} ${FLEX_flex_lexer_OUTPUTS}) > > + target_compile_options(parser PRIVATE "-w") > > + target_include_directories(parser PUBLIC src src/ast ${CMAKE_BINARY_DIR}) > > ++install(TARGETS parser LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) > > Maybe libparser should be forced to build as a static library by bpftrace and > not installed. Hmm okay. Let me see if I can do this in a way that is upstreamable. > > diff --git a/package/bpftrace/Config.in b/package/bpftrace/Config.in > > new file mode 100644 > > index 0000000000..a4bae478dc > > --- /dev/null > > +++ b/package/bpftrace/Config.in > > @@ -0,0 +1,27 @@ > > +config BR2_PACKAGE_BPFTRACE > > + bool "bpftrace" > > + depends on BR2_aarch64 || BR2_aarch64_be || BR2_x86_64 > > + depends on BR2_PACKAGE_BCC > > + depends on BR2_PACKAGE_LLVM_RTTI > > Why llvm rtti is needed ? Good question. I think I was seeing failures similar to the one described in the link below. Something wasn't found in LLVM library without enabling this option. Will try to reproduce and document it better. Unless you know of a better way to handle these type of problems :-) https://github.com/iovisor/bpftrace/issues/1156 > > > + help > > + BPFTrace > > + > > + bpftrace is a high-level tracing language for Linux enhanced > > + Berkeley Packet Filter (eBPF) available in recent Linux > > + kernels (4.x). > > + > > + bpftrace uses LLVM as a backend to compile scripts to > > + BPF-bytecode and makes use of BCC for interacting with the > > + Linux BPF system, as well as existing Linux tracing > > + capabilities: kernel dynamic tracing (kprobes), user-level > > + dynamic tracing (uprobes), and tracepoints. The bpftrace > > + language is inspired by awk and C, and predecessor tracers > > + such as DTrace and SystemTap. > > + > > + https://www.github.com/iovisor/bpftrace > > + > > +comment "bpftrace supported on aarch64 and x86_64" > > + depends on !(BR2_aarch64 || BR2_aarch64_be || BR2_x86_64) > > + > > +comment "bpftrace needs bcc, llvm-rtti" > > + depends on !BR2_PACKAGE_BCC || !BR2_PACKAGE_LLVM_RTTI > > diff --git a/package/bpftrace/bpftrace.mk b/package/bpftrace/bpftrace.mk > > new file mode 100644 > > index 0000000000..d5975618f1 > > --- /dev/null > > +++ b/package/bpftrace/bpftrace.mk > > @@ -0,0 +1,17 @@ > > +################################################################################ > > +# > > +# BPFTrace > > +# > > +################################################################################ > > + > > +BPFTRACE_VERSION = v0.11.0 > > +BPFTRACE_SITE = https://github.com/iovisor/bpftrace > > +BPFTRACE_SITE_METHOD = git > > +BPFTRACE_LICENSE = Apache-2.0 > > +BPFTRACE_LICENSE_FILES = LICENSE > > +BPFTRACE_INSTALL_STAGING = YES > > If no library is installed by bpftrace, we can remove this line. +1 > > > +BPFTRACE_DEPENDENCIES = bcc > > + > > +BPFTRACE_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release > > Usually the CMAKE_BUILD_TYPE is handled by the Buildroot package infra. > There are some exceptions like for llvm/clang where the build blowup with - > -DCMAKE_BUILD_TYPE=Debug... +1 > > The bpftrace.hash file is missing, see > http://nightly.buildroot.org/manual.html#adding-packages-hash > > I forgot to mention the DEVELOPERS file entry in my previous review: > http://nightly.buildroot.org/manual.html#DEVELOPERS > > You need to add you as developer of bpftrace package. > Feel free to add you to other packages such bcc. Cool. Thanks for the review! I will work on all of these items and post an updated series as soon as it's ready. Please note I am doing this on evenings and weekends only. So please be patient with me for any delays in responses or following up. It's just me trying to find the time to work on this. I certainly intend to follow this through :-) Thanks! -- Qais Yousef
On 10/03/20 21:56, Qais Yousef wrote: [...] > > > diff --git a/package/bpftrace/Config.in b/package/bpftrace/Config.in > > > new file mode 100644 > > > index 0000000000..a4bae478dc > > > --- /dev/null > > > +++ b/package/bpftrace/Config.in > > > @@ -0,0 +1,27 @@ > > > +config BR2_PACKAGE_BPFTRACE > > > + bool "bpftrace" > > > + depends on BR2_aarch64 || BR2_aarch64_be || BR2_x86_64 > > > + depends on BR2_PACKAGE_BCC > > > + depends on BR2_PACKAGE_LLVM_RTTI > > > > Why llvm rtti is needed ? > > Good question. > > I think I was seeing failures similar to the one described in the link below. > Something wasn't found in LLVM library without enabling this option. Will try > to reproduce and document it better. Unless you know of a better way to handle > these type of problems :-) > > https://github.com/iovisor/bpftrace/issues/1156 This is the error that I get if I don't enable LLVM_RTTI: buildroot-arm64/output/host/lib/gcc/aarch64-buildroot-linux-gnu/9.3.0/../../../../aarch64-buildroot-linux-gnu/bin/ld: ast/libast.so: undefined reference to `typeinfo for llvm::SectionMemoryManager' buildroot-arm64/output/host/lib/gcc/aarch64-buildroot-linux-gnu/9.3.0/../../../../aarch64-buildroot-linux-gnu/bin/ld: ast/libast.so: undefined reference to `typeinfo for llvm::orc::SymbolResolver' collect2: error: ld returned 1 exit status I understood after a bit of digging that it has hard dependency on having RTTI enabled. Is there a preferred way to solve these type of problems? Thanks -- Qais Yousef
Hi Romain On 09/29/20 22:55, Romain Naour wrote: [...] > > diff --git a/package/bpftrace/0001-fix-no-sys-auxv-header.patch b/package/bpftrace/0001-fix-no-sys-auxv-header.patch > > new file mode 100644 > > index 0000000000..c89fbe51ee > > --- /dev/null > > +++ b/package/bpftrace/0001-fix-no-sys-auxv-header.patch > > @@ -0,0 +1,22 @@ > > +Signed-off-by: Qais Yousef <qais.yousef@arm.com> > > + > > +--- ./src/attached_probe.cpp.old 2020-07-28 13:23:20.599528129 +0100 > > ++++ ./src/attached_probe.cpp 2020-07-28 13:23:49.199715578 +0100 > > +@@ -8,7 +8,7 @@ > > + #include <linux/limits.h> > > + #include <linux/perf_event.h> > > + #include <regex> > > +-#include <sys/auxv.h> > > ++//#include <sys/auxv.h> > > Why? This .. > > > + #include <sys/utsname.h> > > + #include <tuple> > > + #include <unistd.h> > > +@@ -612,7 +612,7 @@ > > + // the build-time constant if unavailable. This always matches the > > + // running kernel, but is not supported on arm32. > > + unsigned code = 0; > > +- unsigned long base = getauxval(AT_SYSINFO_EHDR); > > ++ unsigned long base = 0; //getauxval(AT_SYSINFO_EHDR); > > Why? .. this .. > > > + if (base && !memcmp(reinterpret_cast<void *>(base), ELFMAG, 4)) > > + code = _find_version_note(base); > > + if (! code) > > diff --git a/package/bpftrace/0002-fix-missing-def-ADDR_NO_RANDOMIZE.patch b/package/bpftrace/0002-fix-missing-def-ADDR_NO_RANDOMIZE.patch > > new file mode 100644 > > index 0000000000..0481348068 > > --- /dev/null > > +++ b/package/bpftrace/0002-fix-missing-def-ADDR_NO_RANDOMIZE.patch > > @@ -0,0 +1,13 @@ > > +Signed-off-by: Qais Yousef <qais.yousef@arm.com> > > + > > +--- ./src/bpftrace.cpp.old 2020-07-28 13:24:42.322117517 +0100 > > ++++ ./src/bpftrace.cpp 2020-07-28 13:25:08.651880968 +0100 > > +@@ -37,6 +37,8 @@ > > + #include "triggers.h" > > + #include "utils.h" > > + > > ++#define ADDR_NO_RANDOMIZE 0x0040000 > > This define come from the kernel source (include/uapi/linux/personality.h) .. and this were caused by using uClibc. With Glibc I can't reproduce them. So it's just uClibc lacks the new headers and definitions. > > > ++ > > + namespace libbpf { > > + #define __BPF_NAME_FN(x) #x > > + const char *bpf_func_name[] = { __BPF_FUNC_MAPPER(__BPF_NAME_FN) }; > > diff --git a/package/bpftrace/0003-install-libparser.patch b/package/bpftrace/0003-install-libparser.patch > > new file mode 100644 > > index 0000000000..9cf368cb7a > > --- /dev/null > > +++ b/package/bpftrace/0003-install-libparser.patch > > @@ -0,0 +1,12 @@ > > +Signed-off-by: Qais Yousef <qais.yousef@arm.com> > > + > > +--- ./CMakeLists.txt.old 2020-07-28 23:08:33.068910392 +0100 > > ++++ ./CMakeLists.txt 2020-07-28 23:08:41.529166766 +0100 > > +@@ -94,6 +94,7 @@ > > + add_library(parser ${BISON_bison_parser_OUTPUTS} ${FLEX_flex_lexer_OUTPUTS}) > > + target_compile_options(parser PRIVATE "-w") > > + target_include_directories(parser PUBLIC src src/ast ${CMAKE_BINARY_DIR}) > > ++install(TARGETS parser LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) > > Maybe libparser should be forced to build as a static library by bpftrace and > not installed. The below define in bpftrace.mk makes this and the other libs static: +BPFTRACE_CONF_OPTS += -DBUILD_SHARED_LIBS:BOOL=OFF There's a weird requirement for bpftrace to work correctly. It must not be stripped otherwise it'll lose an important functionality. I found the below bugzilla which describes the problem: https://bugzilla.redhat.com/show_bug.cgi?id=1865787 Is there a way to tell buidlroot not to strip a binary without setting it in the config? I couldn't find an example in .mk file - but maybe I didn't look hard enough. Thanks -- Qais Yousef
diff --git a/package/Config.in b/package/Config.in index 03ed3e5874..c7e352be82 100644 --- a/package/Config.in +++ b/package/Config.in @@ -86,6 +86,7 @@ menu "Debugging, profiling and benchmark" source "package/blktrace/Config.in" source "package/bcc/Config.in" source "package/bonnie/Config.in" + source "package/bpftrace/Config.in" source "package/cache-calibrator/Config.in" source "package/clinfo/Config.in" source "package/dacapo/Config.in" diff --git a/package/bpftrace/0001-fix-no-sys-auxv-header.patch b/package/bpftrace/0001-fix-no-sys-auxv-header.patch new file mode 100644 index 0000000000..c89fbe51ee --- /dev/null +++ b/package/bpftrace/0001-fix-no-sys-auxv-header.patch @@ -0,0 +1,22 @@ +Signed-off-by: Qais Yousef <qais.yousef@arm.com> + +--- ./src/attached_probe.cpp.old 2020-07-28 13:23:20.599528129 +0100 ++++ ./src/attached_probe.cpp 2020-07-28 13:23:49.199715578 +0100 +@@ -8,7 +8,7 @@ + #include <linux/limits.h> + #include <linux/perf_event.h> + #include <regex> +-#include <sys/auxv.h> ++//#include <sys/auxv.h> + #include <sys/utsname.h> + #include <tuple> + #include <unistd.h> +@@ -612,7 +612,7 @@ + // the build-time constant if unavailable. This always matches the + // running kernel, but is not supported on arm32. + unsigned code = 0; +- unsigned long base = getauxval(AT_SYSINFO_EHDR); ++ unsigned long base = 0; //getauxval(AT_SYSINFO_EHDR); + if (base && !memcmp(reinterpret_cast<void *>(base), ELFMAG, 4)) + code = _find_version_note(base); + if (! code) diff --git a/package/bpftrace/0002-fix-missing-def-ADDR_NO_RANDOMIZE.patch b/package/bpftrace/0002-fix-missing-def-ADDR_NO_RANDOMIZE.patch new file mode 100644 index 0000000000..0481348068 --- /dev/null +++ b/package/bpftrace/0002-fix-missing-def-ADDR_NO_RANDOMIZE.patch @@ -0,0 +1,13 @@ +Signed-off-by: Qais Yousef <qais.yousef@arm.com> + +--- ./src/bpftrace.cpp.old 2020-07-28 13:24:42.322117517 +0100 ++++ ./src/bpftrace.cpp 2020-07-28 13:25:08.651880968 +0100 +@@ -37,6 +37,8 @@ + #include "triggers.h" + #include "utils.h" + ++#define ADDR_NO_RANDOMIZE 0x0040000 ++ + namespace libbpf { + #define __BPF_NAME_FN(x) #x + const char *bpf_func_name[] = { __BPF_FUNC_MAPPER(__BPF_NAME_FN) }; diff --git a/package/bpftrace/0003-install-libparser.patch b/package/bpftrace/0003-install-libparser.patch new file mode 100644 index 0000000000..9cf368cb7a --- /dev/null +++ b/package/bpftrace/0003-install-libparser.patch @@ -0,0 +1,12 @@ +Signed-off-by: Qais Yousef <qais.yousef@arm.com> + +--- ./CMakeLists.txt.old 2020-07-28 23:08:33.068910392 +0100 ++++ ./CMakeLists.txt 2020-07-28 23:08:41.529166766 +0100 +@@ -94,6 +94,7 @@ + add_library(parser ${BISON_bison_parser_OUTPUTS} ${FLEX_flex_lexer_OUTPUTS}) + target_compile_options(parser PRIVATE "-w") + target_include_directories(parser PUBLIC src src/ast ${CMAKE_BINARY_DIR}) ++install(TARGETS parser LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + + include(CheckSymbolExists) + set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) diff --git a/package/bpftrace/0004-install-libresources.patch b/package/bpftrace/0004-install-libresources.patch new file mode 100644 index 0000000000..4c1902e2b3 --- /dev/null +++ b/package/bpftrace/0004-install-libresources.patch @@ -0,0 +1,12 @@ +Signed-off-by: Qais Yousef <qais.yousef@arm.com> + +--- ./resources/CMakeLists.txt.old 2020-07-28 23:08:53.037515482 +0100 ++++ ./resources/CMakeLists.txt 2020-07-28 23:09:24.934482032 +0100 +@@ -1,6 +1,7 @@ + add_library(resources headers.cpp) + + target_include_directories(resources PUBLIC ../src) ++install(TARGETS resources LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + + function(embed_headers output) + file(WRITE ${output} "#include \"headers.h\"\n\nnamespace bpftrace {\n") diff --git a/package/bpftrace/0005-install-libarch.patch b/package/bpftrace/0005-install-libarch.patch new file mode 100644 index 0000000000..04812ff313 --- /dev/null +++ b/package/bpftrace/0005-install-libarch.patch @@ -0,0 +1,10 @@ +Signed-off-by: Qais Yousef <qais.yousef@arm.com> + +--- ./src/arch/CMakeLists.txt.old 2020-07-28 23:01:18.283735497 +0100 ++++ ./src/arch/CMakeLists.txt 2020-07-28 23:02:13.865419746 +0100 +@@ -11,3 +11,5 @@ + else() + message(FATAL_ERROR "Unsupported architecture: ${CMAKE_SYSTEM_PROCESSOR}") + endif() ++ ++install(TARGETS arch LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/package/bpftrace/0006-install-libast.patch b/package/bpftrace/0006-install-libast.patch new file mode 100644 index 0000000000..c84991d360 --- /dev/null +++ b/package/bpftrace/0006-install-libast.patch @@ -0,0 +1,11 @@ +Signed-off-by: Qais Yousef <qais.yousef@arm.com> + +--- ./src/ast/CMakeLists.txt.old 2020-07-28 23:00:16.837873565 +0100 ++++ ./src/ast/CMakeLists.txt 2020-07-28 23:04:08.320887977 +0100 +@@ -67,4 +67,6 @@ + target_link_libraries(ast ${llvm_libs}) + endif() + target_link_libraries(ast libclang) ++ ++ install(TARGETS ast LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + endif() diff --git a/package/bpftrace/Config.in b/package/bpftrace/Config.in new file mode 100644 index 0000000000..a4bae478dc --- /dev/null +++ b/package/bpftrace/Config.in @@ -0,0 +1,27 @@ +config BR2_PACKAGE_BPFTRACE + bool "bpftrace" + depends on BR2_aarch64 || BR2_aarch64_be || BR2_x86_64 + depends on BR2_PACKAGE_BCC + depends on BR2_PACKAGE_LLVM_RTTI + help + BPFTrace + + bpftrace is a high-level tracing language for Linux enhanced + Berkeley Packet Filter (eBPF) available in recent Linux + kernels (4.x). + + bpftrace uses LLVM as a backend to compile scripts to + BPF-bytecode and makes use of BCC for interacting with the + Linux BPF system, as well as existing Linux tracing + capabilities: kernel dynamic tracing (kprobes), user-level + dynamic tracing (uprobes), and tracepoints. The bpftrace + language is inspired by awk and C, and predecessor tracers + such as DTrace and SystemTap. + + https://www.github.com/iovisor/bpftrace + +comment "bpftrace supported on aarch64 and x86_64" + depends on !(BR2_aarch64 || BR2_aarch64_be || BR2_x86_64) + +comment "bpftrace needs bcc, llvm-rtti" + depends on !BR2_PACKAGE_BCC || !BR2_PACKAGE_LLVM_RTTI diff --git a/package/bpftrace/bpftrace.mk b/package/bpftrace/bpftrace.mk new file mode 100644 index 0000000000..d5975618f1 --- /dev/null +++ b/package/bpftrace/bpftrace.mk @@ -0,0 +1,17 @@ +################################################################################ +# +# BPFTrace +# +################################################################################ + +BPFTRACE_VERSION = v0.11.0 +BPFTRACE_SITE = https://github.com/iovisor/bpftrace +BPFTRACE_SITE_METHOD = git +BPFTRACE_LICENSE = Apache-2.0 +BPFTRACE_LICENSE_FILES = LICENSE +BPFTRACE_INSTALL_STAGING = YES +BPFTRACE_DEPENDENCIES = bcc + +BPFTRACE_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release + +$(eval $(cmake-package))
bpftrace is a high-level tracing language for Linux enhanced Berkeley Packet Filter (eBPF) available in recent Linux kernels (4.x). Only tested on x86_64 and aarch64. The package doesn't support i386 and aarch32. Signed-off-by: Qais Yousef <qais.yousef@arm.com> --- package/Config.in | 1 + .../0001-fix-no-sys-auxv-header.patch | 22 +++++++++++++++ ...02-fix-missing-def-ADDR_NO_RANDOMIZE.patch | 13 +++++++++ package/bpftrace/0003-install-libparser.patch | 12 +++++++++ .../bpftrace/0004-install-libresources.patch | 12 +++++++++ package/bpftrace/0005-install-libarch.patch | 10 +++++++ package/bpftrace/0006-install-libast.patch | 11 ++++++++ package/bpftrace/Config.in | 27 +++++++++++++++++++ package/bpftrace/bpftrace.mk | 17 ++++++++++++ 9 files changed, 125 insertions(+) create mode 100644 package/bpftrace/0001-fix-no-sys-auxv-header.patch create mode 100644 package/bpftrace/0002-fix-missing-def-ADDR_NO_RANDOMIZE.patch create mode 100644 package/bpftrace/0003-install-libparser.patch create mode 100644 package/bpftrace/0004-install-libresources.patch create mode 100644 package/bpftrace/0005-install-libarch.patch create mode 100644 package/bpftrace/0006-install-libast.patch create mode 100644 package/bpftrace/Config.in create mode 100644 package/bpftrace/bpftrace.mk