I'd like to be able to specify additional include paths at runtime. The use case is that I have a kernel module (zfs) whose header files are not all in /usr/src/linux-headers-4.15.0-19-generic/include. I'd like to be able to do the equivalent of -I/path/to/zfs/include, so that my bcc program can #include <sys/dbuf.h>, etc. My current workaround is to copy all the header files into the system path:
find /export/home/delphix/spl/include /export/home/delphix/zfs/include -name "*.h" | \
xargs tar -cf - | \
tar --strip-components=5 -xf -
@brendangregg
Have you tried passing -I/path/to/zfs/include to the cflags argument of bcc.BPF() constructor (assuming python use case)?
@drzaeus77 Yes, thank you that totally works! I wasn't aware of that argument. I'm happy for this issue to be closed, or perhaps converted to a documentation issue.
I didn't know about it; sounds like we need docs.
We use this in trace.py.
https://github.com/iovisor/bcc/blob/master/tools/trace_example.txt#L268-L271
@yonghong-song this isn't exactly the same as what's done in trace.py. trace.py -I adds additional #include ... directives, but I need to change the include path by which we search for those includes. I can't simply use an absolute path for the few files that I include, because those files include other files, which are assumed to be available in the include path.
Oh, yes. trace.py example is bad. In fb, we use this cflags option to pass addition -D<macro>=<value>s, e.g., queue size etc.
Agreed. that we need documentation to advertise this feature.
@yonghong-song Cool. I opened a PR to add very basic documentation of this: https://github.com/iovisor/bcc/pull/1709
Most helpful comment
Have you tried passing
-I/path/to/zfs/includeto the cflags argument ofbcc.BPF()constructor (assuming python use case)?