-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Location of the kernel headers #397
Comments
On most systems, I find the kernel headers in |
There is kernel-default-devel which provides /lib/modules/$(uname -r)/build but the header structure is very different than what I expect:
|
This is obviously a SUSE related problem, I am closing the bug. Will try to ask our kernel devs. |
:) I imagine there is a reasonable answer. My hope is that you aren't required to install the full kernel sources. Let us know when you find out. |
@lcp thats awesome! Maybe it can be upstreamed :-) |
In SLE/openSUSE, the kernel headers are actually in two packages: kernel-default-devel and kernel-devel. kernel-default-devel actually requires kernel-default, so those two packages will be installed altogether. The headers in /lib/modules/$(version)/build are from kernel-default-devel and those in /lib/modules/$(version)/source are from kernel-devel, and build and source link to different directories: build -> /usr/src/linux-4.4.0-3-obj/x86_64/default The headers are separated on purpose. From the descriptions of the packages, kernel-default-devel contains the files "necessary for building kernel modules against the default flavor of the kernel" while kernel-devel contains the files "required for development of external kernel modules." My patch is to add the "source" paths so that clang can find the corresponding headers. I found that fedora links source to build, so the patch probably won't affect them. @drzaeus77 Do you think it's fine to upstream my patch or just leave it in SUSE? |
The descriptions of those two packages look very similar to me :) Unfortunately, the other two datapoints in my informal survey (arch linux and ubuntu) show that the presence of the |
They're similar but still different. There are several flavors of kernels in SLE/openSUSE, e.g. default and vanilla for x86_64, and the kernel-"flavor"-devel packages contain the headers different from the flavors, so the "generated" headers are in kernel-"flavor"-devel, and the rest are in kernel-devel. Thus, in our case, we need both "build" and "source" in the include paths. I thought "build" and "source" are created by "make modules_install" and other distro would keep them, but it seems not true :-( |
Hello, trying to build bcc on a Debian / Jessie, and getting the same issue:
I tried linking the missing directory, but then it breaks with a different error
Has anybody succeeded in compiling it under Jessie ? I got the same errors if I try to run debian/rules binary, is there something that I am missing ? |
No, I haven't tried compiling under jessie. Let's assume for a moment that the symlink was properly done, and so the first error is worked around. The second error seems to suggest that the kernel sources don't include the bpf headers. Which kernel version are you symlinking to? |
Hello, thank for your answer. That'what I did:
The files are present:
is the problem that the headers are under linux-headers-4.3.0-0.bpo.1-common and not under linux-headers-4.3.0-0.bpo.1-amd64 (just wildguessing) ? |
No, I don't think -amd64 will change anything, the output of Is there also a symlink from |
this is the output of /lib/modules/4.3.0-0.bpo.1-amd64
|
Ah, interesting. The symlinks are different, so yes it seems that the headers picked up will be different, unless |
build != source for out-of-source build. Currently I workaround that by symlinking stuff manually. The better fix would be on bcc side to give both /lib/../source and /lib/../build directories to -I |
|
@4ast which directory would have been used for a kmod build (M=??), that was supposed to be the only requirement. Having two M= doesn't make sense for kmod, and nor does it make sense for us. There should be a 'right way' without needing ./sources. |
it's one M=. I think ko's makefile is looking for 'source' link inside 'build' dir. |
That seems unlikely, on my system there is no ./source link and modules build just fine. I haven't read any makefile sources to confirm that, though... |
@finelli sorry, I asked for the wrong command. It should have been |
Makefile:1132 |
As follows:
|
Some linux distributions structure the /lib/modules directories differently, causing complexities. Add cmake overrides to be able to compile different behavior. If your distro sets up `/lib/modules/$(uname -r)/{source,build}` with header files split between the two (debian does this), then add -DBCC_KERNEL_HAS_SOURCE_DIR=1 to the cmake command line. If your distro just has something other than build/, but things are still in one subdirectory, then add -DBCC_KERNEL_MODULES_SUFFIX=foo to the cmake command line. Also, fix one implicit declaration warning introduced by the new bpf_get_stackid() helper. Fixes: #397 Signed-off-by: Brenden Blanco <[email protected]>
The mentioned pull request was tested on debian but not suse. Please let me know how the fix looks on your respective systems. |
Adding "-DBCC_KERNEL_HAS_SOURCE_DIR=1" to cmake works for me. |
Confirmed: adding "-DBCC_KERNEL_HAS_SOURCE_DIR=1" to cmake works for me too (not tried the debian/rules part, not sure how to add that option to the build) |
Well, a little too fast: the hello_world example runs, but other examples are broken:
|
Ok, the pull request is updated, hopefully the new version includes all of the right bits. |
I confirm that no example gives error. Thanks. |
@finelli how did you solve the issue? I am running on jessie with binary packages from http:https://52.8.15.63/apt/ as instructed in INSTALL.md - did you manually build instead? libbcc:amd64/trusty 0.1.8-1 uptodate |
Yes, I built them, I am not using the above packages |
This fails for me again with git master (on openSUSE Tumbleweed as my original bug report):
|
I am trying to run bcc on openSUSE Linux and there is a problem with the kernel header path it seems:
The file exists at /usr/src/linux/include/linux/kconfig.h , I am wondering if there is a special setup I should be doing before using bcc.
The text was updated successfully, but these errors were encountered: