[cfe-dev] Clang and linux kernel. What include path do I need?

Andrey Tarasevich tarasevich.andrey at googlemail.com
Mon Jul 4 12:09:45 PDT 2011


Hello.

I'm parsing linux kernel source code with clang in order to build
correct AST. To be specific, it is Chromium OS kernel. but they are
using slightly modified version of the linux kernel 2.6.32.
I'm running Ubuntu 10.04 x86_64 with kernel 2.6.32-32

The problem is I can not build correct AST since clang always fires me
errors, where it states, that some types are not defined although I
checked the includes manually and the type definitions are correct.
Include path I'm using for clang:
/usr/lib/gcc/x86_64-linux-gnu/4.4/include/
/usr/src/linux-headers-2.6.32-32/include/
/usr/src/linux-headers-2.6.32-32/arch/x86/include/
/usr/src/linux-headers-2.6.32-32-generic/include/

for instance the error message I get from clang:

In file included from /some_path_here/acct.c:47:
In file included from /usr/src/linux-headers-2.6.32-32/include//linux/slab.h:12:
In file included from /usr/src/linux-headers-2.6.32-32/include//linux/gfp.h:4:
In file included from
/usr/src/linux-headers-2.6.32-32/include//linux/mmzone.h:7:
In file included from
/usr/src/linux-headers-2.6.32-32/include//linux/spinlock.h:50:
In file included from
/usr/src/linux-headers-2.6.32-32/include//linux/preempt.h:9:
/usr/src/linux-headers-2.6.32-32/include//linux/thread_info.h:26:4:
error: unknown type name 'u32'
                        u32 *uaddr;
                        ^
/usr/src/linux-headers-2.6.32-32/include//linux/thread_info.h:27:4:
error: unknown type name 'u32'
                        u32 val;
                        ^
/usr/src/linux-headers-2.6.32-32/include//linux/thread_info.h:28:4:
error: unknown type name 'u32'
                        u32 flags;
                        ^
/usr/src/linux-headers-2.6.32-32/include//linux/thread_info.h:29:4:
error: unknown type name 'u32'
                        u32 bitset;
                        ^

I checked the include paths and type 'u32' is defined in file
/usr/src/linux-headers-2.6.32-32/include/asm-generic/int-ll64.h

So my question is following am I missing some include paths or should
I pass some extra compiler options for the clang?

with best regards,
Andrey Tarasevich



More information about the cfe-dev mailing list