* BPF in linux-libre @ 2020-06-14 3:21 John Soo 2020-06-14 9:23 ` Mathieu Othacehe 0 siblings, 1 reply; 13+ messages in thread From: John Soo @ 2020-06-14 3:21 UTC (permalink / raw) To: Help Guix Hi Guix, I was in the mood to try some of these new bpf tools. Does the linux libre kernel support it? Thanks! John ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: BPF in linux-libre 2020-06-14 3:21 BPF in linux-libre John Soo @ 2020-06-14 9:23 ` Mathieu Othacehe 2020-06-14 15:11 ` John Soo 0 siblings, 1 reply; 13+ messages in thread From: Mathieu Othacehe @ 2020-06-14 9:23 UTC (permalink / raw) To: John Soo; +Cc: Help Guix Hello John, > I was in the mood to try some of these new bpf tools. Does the linux libre kernel support it? Yes it should support it, plus according to this[1], we have the right Kernel configuration (except maybe for CONFIG_BPF_JIT). Now, it's just a matter of packaging "bcc" and "bpftrace" I guess. Thanks, Mathieu [1]: https://github.com/iovisor/bcc/blob/master/INSTALL.md ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: BPF in linux-libre 2020-06-14 9:23 ` Mathieu Othacehe @ 2020-06-14 15:11 ` John Soo 2020-06-17 10:16 ` Mathieu Othacehe 0 siblings, 1 reply; 13+ messages in thread From: John Soo @ 2020-06-14 15:11 UTC (permalink / raw) To: Mathieu Othacehe; +Cc: Help Guix Hi Mathieu, Mathieu Othacehe <othacehe@gnu.org> writes: > Now, it's just a matter of packaging "bcc" and "bpftrace" I guess. I was working on these yesterday. I keep getting errors that seem to indicate the linux-libre-headers we have might not be compatible: Here's my definition: (define-public bcc (let* ((ver "0.14.0") (commit (string-append "v" ver))) (package (name "bcc") (version ver) (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/iovisor/bcc") (commit commit))) (file-name (git-file-name name ver)) (sha256 (base32 "08m21avzamr48qwshd4r5hlcckk1kvgrb1i6qw373b7la89jf5an")))) (build-system cmake-build-system) (inputs `(("bison" ,bison) ("clang-toolchain" ,clang-toolchain) ("flex" ,flex) ("libbpf" ,libbpf) ("libelf" ,libelf) ("linux-libre-headers" ,linux-libre-headers) ("python-wrapper" ,python-wrapper))) (arguments `(#:parallel-build? #f #:configure-flags (list (string-append "-DLIBBPF_INCLUDE_DIR=" (assoc-ref %build-inputs "libbpf") "/include")))) (home-page "https://github.com/iovisor/bcc") (synopsis "Tools for BPF on Linux") (description "BCC is a toolkit for creating efficient kernel tracing and manipulation programs, and includes several useful tools and examples. It makes use of extended BPF (Berkeley Packet Filters), formally known as eBPF, a new feature that was first added to Linux 3.15. Much of what BCC uses requires Linux 4.1 and above.") (license license:asl2.0)))) I get a lot of errors that certain things are undefined. I am guessing the names should be available in the linux headers? /tmp/guix-build-bcc-0.14.0.drv-0/source/src/cc/libbpf.c:694:58: error: ‘BPF_PROG_TYPE_EXT’ undeclared (first use in this function); did you mean ‘BPF_PROG_TYPE_XDP’? if (prog_type != BPF_PROG_TYPE_TRACING && prog_type != BPF_PROG_TYPE_EXT) ^~~~~~~~~~~~~~~~~ BPF_PROG_TYPE_XDP The bcc github releases seem to indicate that bcc supports kernels up to 5.6. I also defined libbpf (included as a submodule) like this: (define-public libbpf (let* ((commit "6a1615c263b679c17ecb292fa897f159e826dc10")) (package (name "libbpf") (version "0.0.8") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/libbpf/libbpf") (commit commit))) (sha256 (base32 "02vbpg9v5sjcw7ihximy63cjmz82q5izkp91i44m1qp6qj5qn4sr")))) (build-system gnu-build-system) (inputs `(("libelf" ,libelf) ("pkg-config" ,pkg-config) ("zlib" ,zlib))) (arguments `(#:tests? #f ; No tests #:make-flags (list (string-append "PREFIX=''") (string-append "DESTDIR=" (assoc-ref %outputs "out")) (string-append "CC=" (assoc-ref %build-inputs "gcc") "/bin/gcc")) #:phases (modify-phases %standard-phases (delete 'configure) (add-before 'build 'pre-build (lambda* (#:key inputs #:allow-other-keys) (substitute* "scripts/check-reallocarray.sh" (("/bin/rm" rm) (string-append (assoc-ref inputs "coreutils") rm))) (chdir "src") #t))))) (home-page "https://github.com/libbpf/libbpf") (synopsis "BPF CO-RE (Compile Once – Run Everywhere)") (description "Libbpf supports building BPF CO-RE-enabled applications, which, in contrast to BCC, do not require Clang/LLVM runtime being deployed to target servers and does not rely on kernel-devel headers being available.") (license `(,license:lgpl2.1 ,license:bsd-2))))) I'm not sure where to go from here. Thanks for the help! - John ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: BPF in linux-libre 2020-06-14 15:11 ` John Soo @ 2020-06-17 10:16 ` Mathieu Othacehe 2020-06-17 13:42 ` John Soo 2020-06-21 15:32 ` John Soo 0 siblings, 2 replies; 13+ messages in thread From: Mathieu Othacehe @ 2020-06-17 10:16 UTC (permalink / raw) To: John Soo; +Cc: Help Guix Hello John, > /tmp/guix-build-bcc-0.14.0.drv-0/source/src/cc/libbpf.c:694:58: error: ‘BPF_PROG_TYPE_EXT’ undeclared (first use in this function); did you mean ‘BPF_PROG_TYPE_XDP’? > if (prog_type != BPF_PROG_TYPE_TRACING && prog_type != BPF_PROG_TYPE_EXT) > ^~~~~~~~~~~~~~~~~ > BPF_PROG_TYPE_XDP > > The bcc github releases seem to indicate that bcc supports kernels up to > 5.6. Yes the issue here is that linux-libre-headers is in fact linux-libre-headers-5.4.20 which is too old. I tried to add linux-libre-headers-5.7 to the inputs. Even though it comes first in CPLUS_INCLUDE_PATH, GCC is picking the old headers. I'll have another look later. Thanks, Mathieu ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: BPF in linux-libre 2020-06-17 10:16 ` Mathieu Othacehe @ 2020-06-17 13:42 ` John Soo 2020-06-21 15:32 ` John Soo 1 sibling, 0 replies; 13+ messages in thread From: John Soo @ 2020-06-17 13:42 UTC (permalink / raw) To: Mathieu Othacehe; +Cc: Help Guix [-- Attachment #1: Type: text/plain, Size: 14220 bytes --] Hi Mathieu, Mathieu Othacehe <othacehe@gnu.org> writes: > Yes the issue here is that linux-libre-headers is in fact > linux-libre-headers-5.4.20 which is too old. > > I tried to add linux-libre-headers-5.7 to the inputs. Even though it > comes first in CPLUS_INCLUDE_PATH, GCC is picking the old headers. I found out that if LIBBPF_INCLUDE_DIR was specified instead of present as a submodule, the error about missing macros would occur. There is an open issue upstream regarding it so now bcc builds ok. It was definitely confusing because kernels since about 4.16 support bpf. Now there is a new problem building bpftrace: cd /tmp/guix-build-bpftrace-0.10.0-1.v0.10.0.drv-0/build/src && /gnu/store/89rj5fqcg48afgk99639ds602pgf92k4-cmake-minimal-3.16.5/bin/cmake -E cmake_link_script CMakeFiles/bpftrace.dir/link.txt --verbose=1 /gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/bin/c++ -O2 -g -DNDEBUG -rdynamic CMakeFiles/bpftrace.dir/attached_probe.cpp.o CMakeFiles/bpftrace.dir/bpffeature.cpp.o CMakeFiles/bpftrace.dir/bpftrace.cpp.o CMakeFiles/bpftrace.dir/btf.cpp.o CMakeFiles/bpftrace.dir/clang_parser.cpp.o CMakeFiles/bpftrace.dir/disasm.cpp.o CMakeFiles/bpftrace.dir/driver.cpp.o CMakeFiles/bpftrace.dir/fake_map.cpp.o CMakeFiles/bpftrace.dir/list.cpp.o CMakeFiles/bpftrace.dir/lockdown.cpp.o CMakeFiles/bpftrace.dir/main.cpp.o CMakeFiles/bpftrace.dir/map.cpp.o CMakeFiles/bpftrace.dir/mapkey.cpp.o CMakeFiles/bpftrace.dir/output.cpp.o CMakeFiles/bpftrace.dir/printf.cpp.o CMakeFiles/bpftrace.dir/resolve_cgroupid.cpp.o CMakeFiles/bpftrace.dir/signal.cpp.o CMakeFiles/bpftrace.dir/struct.cpp.o CMakeFiles/bpftrace.dir/tracepoint_format_parser.cpp.o CMakeFiles/bpftrace.dir/types.cpp.o CMakeFiles/bpftrace.dir/utils.cpp.o CMakeFiles/bpftrace.dir/bfd-disasm.cpp.o -o bpftrace -Wl,-rpath,::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -Wl,-Bstatic -lbfd -lopcodes arch/libarch.a ast/libast.a ../libparser.a ../resources/libresources.a -Wl,-Bdynamic -lbcc -lelf arch/libarch.a /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMOrcJIT.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMJITLink.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMCJIT.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMExecutionEngine.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMRuntimeDyld.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libclang.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMXCoreDisassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMXCoreCodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMXCoreDesc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMXCoreInfo.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMX86Disassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMX86AsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMX86CodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMX86Desc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMX86Utils.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMX86Info.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMWebAssemblyDisassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMWebAssemblyAsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMWebAssemblyCodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMWebAssemblyDesc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMWebAssemblyInfo.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMSystemZDisassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMSystemZAsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMSystemZCodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMSystemZDesc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMSystemZInfo.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMSparcDisassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMSparcAsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMSparcCodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMSparcDesc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMSparcInfo.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMRISCVDisassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMRISCVAsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMRISCVCodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMRISCVDesc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMRISCVUtils.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMRISCVInfo.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMPowerPCDisassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMPowerPCAsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMPowerPCCodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMPowerPCDesc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMPowerPCInfo.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMNVPTXCodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMNVPTXDesc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMNVPTXInfo.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMSP430Disassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMSP430AsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMSP430CodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMSP430Desc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMSP430Info.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMipsDisassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMipsAsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMipsCodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMipsDesc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMipsInfo.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMLanaiDisassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMLanaiCodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMLanaiAsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMLanaiDesc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMLanaiInfo.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMHexagonDisassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMHexagonCodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMHexagonAsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMHexagonDesc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMHexagonInfo.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMBPFDisassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMBPFAsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMARMDisassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMARMAsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMARMCodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMARMDesc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMARMUtils.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMARMInfo.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAMDGPUDisassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAMDGPUAsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAMDGPUCodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMIRParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMipo.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMLinker.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMInstrumentation.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMIRReader.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMVectorize.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAMDGPUDesc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAMDGPUUtils.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAMDGPUInfo.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAArch64Disassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMCDisassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAArch64AsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAArch64CodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMGlobalISel.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAArch64Desc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAArch64Utils.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAArch64Info.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMBPFCodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMSelectionDAG.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAsmPrinter.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMDebugInfoDWARF.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMCodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMScalarOpts.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMInstCombine.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAggressiveInstCombine.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMTransformUtils.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMBitWriter.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMTarget.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAnalysis.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMProfileData.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMObject.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMCParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMBitReader.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMBitstreamReader.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMBPFDesc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMC.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMDebugInfoCodeView.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMDebugInfoMSF.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMBPFInfo.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMCore.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMRemarks.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMBinaryFormat.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMSupport.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMDemangle.so.9 ld: /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libbfd.a(compress.o): undefined reference to symbol 'inflateEnd' ld: /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libz.so.1: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status make[2]: *** [src/CMakeFiles/bpftrace.dir/build.make:532: src/bpftrace] Error 1 make[2]: Leaving directory '/tmp/guix-build-bpftrace-0.10.0-1.v0.10.0.drv-0/build' make[1]: *** [CMakeFiles/Makefile2:363: src/CMakeFiles/bpftrace.dir/all] Error 2 make[1]: Leaving directory '/tmp/guix-build-bpftrace-0.10.0-1.v0.10.0.drv-0/build' make: *** [Makefile:133: all] Error 2 Updated patches attached. Thanks! - John [-- Attachment #2: 0001-gnu-Add-libbpf.patch --] [-- Type: text/x-patch, Size: 2814 bytes --] From 1fd0e237ec93c953b49fcafa819dcfc1198b8644 Mon Sep 17 00:00:00 2001 From: John Soo <jsoo1@asu.edu> Date: Sat, 13 Jun 2020 14:53:50 -0700 Subject: [PATCH 1/5] gnu: Add libbpf. * gnu/packages/linux.scm (libbpf): New variable. --- gnu/packages/linux.scm | 46 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index f2b35e33c5..cd4b712786 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -45,6 +45,7 @@ ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> ;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re> ;;; Copyright © 2020 Morgan Smith <Morgan.J.Smith@outlook.com> +;;; Copyright © 2020 John Soo <jsoo1@asu.edu> ;;; ;;; This file is part of GNU Guix. ;;; @@ -7127,3 +7128,48 @@ cache data store that is used by network file systems such as @code{AFS} and @code{NFS} to cache data locally on disk. The content of the cache is persistent over reboots.") (license license:gpl2+))) + +(define-public libbpf + (let* ((commit "6a1615c263b679c17ecb292fa897f159e826dc10")) + (package + (name "libbpf") + (version "0.0.8") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/libbpf/libbpf") + (commit commit))) + (sha256 + (base32 + "02vbpg9v5sjcw7ihximy63cjmz82q5izkp91i44m1qp6qj5qn4sr")))) + (build-system gnu-build-system) + (inputs + `(("libelf" ,libelf) + ("pkg-config" ,pkg-config) + ("zlib" ,zlib))) + (arguments + `(#:tests? #f ; No tests + #:make-flags + (list + (string-append "PREFIX=''") + (string-append "DESTDIR=" (assoc-ref %outputs "out")) + (string-append + "CC=" (assoc-ref %build-inputs "gcc") "/bin/gcc")) + #:phases + (modify-phases %standard-phases + (delete 'configure) + (add-before 'build 'pre-build + (lambda* (#:key inputs #:allow-other-keys) + (substitute* "scripts/check-reallocarray.sh" + (("/bin/rm" rm) + (string-append (assoc-ref inputs "coreutils") rm))) + (chdir "src") + #t))))) + (home-page "https://github.com/libbpf/libbpf") + (synopsis "BPF CO-RE (Compile Once – Run Everywhere)") + (description + "Libbpf supports building BPF CO-RE-enabled applications, which, in +contrast to BCC, do not require Clang/LLVM runtime being deployed to target +servers and does not rely on kernel-devel headers being available.") + (license `(,license:lgpl2.1 ,license:bsd-2))))) -- 2.26.2 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #3: 0002-gnu-Add-bpf-extra-linux-options.patch --] [-- Type: text/x-patch, Size: 1339 bytes --] From f0eff687adee1494c3d642379292dae7cd2a85e6 Mon Sep 17 00:00:00 2001 From: John Soo <jsoo1@asu.edu> Date: Sat, 13 Jun 2020 22:52:55 -0700 Subject: [PATCH 2/5] gnu: Add %bpf-extra-linux-options. * gnu/packages/linux (%bpf-extra-linux-options): New variable. --- gnu/packages/linux.scm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index cd4b712786..bb4f7af81f 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -619,6 +619,22 @@ for ARCH and optionally VARIANT, or #f if there is no such configuration." ("CONFIG_CIFS" . m) ("CONFIG_9P_FS" . m))) +;; See https://github.com/iovisor/bcc/blob/master/INSTALL.md#kernel-configuration +(define %bpf-extra-linux-options + `(("CONFIG_BPF" . #t) + ("CONFIG_BPF_SYSCALL" . #t) + ;; optional, for tc filters + ("CONFIG_NET_CLS_BPF" . m) + ;; optional, for tc actions + ("CONFIG_NET_ACT_BPF" . m) + ("CONFIG_BPF_JIT" . #t) + ;; for Linux kernel versions 4.1 through 4.6 + ;; ("CONFIG_HAVE_BPF_JIT" . y) + ;; for Linux kernel versions 4.7 and later + ("CONFIG_HAVE_EBPF_JIT" . #t) + ;; optional, for kprobes + ("CONFIG_BPF_EVENTS" . #t))) + (define (config->string options) (string-join (map (match-lambda ((option . 'm) -- 2.26.2 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #4: 0003-gnu-Add-linux-libre-with-bpf.patch --] [-- Type: text/x-patch, Size: 1248 bytes --] From bf93994a7c1eb3e910061d5c6de8a86d0bc8f331 Mon Sep 17 00:00:00 2001 From: John Soo <jsoo1@asu.edu> Date: Sat, 13 Jun 2020 22:54:24 -0700 Subject: [PATCH 3/5] gnu: Add linux-libre-with-bpf. * gnu/packages/linux.scm (linux-libre-with-bpf): New variable. --- gnu/packages/linux.scm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index bb4f7af81f..5c379e7cd3 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -7145,6 +7145,16 @@ cache data store that is used by network file systems such as @code{AFS} and persistent over reboots.") (license license:gpl2+))) +(define-public linux-libre-with-bpf + (make-linux-libre* linux-libre-5.4-version + linux-libre-5.4-source + '("x86_64-linux" "i686-linux" "armhf-linux" "aarch64-linux" "riscv64-linux") + #:extra-version "bpf" + #:configuration-file kernel-config + #:extra-options + (append %bpf-extra-linux-options + %default-extra-linux-options))) + (define-public libbpf (let* ((commit "6a1615c263b679c17ecb292fa897f159e826dc10")) (package -- 2.26.2 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #5: 0004-gnu-Add-bcc.patch --] [-- Type: text/x-patch, Size: 3924 bytes --] From a4a3836ab1cb781ba7138d4ddc213ac18fe17db4 Mon Sep 17 00:00:00 2001 From: John Soo <jsoo1@asu.edu> Date: Sat, 13 Jun 2020 23:16:11 -0700 Subject: [PATCH 4/5] gnu: Add bcc. * gnu/packages/linux.scm (bcc): New variable. --- gnu/packages/linux.scm | 65 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index 5c379e7cd3..362e041ba9 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -97,6 +97,8 @@ #:use-module (gnu packages haskell-xyz) #:use-module (gnu packages libunwind) #:use-module (gnu packages libusb) + #:use-module (gnu packages llvm) + #:use-module (gnu packages lua) #:use-module (gnu packages man) #:use-module (gnu packages maths) #:use-module (gnu packages multiprecision) @@ -131,6 +133,7 @@ #:use-module (gnu packages rsync) #:use-module (gnu packages selinux) #:use-module (gnu packages swig) + #:use-module (gnu packages version-control) #:use-module (guix build-system cmake) #:use-module (guix build-system gnu) #:use-module (guix build-system go) @@ -7199,3 +7202,65 @@ persistent over reboots.") contrast to BCC, do not require Clang/LLVM runtime being deployed to target servers and does not rely on kernel-devel headers being available.") (license `(,license:lgpl2.1 ,license:bsd-2))))) + +(define-public bcc + (let* ((ver "0.14.0") + (commit (string-append "v" ver)) + (revision "1")) + (package + (name "bcc") + (version (git-version ver revision commit)) + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/iovisor/bcc") + (commit commit))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "08m21avzamr48qwshd4r5hlcckk1kvgrb1i6qw373b7la89jf5an")))) + (build-system cmake-build-system) + (inputs + `(;; TODO: package optional integrations + ;; ("arping" ,argping) + ;; ("netperf" ,netperf) + ;; ("iperf" ,iperf) or ("iperf3" ,iperf3) + ("bison" ,bison) + ("clang-toolchain" ,clang-toolchain) + ("flex" ,flex) + ;; FIXME: Timestamp some other way. + ("git" ,git) + ("libbpf" ,(package-source libbpf)) + ;; LibElf required but libelf does not contain + ;; archives, only object files. + ;; https://github.com/iovisor/bcc/issues/504 + ("elfutils" ,elfutils) + ("linux-libre-headers" ,linux-libre-headers) + ("luajit" ,luajit) + ("python-wrapper" ,python-wrapper))) + (arguments + `(;; Tests all require sudo and a "standard" file heirarchy + #:tests? #f + ;; LIBBPF_INCLUDE_DIR should work with the output of libbpf - + ;; i.e. ,libbpf instead of ,(package-source libbpf) in inputs + ;; but it seems there could be a bug + ;; #:configure-flags + ;; (list + ;; (string-append + ;; "-DLIBBPF_INCLUDE_DIR=" (assoc-ref %build-inputs "libbpf") "/include")) + #:phases + (modify-phases %standard-phases + (add-after 'unpack 'copy-libbpf + (lambda* (#:key inputs #:allow-other-keys) + (delete-file-recursively "src/cc/libbpf") + (copy-recursively (assoc-ref inputs "libbpf") "src/cc/libbpf")))))) + (home-page "https://github.com/iovisor/bcc") + (synopsis "Tools for BPF on Linux") + (description + "BCC is a toolkit for creating efficient kernel tracing and +manipulation programs, and includes several useful tools and examples. It +makes use of extended BPF (Berkeley Packet Filters), formally known as eBPF, a +new feature that was first added to Linux 3.15. Much of what BCC uses requires +Linux 4.1 and above.") + (license license:asl2.0)))) -- 2.26.2 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #6: 0005-WIP-gnu-Add-bpftrace.patch --] [-- Type: text/x-patch, Size: 2628 bytes --] From b8b02baf0b2bfa42e0b2d19a47bb5895e0004f93 Mon Sep 17 00:00:00 2001 From: John Soo <jsoo1@asu.edu> Date: Sat, 13 Jun 2020 23:16:56 -0700 Subject: [PATCH 5/5] [WIP] gnu: Add bpftrace. * gnu/packages/linux.scm (bpftrace): New variable. --- gnu/packages/linux.scm | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index 362e041ba9..b7956f3d61 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -7264,3 +7264,48 @@ makes use of extended BPF (Berkeley Packet Filters), formally known as eBPF, a new feature that was first added to Linux 3.15. Much of what BCC uses requires Linux 4.1 and above.") (license license:asl2.0)))) + +(define-public bpftrace + (let* ((ver "0.10.0") + (commit (string-append "v" ver)) + (revision "1")) + (package + (name "bpftrace") + (version (git-version ver revision commit)) + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/iovisor/bpftrace") + (commit commit))) + (file-name (git-file-name name ver)) + (sha256 + (base32 + "023ardywbw5w8815j2ny9rrp2xlpxndqaa7v2njjm8109p7ilsdn")))) + (build-system cmake-build-system) + (inputs + `(("bcc" ,bcc) + ("bison" ,bison) + ("clang-toolchain" ,clang-toolchain) + ("elfutils" ,elfutils) + ("flex" ,flex) + ;; FIXME: Tests require googletest but not from system + ;; ("googletest" ,googletest) + ("linux-libre-headers" ,linux-libre-headers))) + (arguments + `(#:configure-flags + '(;; FIXME: Make tests not clone the googletest repository + "-DBUILD_TESTING=OFF" + "-DLIBBFD_DISASM_FOUR_ARGS_SIGNATURE=ON"))) + (home-page "https://github.com/iovisor/bpftrace") + (synopsis "High-level tracing language for Linux eBPF") + (description + "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. bpftrace was +created by Alastair Robertson.") + (license license:asl2.0)))) -- 2.26.2 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: BPF in linux-libre 2020-06-17 10:16 ` Mathieu Othacehe 2020-06-17 13:42 ` John Soo @ 2020-06-21 15:32 ` John Soo 2020-06-26 10:50 ` Mathieu Othacehe 1 sibling, 1 reply; 13+ messages in thread From: John Soo @ 2020-06-21 15:32 UTC (permalink / raw) To: Mathieu Othacehe; +Cc: Help Guix Hi Mathieu and Guix, I think I understand this error a little better now. It seems like zlib is not being resolved correctly. /gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/bin/c++ -O2 -g -DNDEBUG -rdynamic CMakeFiles/bpftrace.dir/attached_probe.cpp.o CMakeFiles/bpftrace.dir/bpffeature.cpp.o CMakeFiles/bpftrace.dir/bpftrace.cpp.o CMakeFiles/bpftrace.dir/btf.cpp.o CMakeFiles/bpftrace.dir/clang_parser.cpp.o CMakeFiles/bpftrace.dir/disasm.cpp.o CMakeFiles/bpftrace.dir/driver.cpp.o CMakeFiles/bpftrace.dir/fake_map.cpp.o CMakeFiles/bpftrace.dir/list.cpp.o CMakeFiles/bpftrace.dir/lockdown.cpp.o CMakeFiles/bpftrace.dir/main.cpp.o CMakeFiles/bpftrace.dir/map.cpp.o CMakeFiles/bpftrace.dir/mapkey.cpp.o CMakeFiles/bpftrace.dir/output.cpp.o CMakeFiles/bpftrace.dir/printf.cpp.o CMakeFiles/bpftrace.dir/resolve_cgroupid.cpp.o CMakeFiles/bpftrace.dir/signal.cpp.o CMakeFiles/bpftrace.dir/struct.cpp.o CMakeFiles/bpftrace.dir/tracepoint_format_parser.cpp.o CMakeFiles/bpftrace.dir/types.cpp.o CMakeFiles/bpftrace.dir/utils.cpp.o CMakeFiles/bpftrace.dir/bfd-disasm.cpp.o -o bpftrace -Wl,-rpath,::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -Wl,-Bstatic -lbfd -lopcodes arch/libarch.a ast/libast.a ../libparser.a ../resources/libresources.a -Wl,-Bdynamic -lbcc -lelf arch/libarch.a /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMOrcJIT.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMJITLink.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMCJIT.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMExecutionEngine.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMRuntimeDyld.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libclang.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMXCoreDisassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMXCoreCodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMXCoreDesc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMXCoreInfo.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMX86Disassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMX86AsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMX86CodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMX86Desc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMX86Utils.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMX86Info.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMWebAssemblyDisassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMWebAssemblyAsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMWebAssemblyCodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMWebAssemblyDesc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMWebAssemblyInfo.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMSystemZDisassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMSystemZAsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMSystemZCodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMSystemZDesc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMSystemZInfo.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMSparcDisassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMSparcAsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMSparcCodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMSparcDesc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMSparcInfo.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMRISCVDisassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMRISCVAsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMRISCVCodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMRISCVDesc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMRISCVUtils.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMRISCVInfo.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMPowerPCDisassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMPowerPCAsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMPowerPCCodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMPowerPCDesc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMPowerPCInfo.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMNVPTXCodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMNVPTXDesc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMNVPTXInfo.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMSP430Disassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMSP430AsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMSP430CodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMSP430Desc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMSP430Info.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMipsDisassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMipsAsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMipsCodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMipsDesc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMipsInfo.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMLanaiDisassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMLanaiCodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMLanaiAsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMLanaiDesc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMLanaiInfo.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMHexagonDisassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMHexagonCodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMHexagonAsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMHexagonDesc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMHexagonInfo.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMBPFDisassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMBPFAsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMARMDisassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMARMAsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMARMCodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMARMDesc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMARMUtils.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMARMInfo.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAMDGPUDisassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAMDGPUAsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAMDGPUCodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMIRParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMipo.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMLinker.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMInstrumentation.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMIRReader.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMVectorize.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAMDGPUDesc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAMDGPUUtils.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAMDGPUInfo.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAArch64Disassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMCDisassembler.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAArch64AsmParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAArch64CodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMGlobalISel.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAArch64Desc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAArch64Utils.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAArch64Info.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMBPFCodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMSelectionDAG.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAsmPrinter.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMDebugInfoDWARF.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMCodeGen.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMScalarOpts.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMInstCombine.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAggressiveInstCombine.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMTransformUtils.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMBitWriter.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMTarget.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMAnalysis.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMProfileData.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMObject.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMCParser.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMBitReader.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMBitstreamReader.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMBPFDesc.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMMC.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMDebugInfoCodeView.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMDebugInfoMSF.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMBPFInfo.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMCore.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMRemarks.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMBinaryFormat.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMSupport.so.9 /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libLLVMDemangle.so.9 ld: /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libbfd.a(compress.o): undefined reference to symbol 'inflateEnd' ld: /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libz.so.1: error adding symbols: DSO missing from command line pft\x03 I added zlib to the inputs of bpftrace but still the same error. Are there any CMake experts out there that can tell if there is a flag or option to use here? Is this an upstream issue? Thanks! - John ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: BPF in linux-libre 2020-06-21 15:32 ` John Soo @ 2020-06-26 10:50 ` Mathieu Othacehe 2020-06-28 20:24 ` John Soo ` (2 more replies) 0 siblings, 3 replies; 13+ messages in thread From: Mathieu Othacehe @ 2020-06-26 10:50 UTC (permalink / raw) To: John Soo; +Cc: Help Guix [-- Attachment #1: Type: text/plain, Size: 1321 bytes --] Hello John, > ld: /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libbfd.a(compress.o): undefined reference to symbol 'inflateEnd' > ld: /gnu/store/80y2wbx9lrhvwp41nnyjjsb4g9ff8avn-clang-toolchain-9.0.1/lib/libz.so.1: error adding symbols: DSO missing from command line > > I added zlib to the inputs of bpftrace but still the same error. Are > there any CMake experts out there that can tell if there is a flag or > option to use here? Is this an upstream issue? By default, a dynamic version of bpftrace is built. However, as we do not provide a libbpf.so, it falls back on libbpf.a. There's a comment in FindLibBfd.cmake which says: --8<---------------cut here---------------start------------->8--- # libbfd.a is not statically linked with libiberty.a or libz.a so we must manually # do it. Furthermore, libbfd uses some libc symbols that we must manually # link against if we're not using static libc (which includes such symbols). --8<---------------cut here---------------end--------------->8--- So when STATIC_LINKING is ON, they add "libz" to the required libraries. It would be preferable to avoid building a static bpftrace, so I tried to provide a dynamic version of libbpf. There's still a failure at validate-runpath phase that need to be fixed, not sure why. Thanks, Mathieu [-- Attachment #2: diff --] [-- Type: application/octet-stream, Size: 2029 bytes --] diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm index 50e426fadf..42bba03b2a 100644 --- a/gnu/packages/base.scm +++ b/gnu/packages/base.scm @@ -601,6 +601,17 @@ included.") (inputs `(("gcc:lib" ,gcc "lib"))))) +(define-public binutils-shared + (package + (inherit binutils) + (name "binutils-shared") + (arguments + `(#:validate-runpath? #f + ,@(substitute-keyword-arguments (package-arguments binutils) + ((#:configure-flags flags) + `(cons "--enable-shared" ,flags))))) + (properties '()))) + (define* (make-ld-wrapper name #:key (target (const #f)) binutils diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index 8f0b9ac018..7f30e3750c 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -7169,6 +7169,7 @@ persistent over reboots.") (list (string-append "PREFIX=''") (string-append "DESTDIR=" (assoc-ref %outputs "out")) + (string-append "LIBDIR=/lib") (string-append "CC=" (assoc-ref %build-inputs "gcc") "/bin/gcc")) #:phases @@ -7272,8 +7273,11 @@ Linux 4.1 and above.") (inputs `(("bcc" ,bcc) ("bison" ,bison) + ("binutils" ,binutils-shared) ("clang-toolchain" ,clang-toolchain) ("elfutils" ,elfutils) + ("libiberty" ,libiberty) + ("libbpf" ,libbpf) ("flex" ,flex) ;; FIXME: Tests require googletest but not from system ;; ("googletest" ,googletest) @@ -7282,7 +7286,8 @@ Linux 4.1 and above.") `(#:configure-flags '(;; FIXME: Make tests not clone the googletest repository "-DBUILD_TESTING=OFF" - "-DLIBBFD_DISASM_FOUR_ARGS_SIGNATURE=ON"))) + "-DLIBBFD_DISASM_FOUR_ARGS_SIGNATURE=ON") + #:tests? #f)) (home-page "https://github.com/iovisor/bpftrace") (synopsis "High-level tracing language for Linux eBPF") (description ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: BPF in linux-libre 2020-06-26 10:50 ` Mathieu Othacehe @ 2020-06-28 20:24 ` John Soo 2020-07-01 5:40 ` John Soo 2020-07-03 16:01 ` John Soo 2 siblings, 0 replies; 13+ messages in thread From: John Soo @ 2020-06-28 20:24 UTC (permalink / raw) To: Mathieu Othacehe; +Cc: Help Guix Thanks Mathieu, I’ll take a look in a few weeks if you can’t figure it out. I’m probably going to take a quick break from bpf for a couple weeks as I have become extremely busy. Thanks for your help. Oh also I discussed issues I was having on the bpftrace irc and they pointed me to this pull request which specifies all the dependencies and their configurations. Maybe we can learn something from it: https://github.com/iovisor/bpftrace/pull/1095 - John ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: BPF in linux-libre 2020-06-26 10:50 ` Mathieu Othacehe 2020-06-28 20:24 ` John Soo @ 2020-07-01 5:40 ` John Soo 2020-07-03 16:01 ` John Soo 2 siblings, 0 replies; 13+ messages in thread From: John Soo @ 2020-07-01 5:40 UTC (permalink / raw) To: Mathieu Othacehe; +Cc: Help Guix [-- Attachment #1: Type: text/plain, Size: 272 bytes --] Hi Mathieu and Guix, I forgot to mention that I do have an updated patchset where libbpf is found. I've attached my work. This is I think closer to the desired effect but now there is a compile error I do not understand. I hope you can get further than I did. - John [-- Attachment #2: 0001-gnu-Add-libbpf.patch --] [-- Type: text/x-patch, Size: 2814 bytes --] From 6560dc2a5eedb3040bdd5fba8d8b6950b7a2b6d1 Mon Sep 17 00:00:00 2001 From: John Soo <jsoo1@asu.edu> Date: Sat, 13 Jun 2020 14:53:50 -0700 Subject: [PATCH 1/5] gnu: Add libbpf. * gnu/packages/linux.scm (libbpf): New variable. --- gnu/packages/linux.scm | 46 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index cadfd186a1..c0ac8f24bc 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -45,6 +45,7 @@ ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> ;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re> ;;; Copyright © 2020 Morgan Smith <Morgan.J.Smith@outlook.com> +;;; Copyright © 2020 John Soo <jsoo1@asu.edu> ;;; ;;; This file is part of GNU Guix. ;;; @@ -7139,3 +7140,48 @@ cache data store that is used by network file systems such as @code{AFS} and @code{NFS} to cache data locally on disk. The content of the cache is persistent over reboots.") (license license:gpl2+))) + +(define-public libbpf + (let* ((commit "6a1615c263b679c17ecb292fa897f159e826dc10")) + (package + (name "libbpf") + (version "0.0.8") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/libbpf/libbpf") + (commit commit))) + (sha256 + (base32 + "02vbpg9v5sjcw7ihximy63cjmz82q5izkp91i44m1qp6qj5qn4sr")))) + (build-system gnu-build-system) + (inputs + `(("libelf" ,libelf) + ("pkg-config" ,pkg-config) + ("zlib" ,zlib))) + (arguments + `(#:tests? #f ; No tests + #:make-flags + (list + (string-append "PREFIX=''") + (string-append "DESTDIR=" (assoc-ref %outputs "out")) + (string-append + "CC=" (assoc-ref %build-inputs "gcc") "/bin/gcc")) + #:phases + (modify-phases %standard-phases + (delete 'configure) + (add-before 'build 'pre-build + (lambda* (#:key inputs #:allow-other-keys) + (substitute* "scripts/check-reallocarray.sh" + (("/bin/rm" rm) + (string-append (assoc-ref inputs "coreutils") rm))) + (chdir "src") + #t))))) + (home-page "https://github.com/libbpf/libbpf") + (synopsis "BPF CO-RE (Compile Once – Run Everywhere)") + (description + "Libbpf supports building BPF CO-RE-enabled applications, which, in +contrast to BCC, do not require Clang/LLVM runtime being deployed to target +servers and does not rely on kernel-devel headers being available.") + (license `(,license:lgpl2.1 ,license:bsd-2))))) -- 2.26.2 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #3: 0002-gnu-Add-bpf-extra-linux-options.patch --] [-- Type: text/x-patch, Size: 1339 bytes --] From 124267a629c30d0acb5e5c931772cc8d0f3c43ac Mon Sep 17 00:00:00 2001 From: John Soo <jsoo1@asu.edu> Date: Sat, 13 Jun 2020 22:52:55 -0700 Subject: [PATCH 2/5] gnu: Add %bpf-extra-linux-options. * gnu/packages/linux (%bpf-extra-linux-options): New variable. --- gnu/packages/linux.scm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index c0ac8f24bc..4daa371c6b 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -619,6 +619,22 @@ for ARCH and optionally VARIANT, or #f if there is no such configuration." ("CONFIG_CIFS" . m) ("CONFIG_9P_FS" . m))) +;; See https://github.com/iovisor/bcc/blob/master/INSTALL.md#kernel-configuration +(define %bpf-extra-linux-options + `(("CONFIG_BPF" . #t) + ("CONFIG_BPF_SYSCALL" . #t) + ;; optional, for tc filters + ("CONFIG_NET_CLS_BPF" . m) + ;; optional, for tc actions + ("CONFIG_NET_ACT_BPF" . m) + ("CONFIG_BPF_JIT" . #t) + ;; for Linux kernel versions 4.1 through 4.6 + ;; ("CONFIG_HAVE_BPF_JIT" . y) + ;; for Linux kernel versions 4.7 and later + ("CONFIG_HAVE_EBPF_JIT" . #t) + ;; optional, for kprobes + ("CONFIG_BPF_EVENTS" . #t))) + (define (config->string options) (string-join (map (match-lambda ((option . 'm) -- 2.26.2 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #4: 0003-gnu-Add-linux-libre-with-bpf.patch --] [-- Type: text/x-patch, Size: 1248 bytes --] From 88c88d787a399069f0554c8635f1f3496a9fd1e2 Mon Sep 17 00:00:00 2001 From: John Soo <jsoo1@asu.edu> Date: Sat, 13 Jun 2020 22:54:24 -0700 Subject: [PATCH 3/5] gnu: Add linux-libre-with-bpf. * gnu/packages/linux.scm (linux-libre-with-bpf): New variable. --- gnu/packages/linux.scm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index 4daa371c6b..f3eec978ec 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -7157,6 +7157,16 @@ cache data store that is used by network file systems such as @code{AFS} and persistent over reboots.") (license license:gpl2+))) +(define-public linux-libre-with-bpf + (make-linux-libre* linux-libre-5.4-version + linux-libre-5.4-source + '("x86_64-linux" "i686-linux" "armhf-linux" "aarch64-linux" "riscv64-linux") + #:extra-version "bpf" + #:configuration-file kernel-config + #:extra-options + (append %bpf-extra-linux-options + %default-extra-linux-options))) + (define-public libbpf (let* ((commit "6a1615c263b679c17ecb292fa897f159e826dc10")) (package -- 2.26.2 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #5: 0004-gnu-Add-bcc.patch --] [-- Type: text/x-patch, Size: 3924 bytes --] From 0358dccc866a392512ddb15f9fee0e24e6bc837c Mon Sep 17 00:00:00 2001 From: John Soo <jsoo1@asu.edu> Date: Sat, 13 Jun 2020 23:16:11 -0700 Subject: [PATCH 4/5] gnu: Add bcc. * gnu/packages/linux.scm (bcc): New variable. --- gnu/packages/linux.scm | 65 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index f3eec978ec..0b8b08883a 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -97,6 +97,8 @@ #:use-module (gnu packages haskell-xyz) #:use-module (gnu packages libunwind) #:use-module (gnu packages libusb) + #:use-module (gnu packages llvm) + #:use-module (gnu packages lua) #:use-module (gnu packages man) #:use-module (gnu packages maths) #:use-module (gnu packages multiprecision) @@ -131,6 +133,7 @@ #:use-module (gnu packages rsync) #:use-module (gnu packages selinux) #:use-module (gnu packages swig) + #:use-module (gnu packages version-control) #:use-module (guix build-system cmake) #:use-module (guix build-system gnu) #:use-module (guix build-system go) @@ -7211,3 +7214,65 @@ persistent over reboots.") contrast to BCC, do not require Clang/LLVM runtime being deployed to target servers and does not rely on kernel-devel headers being available.") (license `(,license:lgpl2.1 ,license:bsd-2))))) + +(define-public bcc + (let* ((ver "0.14.0") + (commit (string-append "v" ver)) + (revision "1")) + (package + (name "bcc") + (version (git-version ver revision commit)) + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/iovisor/bcc") + (commit commit))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "08m21avzamr48qwshd4r5hlcckk1kvgrb1i6qw373b7la89jf5an")))) + (build-system cmake-build-system) + (inputs + `(;; TODO: package optional integrations + ;; ("arping" ,argping) + ;; ("netperf" ,netperf) + ;; ("iperf" ,iperf) or ("iperf3" ,iperf3) + ("bison" ,bison) + ("clang-toolchain" ,clang-toolchain) + ("flex" ,flex) + ;; FIXME: Timestamp some other way. + ("git" ,git) + ("libbpf" ,(package-source libbpf)) + ;; LibElf required but libelf does not contain + ;; archives, only object files. + ;; https://github.com/iovisor/bcc/issues/504 + ("elfutils" ,elfutils) + ("linux-libre-headers" ,linux-libre-headers) + ("luajit" ,luajit) + ("python-wrapper" ,python-wrapper))) + (arguments + `(;; Tests all require sudo and a "standard" file heirarchy + #:tests? #f + ;; LIBBPF_INCLUDE_DIR should work with the output of libbpf - + ;; i.e. ,libbpf instead of ,(package-source libbpf) in inputs + ;; but it seems there could be a bug + ;; #:configure-flags + ;; (list + ;; (string-append + ;; "-DLIBBPF_INCLUDE_DIR=" (assoc-ref %build-inputs "libbpf") "/include")) + #:phases + (modify-phases %standard-phases + (add-after 'unpack 'copy-libbpf + (lambda* (#:key inputs #:allow-other-keys) + (delete-file-recursively "src/cc/libbpf") + (copy-recursively (assoc-ref inputs "libbpf") "src/cc/libbpf")))))) + (home-page "https://github.com/iovisor/bcc") + (synopsis "Tools for BPF on Linux") + (description + "BCC is a toolkit for creating efficient kernel tracing and +manipulation programs, and includes several useful tools and examples. It +makes use of extended BPF (Berkeley Packet Filters), formally known as eBPF, a +new feature that was first added to Linux 3.15. Much of what BCC uses requires +Linux 4.1 and above.") + (license license:asl2.0)))) -- 2.26.2 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #6: 0005-WIP-gnu-Add-bpftrace.patch --] [-- Type: text/x-patch, Size: 3405 bytes --] From 3176597e20946e7b3564479f655ac51b65109b5f Mon Sep 17 00:00:00 2001 From: John Soo <jsoo1@asu.edu> Date: Sat, 13 Jun 2020 23:16:56 -0700 Subject: [PATCH 5/5] [WIP] gnu: Add bpftrace. * gnu/packages/linux.scm (bpftrace): New variable. --- gnu/packages/linux.scm | 60 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index 0b8b08883a..00c4c41c82 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -7276,3 +7276,63 @@ makes use of extended BPF (Berkeley Packet Filters), formally known as eBPF, a new feature that was first added to Linux 3.15. Much of what BCC uses requires Linux 4.1 and above.") (license license:asl2.0)))) + +(define-public bpftrace + (let* ((ver "0.10.0") + (commit (string-append "v" ver)) + (revision "1")) + (package + (name "bpftrace") + (version (git-version ver revision commit)) + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/iovisor/bpftrace") + (commit commit))) + (file-name (git-file-name name ver)) + (sha256 + (base32 + "023ardywbw5w8815j2ny9rrp2xlpxndqaa7v2njjm8109p7ilsdn")))) + (build-system cmake-build-system) + (inputs + `(("bcc" ,bcc) + ("binutils" ,binutils) + ("bison" ,bison) + ("clang-toolchain" ,clang-toolchain) + ("elfutils" ,elfutils) + ("flex" ,flex) + ;; FIXME: Tests require googletest but not from system + ;; ("googletest" ,googletest) + ("libbpf" ,libbpf) + ("libiberty" ,libiberty) + ("linux-libre-headers" ,linux-libre-headers) + ("zlib" ,zlib))) + (arguments + `(#:configure-flags + (let ((libbpf (assoc-ref %build-inputs "libbpf")) + (zlib (assoc-ref %build-inputs "zlib")) + (binutils (assoc-ref %build-inputs "binutils"))) + `(;; FIXME: Make tests not clone the googletest repository + "-DBUILD_TESTING=OFF" + "-DSTATIC_LINKING=ON" + ;; ,(string-append "-DLIBBFD_LIBRARY=" binutils) + ;; ,(string-append "-DLIBBFD_INCLUDE_DIRS=" binutils "/include") + ,(string-append "-DLIBZ_LIBRARIES=" zlib "/lib") + ;; ,(string-append "-DLIBBPF_LIBRARY=" libbpf) + ;; ,(string-append "-DLIBBPF_LIBRARIES=" libbpf "/lib") + ;; ,(string-append "-DLIBBPF_INCLUDE_DIRS=" libbpf "/include") + ;; "-DLIBBFD_DISASM_FOUR_ARGS_SIGNATURE=ON" + )))) + (home-page "https://github.com/iovisor/bpftrace") + (synopsis "High-level tracing language for Linux eBPF") + (description + "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. bpftrace was +created by Alastair Robertson.") + (license license:asl2.0)))) -- 2.26.2 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: BPF in linux-libre 2020-06-26 10:50 ` Mathieu Othacehe 2020-06-28 20:24 ` John Soo 2020-07-01 5:40 ` John Soo @ 2020-07-03 16:01 ` John Soo 2020-07-05 8:18 ` Mathieu Othacehe 2020-07-05 8:20 ` Mathieu Othacehe 2 siblings, 2 replies; 13+ messages in thread From: John Soo @ 2020-07-03 16:01 UTC (permalink / raw) To: Mathieu Othacehe; +Cc: Help Guix [-- Attachment #1: Type: text/plain, Size: 442 bytes --] Hi Mathieu and Guix, I managed to build bpftrace finally. I set the build flag HAVE_BFD_DISASM to false for the package. I am not sure what the implications will be. No version of libbfd I used (binutils, clang-toolchain, gcc-toolchain) was free of link errors, so using HAVE_BFD_DISASM=false just disables the parts that use libbfd. I have not used the package yet, does anyone want to test it out? Patches attached. Thanks! - John [-- Attachment #2: 0001-gnu-Add-libbpf.patch --] [-- Type: text/x-patch, Size: 2814 bytes --] From 6560dc2a5eedb3040bdd5fba8d8b6950b7a2b6d1 Mon Sep 17 00:00:00 2001 From: John Soo <jsoo1@asu.edu> Date: Sat, 13 Jun 2020 14:53:50 -0700 Subject: [PATCH 1/5] gnu: Add libbpf. * gnu/packages/linux.scm (libbpf): New variable. --- gnu/packages/linux.scm | 46 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index cadfd186a1..c0ac8f24bc 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -45,6 +45,7 @@ ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> ;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re> ;;; Copyright © 2020 Morgan Smith <Morgan.J.Smith@outlook.com> +;;; Copyright © 2020 John Soo <jsoo1@asu.edu> ;;; ;;; This file is part of GNU Guix. ;;; @@ -7139,3 +7140,48 @@ cache data store that is used by network file systems such as @code{AFS} and @code{NFS} to cache data locally on disk. The content of the cache is persistent over reboots.") (license license:gpl2+))) + +(define-public libbpf + (let* ((commit "6a1615c263b679c17ecb292fa897f159e826dc10")) + (package + (name "libbpf") + (version "0.0.8") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/libbpf/libbpf") + (commit commit))) + (sha256 + (base32 + "02vbpg9v5sjcw7ihximy63cjmz82q5izkp91i44m1qp6qj5qn4sr")))) + (build-system gnu-build-system) + (inputs + `(("libelf" ,libelf) + ("pkg-config" ,pkg-config) + ("zlib" ,zlib))) + (arguments + `(#:tests? #f ; No tests + #:make-flags + (list + (string-append "PREFIX=''") + (string-append "DESTDIR=" (assoc-ref %outputs "out")) + (string-append + "CC=" (assoc-ref %build-inputs "gcc") "/bin/gcc")) + #:phases + (modify-phases %standard-phases + (delete 'configure) + (add-before 'build 'pre-build + (lambda* (#:key inputs #:allow-other-keys) + (substitute* "scripts/check-reallocarray.sh" + (("/bin/rm" rm) + (string-append (assoc-ref inputs "coreutils") rm))) + (chdir "src") + #t))))) + (home-page "https://github.com/libbpf/libbpf") + (synopsis "BPF CO-RE (Compile Once – Run Everywhere)") + (description + "Libbpf supports building BPF CO-RE-enabled applications, which, in +contrast to BCC, do not require Clang/LLVM runtime being deployed to target +servers and does not rely on kernel-devel headers being available.") + (license `(,license:lgpl2.1 ,license:bsd-2))))) -- 2.26.2 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #3: 0002-gnu-Add-bpf-extra-linux-options.patch --] [-- Type: text/x-patch, Size: 1339 bytes --] From 124267a629c30d0acb5e5c931772cc8d0f3c43ac Mon Sep 17 00:00:00 2001 From: John Soo <jsoo1@asu.edu> Date: Sat, 13 Jun 2020 22:52:55 -0700 Subject: [PATCH 2/5] gnu: Add %bpf-extra-linux-options. * gnu/packages/linux (%bpf-extra-linux-options): New variable. --- gnu/packages/linux.scm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index c0ac8f24bc..4daa371c6b 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -619,6 +619,22 @@ for ARCH and optionally VARIANT, or #f if there is no such configuration." ("CONFIG_CIFS" . m) ("CONFIG_9P_FS" . m))) +;; See https://github.com/iovisor/bcc/blob/master/INSTALL.md#kernel-configuration +(define %bpf-extra-linux-options + `(("CONFIG_BPF" . #t) + ("CONFIG_BPF_SYSCALL" . #t) + ;; optional, for tc filters + ("CONFIG_NET_CLS_BPF" . m) + ;; optional, for tc actions + ("CONFIG_NET_ACT_BPF" . m) + ("CONFIG_BPF_JIT" . #t) + ;; for Linux kernel versions 4.1 through 4.6 + ;; ("CONFIG_HAVE_BPF_JIT" . y) + ;; for Linux kernel versions 4.7 and later + ("CONFIG_HAVE_EBPF_JIT" . #t) + ;; optional, for kprobes + ("CONFIG_BPF_EVENTS" . #t))) + (define (config->string options) (string-join (map (match-lambda ((option . 'm) -- 2.26.2 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #4: 0003-gnu-Add-linux-libre-with-bpf.patch --] [-- Type: text/x-patch, Size: 1248 bytes --] From 88c88d787a399069f0554c8635f1f3496a9fd1e2 Mon Sep 17 00:00:00 2001 From: John Soo <jsoo1@asu.edu> Date: Sat, 13 Jun 2020 22:54:24 -0700 Subject: [PATCH 3/5] gnu: Add linux-libre-with-bpf. * gnu/packages/linux.scm (linux-libre-with-bpf): New variable. --- gnu/packages/linux.scm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index 4daa371c6b..f3eec978ec 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -7157,6 +7157,16 @@ cache data store that is used by network file systems such as @code{AFS} and persistent over reboots.") (license license:gpl2+))) +(define-public linux-libre-with-bpf + (make-linux-libre* linux-libre-5.4-version + linux-libre-5.4-source + '("x86_64-linux" "i686-linux" "armhf-linux" "aarch64-linux" "riscv64-linux") + #:extra-version "bpf" + #:configuration-file kernel-config + #:extra-options + (append %bpf-extra-linux-options + %default-extra-linux-options))) + (define-public libbpf (let* ((commit "6a1615c263b679c17ecb292fa897f159e826dc10")) (package -- 2.26.2 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #5: 0004-gnu-Add-bcc.patch --] [-- Type: text/x-patch, Size: 3924 bytes --] From 0358dccc866a392512ddb15f9fee0e24e6bc837c Mon Sep 17 00:00:00 2001 From: John Soo <jsoo1@asu.edu> Date: Sat, 13 Jun 2020 23:16:11 -0700 Subject: [PATCH 4/5] gnu: Add bcc. * gnu/packages/linux.scm (bcc): New variable. --- gnu/packages/linux.scm | 65 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index f3eec978ec..0b8b08883a 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -97,6 +97,8 @@ #:use-module (gnu packages haskell-xyz) #:use-module (gnu packages libunwind) #:use-module (gnu packages libusb) + #:use-module (gnu packages llvm) + #:use-module (gnu packages lua) #:use-module (gnu packages man) #:use-module (gnu packages maths) #:use-module (gnu packages multiprecision) @@ -131,6 +133,7 @@ #:use-module (gnu packages rsync) #:use-module (gnu packages selinux) #:use-module (gnu packages swig) + #:use-module (gnu packages version-control) #:use-module (guix build-system cmake) #:use-module (guix build-system gnu) #:use-module (guix build-system go) @@ -7211,3 +7214,65 @@ persistent over reboots.") contrast to BCC, do not require Clang/LLVM runtime being deployed to target servers and does not rely on kernel-devel headers being available.") (license `(,license:lgpl2.1 ,license:bsd-2))))) + +(define-public bcc + (let* ((ver "0.14.0") + (commit (string-append "v" ver)) + (revision "1")) + (package + (name "bcc") + (version (git-version ver revision commit)) + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/iovisor/bcc") + (commit commit))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "08m21avzamr48qwshd4r5hlcckk1kvgrb1i6qw373b7la89jf5an")))) + (build-system cmake-build-system) + (inputs + `(;; TODO: package optional integrations + ;; ("arping" ,argping) + ;; ("netperf" ,netperf) + ;; ("iperf" ,iperf) or ("iperf3" ,iperf3) + ("bison" ,bison) + ("clang-toolchain" ,clang-toolchain) + ("flex" ,flex) + ;; FIXME: Timestamp some other way. + ("git" ,git) + ("libbpf" ,(package-source libbpf)) + ;; LibElf required but libelf does not contain + ;; archives, only object files. + ;; https://github.com/iovisor/bcc/issues/504 + ("elfutils" ,elfutils) + ("linux-libre-headers" ,linux-libre-headers) + ("luajit" ,luajit) + ("python-wrapper" ,python-wrapper))) + (arguments + `(;; Tests all require sudo and a "standard" file heirarchy + #:tests? #f + ;; LIBBPF_INCLUDE_DIR should work with the output of libbpf - + ;; i.e. ,libbpf instead of ,(package-source libbpf) in inputs + ;; but it seems there could be a bug + ;; #:configure-flags + ;; (list + ;; (string-append + ;; "-DLIBBPF_INCLUDE_DIR=" (assoc-ref %build-inputs "libbpf") "/include")) + #:phases + (modify-phases %standard-phases + (add-after 'unpack 'copy-libbpf + (lambda* (#:key inputs #:allow-other-keys) + (delete-file-recursively "src/cc/libbpf") + (copy-recursively (assoc-ref inputs "libbpf") "src/cc/libbpf")))))) + (home-page "https://github.com/iovisor/bcc") + (synopsis "Tools for BPF on Linux") + (description + "BCC is a toolkit for creating efficient kernel tracing and +manipulation programs, and includes several useful tools and examples. It +makes use of extended BPF (Berkeley Packet Filters), formally known as eBPF, a +new feature that was first added to Linux 3.15. Much of what BCC uses requires +Linux 4.1 and above.") + (license license:asl2.0)))) -- 2.26.2 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #6: 0005-gnu-Add-bpftrace.patch --] [-- Type: text/x-patch, Size: 4516 bytes --] From 9d93a4fa63a6a84077e3b539043fbd94260d917c Mon Sep 17 00:00:00 2001 From: John Soo <jsoo1@asu.edu> Date: Sat, 13 Jun 2020 23:16:56 -0700 Subject: [PATCH 5/5] gnu: Add bpftrace. * gnu/packages/linux.scm (bpftrace): New variable. * gnu/packages/patches/bpftrace-disable-bfd-disasm.patch: Disable bfd disassembly for bpftrace. * gnu/local.mk (dist_patch_DATA): Add bpftrace-disable-bfd-disasm.patch. --- gnu/local.mk | 1 + gnu/packages/linux.scm | 51 +++++++++++++++++++ .../patches/bpftrace-disable-bfd-disasm.patch | 15 ++++++ 3 files changed, 67 insertions(+) create mode 100644 gnu/packages/patches/bpftrace-disable-bfd-disasm.patch diff --git a/gnu/local.mk b/gnu/local.mk index 5e9dba5ab7..4b5dd50e52 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -812,6 +812,7 @@ dist_patch_DATA = \ %D%/packages/patches/bitcoin-core-python-compat.patch \ %D%/packages/patches/blender-2.79-newer-ffmpeg.patch \ %D%/packages/patches/blender-2.79-python-3.7-fix.patch \ + %D%/packages/patches/bpftrace-disable-bfd-disasm.patch \ %D%/packages/patches/busybox-1.31.1-fix-build-with-glibc-2.31.patch \ %D%/packages/patches/byobu-writable-status.patch \ %D%/packages/patches/calibre-no-updates-dialog.patch \ diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index 0b8b08883a..d6d34134e5 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -7276,3 +7276,54 @@ makes use of extended BPF (Berkeley Packet Filters), formally known as eBPF, a new feature that was first added to Linux 3.15. Much of what BCC uses requires Linux 4.1 and above.") (license license:asl2.0)))) + +(define-public bpftrace + (let* ((ver "0.10.0") + (commit (string-append "v" ver)) + (revision "1")) + (package + (name "bpftrace") + (version (git-version ver revision commit)) + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/iovisor/bpftrace") + (commit commit))) + (file-name (git-file-name name ver)) + (sha256 + (base32 + "023ardywbw5w8815j2ny9rrp2xlpxndqaa7v2njjm8109p7ilsdn")) + (patches (search-patches "bpftrace-disable-bfd-disasm.patch")))) + (build-system cmake-build-system) + (inputs + `(("bcc" ,bcc) + ("bison" ,bison) + ("clang-toolchain" ,clang-toolchain) + ("elfutils" ,elfutils) + ("flex" ,flex) + ;; FIXME: Tests require googletest but clone repository + ;; ("googletest" ,googletest) + ("libbpf" ,libbpf) + ("linux-libre-headers" ,linux-libre-headers))) + (arguments + `(#:tests? #f ; FIXME: Enable when googletest from guix is used + #:configure-flags + '(;; FIXME: Make tests not clone the googletest repository + "-DBUILD_TESTING=OFF" + "-DBUILD_ASAN=ON" + ;; FIXME: libbfd misses some link dependencies + ;; When fixed, remove patch + "-DHAVE_BFD_DISASM=OFF"))) + (home-page "https://github.com/iovisor/bpftrace") + (synopsis "High-level tracing language for Linux eBPF") + (description + "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. bpftrace was +created by Alastair Robertson.") + (license license:asl2.0)))) diff --git a/gnu/packages/patches/bpftrace-disable-bfd-disasm.patch b/gnu/packages/patches/bpftrace-disable-bfd-disasm.patch new file mode 100644 index 0000000000..8565d8d851 --- /dev/null +++ b/gnu/packages/patches/bpftrace-disable-bfd-disasm.patch @@ -0,0 +1,15 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index e89a6a9..a594786 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -126,10 +126,6 @@ find_package(LibBpf) + find_package(LibBfd) + find_package(LibOpcodes) + +-if(${LIBBFD_FOUND} AND ${LIBOPCODES_FOUND}) +- set(HAVE_BFD_DISASM TRUE) +-endif() +- + include(CheckIncludeFile) + check_include_file("sys/sdt.h" HAVE_SYSTEMTAP_SYS_SDT_H) + -- 2.26.2 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: BPF in linux-libre 2020-07-03 16:01 ` John Soo @ 2020-07-05 8:18 ` Mathieu Othacehe 2020-07-05 8:20 ` Mathieu Othacehe 1 sibling, 0 replies; 13+ messages in thread From: Mathieu Othacehe @ 2020-07-05 8:18 UTC (permalink / raw) To: John Soo; +Cc: Help Guix Hello John, Thanks for this serie, a few remarks below. > +(define-public libbpf > + (let* ((commit "6a1615c263b679c17ecb292fa897f159e826dc10")) Why using a specific commit? > + (package > + (name "libbpf") > + (version "0.0.8") The "0.0.9" is out there :) > + (source > + (origin > + (method git-fetch) > + (uri (git-reference > + (url "https://github.com/libbpf/libbpf") > + (commit commit))) (commit (string-append "v" version)) should work fine. > + ("pkg-config" ,pkg-config) This should be a native-input, don't forget to run the linter :) > + (string-append "PREFIX=''") > + (string-append "DESTDIR=" (assoc-ref %outputs "out")) > + (string-append > + "CC=" (assoc-ref %build-inputs "gcc") "/bin/gcc")) This will put libraries in "lib64" directory which is not desired. You can set LIBDIR to "/lib" to avoid that. > + (chdir "src") I'm not sure this is needed. > + #t))))) > + (home-page "https://github.com/libbpf/libbpf") > + (synopsis "BPF CO-RE (Compile Once – Run Everywhere)") > + (description > + "Libbpf supports building BPF CO-RE-enabled applications, which, in > +contrast to BCC, do not require Clang/LLVM runtime being deployed to target > +servers and does not rely on kernel-devel headers being available.") "kernel-devel" is more Debian specific I think. I'm also not sure that the "Clang deploying" things applied well to Guix. Thanks, Mathieu ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: BPF in linux-libre 2020-07-03 16:01 ` John Soo 2020-07-05 8:18 ` Mathieu Othacehe @ 2020-07-05 8:20 ` Mathieu Othacehe 2020-07-06 0:44 ` John Soo 1 sibling, 1 reply; 13+ messages in thread From: Mathieu Othacehe @ 2020-07-05 8:20 UTC (permalink / raw) To: John Soo; +Cc: Help Guix Hey, > +(define-public linux-libre-with-bpf > + (make-linux-libre* linux-libre-5.4-version > + linux-libre-5.4-source > + '("x86_64-linux" "i686-linux" "armhf-linux" "aarch64-linux" "riscv64-linux") > + #:extra-version "bpf" > + #:configuration-file kernel-config > + #:extra-options > + (append %bpf-extra-linux-options > + %default-extra-linux-options))) > + What would be the drawbacks of enabling BPF in the default linux-libre kernel? Thanks, Mathieu ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: BPF in linux-libre 2020-07-05 8:20 ` Mathieu Othacehe @ 2020-07-06 0:44 ` John Soo 0 siblings, 0 replies; 13+ messages in thread From: John Soo @ 2020-07-06 0:44 UTC (permalink / raw) To: Mathieu Othacehe; +Cc: Help Guix [-- Attachment #1: Type: text/plain, Size: 3736 bytes --] Hi Mathieu, I attached an updated series. I think I fixed up the lint errors. Pardon me. >> +(define-public libbpf >> + (let* ((commit "6a1615c263b679c17ecb292fa897f159e826dc10")) > Why using a specific commit? > The "0.0.9" is out there :) I updated the packages where it was appropriate. bcc also had an available update, oops. >> + (source >> + (origin >> + (method git-fetch) >> + (uri (git-reference >> + (url "https://github.com/libbpf/libbpf") >> + (commit commit))) > > (commit (string-append "v" version)) should work fine. > + ("pkg-config" ,pkg-config) > This should be a native-input, don't forget to run the linter :) Done, also I made flex and bison native inputs where appropriate. >> + (string-append "PREFIX=''") >> + (string-append "DESTDIR=" (assoc-ref %outputs "out")) >> + (string-append >> + "CC=" (assoc-ref %build-inputs "gcc") "/bin/gcc")) > > This will put libraries in "lib64" directory which is not desired. You > can set LIBDIR to "/lib" to avoid that. Done, thank you. >> + (chdir "src") > > I'm not sure this is needed. I tried without and it failed. I looked at the libbpf build guide and it says to cd src. I wish I could remove it, too. >> + #t))))) >> + (home-page "https://github.com/libbpf/libbpf") >> + (synopsis "BPF CO-RE (Compile Once – Run Everywhere)") >> + (description >> + "Libbpf supports building BPF CO-RE-enabled applications, which, in >> +contrast to BCC, do not require Clang/LLVM runtime being deployed to target >> +servers and does not rely on kernel-devel headers being available.") > > "kernel-devel" is more Debian specific I think. I'm also not sure that > the "Clang deploying" things applied well to Guix. I think I tidied up the description to match the Guix situation. What do you think now? >> +(define-public linux-libre-with-bpf >> + (make-linux-libre* linux-libre-5.4-version >> + linux-libre-5.4-source >> + '("x86_64-linux" "i686-linux" "armhf-linux" "aarch64-linux" >> "riscv64-linux") >> + #:extra-version "bpf" >> + #:configuration-file kernel-config >> + #:extra-options >> + (append %bpf-extra-linux-options >> + %default-extra-linux-options))) >> + > > What would be the drawbacks of enabling BPF in the default linux-libre > kernel? I could see it being a useful default. BPF seems like a nice technology but I am making these patches to experiment with it myself. Because I haven't used it much I can't really speak on the pros of making it default. Other than my gut feeling that seems like something that should be opted into rather than opting out of I have no strong feelings on including it by default. The only other downside I see is that putting in the default might make the linux definitions less composable. The way it is now, one can assemble a (mostly) bpf-capable system from the pieces in gnu/packages/linux.scm. That said, I think there are a few more missing pieces to get full functionality. Running the example bpftrace scripts gives errors like this: open(/sys/kernel/debug/tracing/uprobe_events): No such file or directory I think that means the operating system definition might need to specify more file systems but I can't seem to work out which ones are required and where to specify them. My first guess is that it would need to be debugfs and mounted in initramfs? I am not sure. Thanks for your feedback! - John [-- Attachment #2: 0001-gnu-Add-libbpf.patch --] [-- Type: text/x-patch, Size: 2854 bytes --] From 7f077c98a2328c43a5041a9461a44299a6b1d9ec Mon Sep 17 00:00:00 2001 From: John Soo <jsoo1@asu.edu> Date: Sat, 13 Jun 2020 14:53:50 -0700 Subject: [PATCH 1/5] gnu: Add libbpf. * gnu/packages/linux.scm (libbpf): New variable. --- gnu/packages/linux.scm | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index b508e1809c..9a7cf73c0d 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -45,6 +45,7 @@ ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> ;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re> ;;; Copyright © 2020 Morgan Smith <Morgan.J.Smith@outlook.com> +;;; Copyright © 2020 John Soo <jsoo1@asu.edu> ;;; ;;; This file is part of GNU Guix. ;;; @@ -7139,3 +7140,51 @@ cache data store that is used by network file systems such as @code{AFS} and @code{NFS} to cache data locally on disk. The content of the cache is persistent over reboots.") (license license:gpl2+))) + +(define-public libbpf + (let* ((revision "1")) + (package + (name "libbpf") + (version "0.0.9") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/libbpf/libbpf") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "18l0gff7nm841mwhr7bc7x863xcyvwh58zl7mc0amnsjqlbrvqg7")))) + (build-system gnu-build-system) + (native-inputs + `(("pkg-config" ,pkg-config))) + (inputs + `(("libelf" ,libelf) + ("zlib" ,zlib))) + (arguments + `(#:tests? #f ; No tests + #:make-flags + (list + (string-append "PREFIX=''") + (string-append "DESTDIR=" (assoc-ref %outputs "out")) + (string-append "LIBDIR=/lib") + (string-append + "CC=" (assoc-ref %build-inputs "gcc") "/bin/gcc")) + #:phases + (modify-phases %standard-phases + (delete 'configure) + (add-before 'build 'pre-build + (lambda* (#:key inputs #:allow-other-keys) + (substitute* "scripts/check-reallocarray.sh" + (("/bin/rm" rm) + (string-append (assoc-ref inputs "coreutils") rm))) + (chdir "src") + #t))))) + (home-page "https://github.com/libbpf/libbpf") + (synopsis "BPF CO-RE (Compile Once – Run Everywhere)") + (description + "Libbpf supports building BPF CO-RE-enabled applications, which, in +contrast to BCC, do not require the Clang/LLVM runtime or linux kernel +headers.") + (license `(,license:lgpl2.1 ,license:bsd-2))))) -- 2.27.0 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #3: 0002-gnu-Add-bpf-extra-linux-options.patch --] [-- Type: text/x-patch, Size: 1617 bytes --] From 4225b08298bf62d008e46b14d14ac5aee717ef27 Mon Sep 17 00:00:00 2001 From: John Soo <jsoo1@asu.edu> Date: Sat, 13 Jun 2020 22:52:55 -0700 Subject: [PATCH 2/5] gnu: Add %bpf-extra-linux-options. * gnu/packages/linux (%bpf-extra-linux-options): New variable. --- gnu/packages/linux.scm | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index 9a7cf73c0d..126d969e65 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -619,6 +619,30 @@ for ARCH and optionally VARIANT, or #f if there is no such configuration." ("CONFIG_CIFS" . m) ("CONFIG_9P_FS" . m))) +;; See https://github.com/iovisor/bcc/blob/master/INSTALL.md#kernel-configuration +(define %bpf-extra-linux-options + `(;; Needed for probes + ("CONFIG_UPROBE_EVENTS" . #t) + ("CONFIG_KPROBE_EVENTS" . #t) + ;; kheaders module also helpful for tracing + ("CONFIG_IKHEADERS" . #t) + ("CONFIG_BPF" . #t) + ("CONFIG_BPF_SYSCALL" . #t) + ("CONFIG_BPF_JIT_ALWAYS_ON" . #t) + ;; optional, for tc filters + ("CONFIG_NET_CLS_BPF" . m) + ;; optional, for tc actions + ("CONFIG_NET_ACT_BPF" . m) + ("CONFIG_BPF_JIT" . #t) + ;; for Linux kernel versions 4.1 through 4.6 + ;; ("CONFIG_HAVE_BPF_JIT" . y) + ;; for Linux kernel versions 4.7 and later + ("CONFIG_HAVE_EBPF_JIT" . #t) + ;; optional, for kprobes + ("CONFIG_BPF_EVENTS" . #t) + ;; kheaders module + ("CONFIG_IKHEADERS" . #t))) + (define (config->string options) (string-join (map (match-lambda ((option . 'm) -- 2.27.0 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #4: 0003-gnu-Add-linux-libre-with-bpf.patch --] [-- Type: text/x-patch, Size: 1598 bytes --] From 1c360ce60dba1d30b7c02e974e37cfe3cbb9c936 Mon Sep 17 00:00:00 2001 From: John Soo <jsoo1@asu.edu> Date: Sat, 13 Jun 2020 22:54:24 -0700 Subject: [PATCH 3/5] gnu: Add linux-libre-with-bpf. * gnu/packages/linux.scm (linux-libre-with-bpf): New variable. --- gnu/packages/linux.scm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index 126d969e65..8a70a78e64 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -75,6 +75,7 @@ #:use-module (gnu packages bison) #:use-module (gnu packages calendar) #:use-module (gnu packages check) + #:use-module (gnu packages cpio) #:use-module (gnu packages crypto) #:use-module (gnu packages cryptsetup) #:use-module (gnu packages compression) @@ -7165,6 +7166,21 @@ cache data store that is used by network file systems such as @code{AFS} and persistent over reboots.") (license license:gpl2+))) +(define-public linux-libre-with-bpf + (let ((base-linux-libre + (make-linux-libre* + linux-libre-5.4-version + linux-libre-5.4-source + '("x86_64-linux" "i686-linux" "armhf-linux" "aarch64-linux" "riscv64-linux") + #:extra-version "bpf" + #:configuration-file kernel-config + #:extra-options + (append %bpf-extra-linux-options + %default-extra-linux-options)))) + (package + (inherit base-linux-libre) + (inputs `(("cpio" ,cpio) ,@(package-inputs base-linux-libre)))))) + (define-public libbpf (let* ((revision "1")) (package -- 2.27.0 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #5: 0004-gnu-Add-bcc.patch --] [-- Type: text/x-patch, Size: 3841 bytes --] From a15d37f1dc4a422daac986cce2dce9008ea66540 Mon Sep 17 00:00:00 2001 From: John Soo <jsoo1@asu.edu> Date: Sat, 13 Jun 2020 23:16:11 -0700 Subject: [PATCH 4/5] gnu: Add bcc. * gnu/packages/linux.scm (bcc): New variable. --- gnu/packages/linux.scm | 65 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index 8a70a78e64..0c1cc77041 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -98,6 +98,8 @@ #:use-module (gnu packages haskell-xyz) #:use-module (gnu packages libunwind) #:use-module (gnu packages libusb) + #:use-module (gnu packages llvm) + #:use-module (gnu packages lua) #:use-module (gnu packages man) #:use-module (gnu packages maths) #:use-module (gnu packages multiprecision) @@ -132,6 +134,7 @@ #:use-module (gnu packages rsync) #:use-module (gnu packages selinux) #:use-module (gnu packages swig) + #:use-module (gnu packages version-control) #:use-module (guix build-system cmake) #:use-module (guix build-system gnu) #:use-module (guix build-system go) @@ -7228,3 +7231,65 @@ persistent over reboots.") contrast to BCC, do not require the Clang/LLVM runtime or linux kernel headers.") (license `(,license:lgpl2.1 ,license:bsd-2))))) + +(define-public bcc + (package + (name "bcc") + (version "0.15.0") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/iovisor/bcc") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "1d5j9zanffa1c7lpi5fcrdlx1n7hy86xl82fam2xqr0s41q4ipxw")))) + (build-system cmake-build-system) + (native-inputs + `(("bison" ,bison) + ("flex" ,flex))) + (inputs + `(;; TODO: package optional integrations + ;; ("arping" ,argping) + ;; ("netperf" ,netperf) + ;; ("iperf" ,iperf) or ("iperf3" ,iperf3) + ("clang-toolchain" ,clang-toolchain) + ;; FIXME: Timestamp some other way. + ("git" ,git) + ("libbpf" ,(package-source libbpf)) + ;; LibElf required but libelf does not contain + ;; archives, only object files. + ;; https://github.com/iovisor/bcc/issues/504 + ("elfutils" ,elfutils) + ("linux-libre-headers" ,linux-libre-headers) + ("luajit" ,luajit) + ("python-wrapper" ,python-wrapper))) + (arguments + `(;; Tests all require sudo and a "standard" file heirarchy + #:tests? #f + ;; LIBBPF_INCLUDE_DIR should work with the output of libbpf - + ;; i.e. ,libbpf instead of ,(package-source libbpf) in inputs + ;; but it seems there could be a bug + ;; #:configure-flags + ;; (list + ;; (string-append + ;; "-DLIBBPF_INCLUDE_DIR=" + ;; (assoc-ref %build-inputs "libbpf") "/include")) + #:phases + (modify-phases %standard-phases + (add-after 'unpack 'copy-libbpf + (lambda* (#:key inputs #:allow-other-keys) + (delete-file-recursively "src/cc/libbpf") + (copy-recursively + (assoc-ref inputs "libbpf") "src/cc/libbpf")))))) + (home-page "https://github.com/iovisor/bcc") + (synopsis "Tools for BPF on Linux") + (description + "BCC is a toolkit for creating efficient kernel tracing and +manipulation programs, and includes several useful tools and examples. It +makes use of extended BPF (Berkeley Packet Filters), formally known as eBPF, a +new feature that was first added to Linux 3.15. Much of what BCC uses requires +Linux 4.1 and above.") + (license license:asl2.0))) -- 2.27.0 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #6: 0005-gnu-Add-bpftrace.patch --] [-- Type: text/x-patch, Size: 4334 bytes --] From c808920c5f8575079cf8d442cb84a1fb1905c13d Mon Sep 17 00:00:00 2001 From: John Soo <jsoo1@asu.edu> Date: Sat, 13 Jun 2020 23:16:56 -0700 Subject: [PATCH 5/5] gnu: Add bpftrace. * gnu/packages/linux.scm (bpftrace): New variable. * gnu/packages/patches/bpftrace-disable-bfd-disasm.patch: Disable bfd disassembly for bpftrace. * gnu/local.mk (dist_patch_DATA): Add bpftrace-disable-bfd-disasm.patch. --- gnu/local.mk | 1 + gnu/packages/linux.scm | 48 +++++++++++++++++++ .../patches/bpftrace-disable-bfd-disasm.patch | 15 ++++++ 3 files changed, 64 insertions(+) create mode 100644 gnu/packages/patches/bpftrace-disable-bfd-disasm.patch diff --git a/gnu/local.mk b/gnu/local.mk index 9a691525a2..ad12fc5181 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -818,6 +818,7 @@ dist_patch_DATA = \ %D%/packages/patches/bitcoin-core-python-compat.patch \ %D%/packages/patches/blender-2.79-newer-ffmpeg.patch \ %D%/packages/patches/blender-2.79-python-3.7-fix.patch \ + %D%/packages/patches/bpftrace-disable-bfd-disasm.patch \ %D%/packages/patches/busybox-1.31.1-fix-build-with-glibc-2.31.patch \ %D%/packages/patches/byobu-writable-status.patch \ %D%/packages/patches/calibre-no-updates-dialog.patch \ diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index 0c1cc77041..b6d69badfe 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -7293,3 +7293,51 @@ makes use of extended BPF (Berkeley Packet Filters), formally known as eBPF, a new feature that was first added to Linux 3.15. Much of what BCC uses requires Linux 4.1 and above.") (license license:asl2.0))) + +(define-public bpftrace + (package + (name "bpftrace") + (version "0.10.0") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/iovisor/bpftrace") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "023ardywbw5w8815j2ny9rrp2xlpxndqaa7v2njjm8109p7ilsdn")) + (patches (search-patches "bpftrace-disable-bfd-disasm.patch")))) + (build-system cmake-build-system) + (native-inputs + `(("bison" ,bison) + ("flex" ,flex))) + (inputs + `(("bcc" ,bcc) + ("clang-toolchain" ,clang-toolchain) + ("elfutils" ,elfutils) + ;; FIXME: Tests require googletest but clone repository + ;; ("googletest" ,googletest) + ("libbpf" ,libbpf) + ("linux-libre-headers" ,linux-libre-headers))) + (arguments + `(#:tests? #f ; FIXME: Enable when googletest from guix is used + #:configure-flags + '(;; FIXME: Make tests not clone the googletest repository + "-DBUILD_TESTING=OFF" + ;; FIXME: libbfd misses some link dependencies + ;; When fixed, remove patch + "-DHAVE_BFD_DISASM=OFF"))) + (home-page "https://github.com/iovisor/bpftrace") + (synopsis "High-level tracing language for Linux eBPF") + (description + "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. bpftrace was +created by Alastair Robertson.") + (license license:asl2.0))) diff --git a/gnu/packages/patches/bpftrace-disable-bfd-disasm.patch b/gnu/packages/patches/bpftrace-disable-bfd-disasm.patch new file mode 100644 index 0000000000..8565d8d851 --- /dev/null +++ b/gnu/packages/patches/bpftrace-disable-bfd-disasm.patch @@ -0,0 +1,15 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index e89a6a9..a594786 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -126,10 +126,6 @@ find_package(LibBpf) + find_package(LibBfd) + find_package(LibOpcodes) + +-if(${LIBBFD_FOUND} AND ${LIBOPCODES_FOUND}) +- set(HAVE_BFD_DISASM TRUE) +-endif() +- + include(CheckIncludeFile) + check_include_file("sys/sdt.h" HAVE_SYSTEMTAP_SYS_SDT_H) + -- 2.27.0 ^ permalink raw reply related [flat|nested] 13+ messages in thread
end of thread, other threads:[~2020-07-06 0:45 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-06-14 3:21 BPF in linux-libre John Soo 2020-06-14 9:23 ` Mathieu Othacehe 2020-06-14 15:11 ` John Soo 2020-06-17 10:16 ` Mathieu Othacehe 2020-06-17 13:42 ` John Soo 2020-06-21 15:32 ` John Soo 2020-06-26 10:50 ` Mathieu Othacehe 2020-06-28 20:24 ` John Soo 2020-07-01 5:40 ` John Soo 2020-07-03 16:01 ` John Soo 2020-07-05 8:18 ` Mathieu Othacehe 2020-07-05 8:20 ` Mathieu Othacehe 2020-07-06 0:44 ` John Soo
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).