Built-in BEGIN bpftrace event is broken due to binary being stripped. Reproducible: Always Steps to Reproduce: % sudo bpftrace -e 'BEGIN { @++ }' Attaching 1 probe... Could not resolve symbol: /proc/self/exe:BEGIN_trigger This is because in order to use BEGIN, bpftrace installs a uprobe on itself, and if the binary is stripped, it can't find the symbol. See upstream discussion: https://github.com/iovisor/bpftrace/issues/954
Does FEATURES=splitdebug help for you? Otherwise, how about FEATURES=nostrip ? I am a little reluctant to put a RESTRICT=strip on this, as that is a big hammer, but I suppose if it's necessary for basic functionality...
splitdebug doesn't help, nostrip does. The reason why splitdebug doesn't help is that bpftools uses /proc/self/exe as its own name, and the bcc library ends up searching for a wrong file: openat(AT_FDCWD, "/proc/self/exe", O_RDONLY) = 29 stat("/proc/self/bpftrace.debug", 0x7fffa8b157e0) = -1 ENOENT (No such file or directory) access("/proc/self/bpftrace.debug", F_OK) = -1 ENOENT (No such file or directory) access("/proc/self/.debug/bpftrace.debug", F_OK) = -1 ENOENT (No such file or directory) access("/usr/lib/debug/proc/self/bpftrace.debug", F_OK) = -1 ENOENT (No such file or directory) This is certainly an upstream bug on its own.
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8b502ccf32895dc1f9cbecc165221022553d28b0 commit 8b502ccf32895dc1f9cbecc165221022553d28b0 Author: Patrick McLean <chutzpah@gentoo.org> AuthorDate: 2021-03-24 23:59:01 +0000 Commit: Patrick McLean <chutzpah@gentoo.org> CommitDate: 2021-03-24 23:59:16 +0000 dev-util/bpftrace-0.11.4-r1: revbump RESTRICT=strip (bug #754648) Closes: https://bugs.gentoo.org/754648 Package-Manager: Portage-3.0.17, Repoman-3.0.2 Signed-off-by: Patrick McLean <chutzpah@gentoo.org> dev-util/bpftrace/bpftrace-0.11.4-r1.ebuild | 89 +++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+)
Version 0.12.1 moves the symbol into libbpftrace.so, and so the symbol will not be found (even if libbpftrace.so is installed) I think the only solution is to use "-DBUILD_SHARED_LIBS:=OFF" and turn off the flag that gentoo's config turns on