bcc/BPFTable.hI'm running on a stock Ubuntu 18.04 system, with a 4.15 Linux kernel.
Example :
//BPFTable_failure.cpp
#include <bcc/BPFTable.h>
int main(void) { }
````
```bash
-> % g++ BPFTable_failure.cpp
In file included from BPFTable_failure.cpp:1:0:
/usr/include/bcc/BPFTable.h:320:54: error: field ‘trace’ has incomplete type ‘bpf_stack_build_id [127]’
struct bpf_stack_build_id trace[BPF_MAX_STACK_DEPTH];
^
In file included from /usr/include/bcc/BPFTable.h:30:0,
from BPFTable_failure.cpp:1:
/usr/include/bcc/bcc_syms.h:76:38: note: forward declaration of ‘struct bpf_stack_build_id’
struct bpf_stack_build_id *trace,
There should be pre-processor guards in these files if the features aren't supported by the host's kernel.
@vijunag could you take a look? probably need to a correct include path in cmake file to contain bpf.h from libbpf/include/uapi/linux directory.
Yes, will take a look at it. There is no -I incantation to that directory already ?
I think your patch is tested against code base before libbpf work. That is why the buildbot did not catch the issue.
Or I could be wrong as later buildbot seems fine. In any case, please take a look. Thanks.
@yonghong-song - This is a compile outside of bcc repository. I don't think we ship headers under libbpf/include/uapi/linux directory since it is taken from the system ? This was the reason why I had created an auxiliary structure(bcc_stack_build_id) so that there is no dependency with the system header.
The below compile fails if it lacks definition. Should we guard it around kernel version ? What is an elegant fix for this ?
g++ BPFTable_failure.cpp
We do ship uapi headers at /usr/include/bcc/compat/linux directory. User codes should include the bpf header there with proper include patch.
In bcc_syms.h, linux/bpf.h is already there. So user space does not need to change code, add an include path should work.
@yonghong-song - Can we close this PR if nothing needs to be done from bcc end ?
For completeness, this is what makes it work:
g++ -I /usr/include/bcc/compat BPFTable_failure.cpp
Thanks.
Most helpful comment
For completeness, this is what makes it work:
Thanks.