Bcc: feature request: specify additional include paths at runtime

Created on 25 Apr 2018  路  7Comments  路  Source: iovisor/bcc

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

Most helpful comment

Have you tried passing -I/path/to/zfs/include to the cflags argument of bcc.BPF() constructor (assuming python use case)?

All 7 comments

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.

@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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

markdrayton picture markdrayton  路  3Comments

brendangregg picture brendangregg  路  4Comments

avgsg picture avgsg  路  6Comments

rjmccabe3701 picture rjmccabe3701  路  9Comments

saobao913 picture saobao913  路  8Comments