[llvmlinux] how to use -emit-ast on linux kernel files

Adrian Golding adriangolding at gmail.com
Wed May 17 00:54:36 UTC 2017

hello, i am new to LLVM and Linux kernel source code, so i have a lot to
catch up.

i've used Clang to generate ASTs using -emit-ast on toy programs and they
work fine. but this doesn't work when i tried to do this on specific files
(e.g. mm/memory.c).

for example, at the mm folder, i did
clang -emit-ast -I../arch/x86/include -I../arch/x86/include/generated/uapi
-I../arch/x86/include/generated -I../include -I../arch/x86/include/uapi
-I../include/uapi -I../include/generated/uapi -include
../include/linux/kconfig.h memory.c

i got into redefintion errors, and many more.
../arch/x86/include/asm/ptrace.h:33:8: error: redefinition of 'pt_regs'
struct pt_regs {
../arch/x86/include/uapi/asm/ptrace.h:43:8: note: previous definition is
struct pt_regs {

i suspect that i'm not doing something fundamentally correct with respect
to what to include.
may i know if anyone has tried using -emit-ast on some of the kernel files?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxfoundation.org/pipermail/llvmlinux/attachments/20170517/fbc038a5/attachment.html>

More information about the LLVMLinux mailing list