dev-util/bcc stops functioning after unmerging the sources of the currently running kernel. Reproducible: Always Steps to Reproduce: 1. Unmerge gentoo-sources of the currently running kernel. 2. Run any bcc tool, e.g. /usr/share/bcc/tools/opensnoop Actual Results: Password: <built-in>:1:10: fatal error: './include/linux/kconfig.h' file not found #include "./include/linux/kconfig.h" ^~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. Traceback (most recent call last): File "/usr/lib/python-exec/python3.9/opensnoop", line 261, in <module> b = BPF(text='') File "/usr/lib/python3.9/site-packages/bcc/__init__.py", line 365, in __init__ raise Exception("Failed to compile BPF module %s" % (src_file or "<text>")) Exception: Failed to compile BPF module <text> Expected Results: It works. bcc tools need the kernel's kconfig.h to function. It tries to find it under path /lib/modules/$(uname -r)/build/include/linux/kconfig.h[1][2]. However, when you unmerge gentoo-sources of the currently running kernel, that file is gone. bcc has a fallback when it tries to extract the headers using kheaders module (/sys/kernel/kheaders.tar.xz). However, the fallback path is not triggered because /lib/modules/$(uname -r)/build still exists until you delete eiter the leftover kernel build directory or /lib/modules/$(uname -r)/build symlink manually[3]. (this is a workaround) I suppose bcc could be fixed to actually check the existence of /lib/modules/$(uname -r)/build/include/linux/kconfig.h instead of just checking for /lib/modules/$(uname -r)/{build,source}. [1] https://github.com/iovisor/bcc/blob/40d6e8556b380e2fd10b865da884f66e7bfdae35/src/cc/frontends/clang/loader.cc#L166-L167 [2] https://github.com/iovisor/bcc/blob/d089013e8c6ee0b82d012c1814f822b00695691f/src/cc/frontends/clang/kbuild_helper.cc#L99-L116 [3] https://github.com/iovisor/bcc/blob/40d6e8556b380e2fd10b865da884f66e7bfdae35/src/cc/frontends/clang/loader.cc#L173
Created attachment 734734 [details, diff] bcc patch to chech the existence of /lib/modules/$(uname -r)/build/include/linux/kconfig.h
This got fixed upstream in 0.22.0 (see liked GitHub PR), and Gentoo already has a new version.