Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 809347 - dev-util/bcc has a run-time dependency on the sources of current running kernel (fatal error: './include/linux/kconfig.h' file not found)
Summary: dev-util/bcc has a run-time dependency on the sources of current running kern...
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Zac Medico
URL: https://github.com/iovisor/bcc/pull/3588
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-21 08:16 UTC by WGH
Modified: 2021-10-08 18:48 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
bcc patch to chech the existence of /lib/modules/$(uname -r)/build/include/linux/kconfig.h (checking-for-kconfig.patch,908 bytes, patch)
2021-08-21 08:28 UTC, WGH
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description WGH 2021-08-21 08:16:42 UTC
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
Comment 1 WGH 2021-08-21 08:28:37 UTC
Created attachment 734734 [details, diff]
bcc patch to chech the existence of /lib/modules/$(uname -r)/build/include/linux/kconfig.h
Comment 2 WGH 2021-10-08 18:48:27 UTC
This got fixed upstream in 0.22.0 (see liked GitHub PR), and Gentoo already has a new version.