我尝试用clang8.0.0为Linux内核2.6.37编写AST文件。
clang -emit-ast init/main.c -o astfile -std=c11 -Iinclude -Iarch/x86/include
也会出错
In file included from /mnt/lfs/sources/linux-2.6.37/init/main.c:12:
/mnt/lfs/sources/linux-2.6.37/include/linux/types.h:13:2: warning: "Attempt to use kernel
headers from user space, see http://kernelnewbies.org/KernelHeaders" [-W#warnings]
#warning "Attempt to use kernel headers from user space, see http://kernelnewbies...
^
In file included from /mnt/lfs/sources/linux-2.6.37/init/main.c:13:
In file included from /mnt/lfs/sources/linux-2.6.37/include/linux/module.h:9:
In file included from /mnt/lfs/sources/linux-2.6.37/include/linux/list.h:7:
In file included from /mnt/lfs/sources/linux-2.6.37/include/linux/prefetch.h:14:
In file included from /mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/processor.h:15:
/mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/current.h:12:8: error: unknown type
name '__always_inline'
static __always_inline struct task_struct *get_current(void)
^
/mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/current.h:12:24: error: expected
identifier or '('
static __always_inline struct task_struct *get_current(void)
^
In file included from /mnt/lfs/sources/linux-2.6.37/init/main.c:13:
In file included from /mnt/lfs/sources/linux-2.6.37/include/linux/module.h:9:
In file included from /mnt/lfs/sources/linux-2.6.37/include/linux/list.h:7:
In file included from /mnt/lfs/sources/linux-2.6.37/include/linux/prefetch.h:14:
In file included from /mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/processor.h:17:
In file included from /mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/system.h:7:
In file included from /mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/cmpxchg.h:4:
In file included from /mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/cmpxchg_64.h:4:
/mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/alternative.h:47:2: error: unknown
type name 'u8'
u8 *instr; /* original instruction */
^
/mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/alternative.h:48:2: error: unknown
type name 'u8'
u8 *replacement;
^
/mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/alternative.h:49:2: error: unknown
type name 'u16'
u16 cpuid; /* cpuid bit set for replacement */
^
/mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/alternative.h:50:2: error: unknown
type name 'u8'
u8 instrlen; /* length of original instruction */
^
/mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/alternative.h:51:2: error: unknown
type name 'u8'
u8 replacementlen; /* length of new instruction, <&#61; instrlen */
^
/mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/alternative.h:164:62: error: unknown
type name &#39;size_t&#39;
extern void *text_poke_early(void *addr, const void *opcode, size_t len);
^
/mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/alternative.h:183:56: error: unknown
type name &#39;size_t&#39;
extern void *text_poke(void *addr, const void *opcode, size_t len);
^
/mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/alternative.h:184:60: error: unknown
type name &#39;size_t&#39;
extern void *text_poke_smp(void *addr, const void *opcode, size_t len);
^
In file included from /mnt/lfs/sources/linux-2.6.37/init/main.c:13:
In file included from /mnt/lfs/sources/linux-2.6.37/include/linux/module.h:9:
In file included from /mnt/lfs/sources/linux-2.6.37/include/linux/list.h:7:
In file included from /mnt/lfs/sources/linux-2.6.37/include/linux/prefetch.h:14:
In file included from /mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/processor.h:17:
In file included from /mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/system.h:7:
In file included from /mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/cmpxchg.h:4:
/mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/cmpxchg_64.h:6:39: error: unknown type
name &#39;u64&#39;
static inline void set_64bit(volatile u64 *ptr, u64 val)
^
/mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/cmpxchg_64.h:6:49: error: unknown type
name &#39;u64&#39;
static inline void set_64bit(volatile u64 *ptr, u64 val)
^
In file included from /mnt/lfs/sources/linux-2.6.37/init/main.c:13:
In file included from /mnt/lfs/sources/linux-2.6.37/include/linux/module.h:9:
In file included from /mnt/lfs/sources/linux-2.6.37/include/linux/list.h:7:
In file included from /mnt/lfs/sources/linux-2.6.37/include/linux/prefetch.h:14:
In file included from /mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/processor.h:17:
In file included from /mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/system.h:11:
In file included from /mnt/lfs/sources/linux-2.6.37/include/linux/irqflags.h:15:
/mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/irqflags.h:20:2: error: use of
undeclared identifier &#39;asm&#39;
asm volatile("# __raw_save_flags\n\t"
^
/mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/irqflags.h:31:2: error: use of
undeclared identifier &#39;asm&#39;
asm volatile("push %0 ; popf"
^
/mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/irqflags.h:39:2: error: use of
undeclared identifier &#39;asm&#39;
asm volatile("cli": : :"memory");
^
/mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/irqflags.h:44:2: error: use of
undeclared identifier &#39;asm&#39;
asm volatile("sti": : :"memory");
^
/mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/irqflags.h:49:2: error: use of
undeclared identifier &#39;asm&#39;
asm volatile("sti; hlt": : :"memory");
^
/mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/irqflags.h:54:2: error: use of
undeclared identifier &#39;asm&#39;
asm volatile("hlt": : :"memory");
^
In file included from /mnt/lfs/sources/linux-2.6.37/init/main.c:13:
In file included from /mnt/lfs/sources/linux-2.6.37/include/linux/module.h:9:
In file included from /mnt/lfs/sources/linux-2.6.37/include/linux/list.h:7:
In file included from /mnt/lfs/sources/linux-2.6.37/include/linux/prefetch.h:14:
In file included from /mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/processor.h:17:
/mnt/lfs/sources/linux-2.6.37/arch/x86/include/asm/system.h:335:2: error: use of
undeclared identifier &#39;asm&#39;
asm volatile("clflush %0" : "&#43;m" (*(volatile char __force *)__p));
^
fatal error: too many errors emitted, stopping now [-ferror-limit&#61;]
1 warning and 20 errors generated.
请帮忙,我已经试着用谷歌搜索这个错误,但没有找到合适的。我已经添加了来自内核源目录的内核头
-I
标志,因为编译器在我的系统ArchLinux 5.0.10-arch1-1-ARCH上找不到它们。