当前位置: 技术问答>linux和unix
内核编译错误,请看看呢!
来源: 互联网 发布时间:2016-11-22
本文导语: 环境: CPU: AMD Athlon(tm) II X2 250 Processor stepping 02 vmare上装了 [root@localhost linux-2.6.35.7]# uname -r 2.4.20-8 打算编译2.6.35.7 步骤: step1:make menuconfig step2:make bzImage 出现如下错误: [root@localhost linux-2.6.35.7]# make...
环境:
CPU: AMD Athlon(tm) II X2 250 Processor stepping 02
vmare上装了
[root@localhost linux-2.6.35.7]# uname -r
2.4.20-8
打算编译2.6.35.7
步骤:
step1:make menuconfig
step2:make bzImage
出现如下错误:
[root@localhost linux-2.6.35.7]# make bzImage
CHK include/linux/version.h
CHK include/generated/utsrelease.h
CC arch/x86/kernel/asm-offsets.s
In file included from /usr/src/linux-2.6.35.7/arch/x86/include/asm/bitops.h:447,
from include/linux/bitops.h:22,
from include/linux/kernel.h:17,
from /usr/src/linux-2.6.35.7/arch/x86/include/asm/percpu.h:44,
from /usr/src/linux-2.6.35.7/arch/x86/include/asm/current.h:5,
from /usr/src/linux-2.6.35.7/arch/x86/include/asm/processor.h:15,
from /usr/src/linux-2.6.35.7/arch/x86/include/asm/atomic.h:6,
from include/linux/crypto.h:20,
from arch/x86/kernel/asm-offsets_32.c:7,
from arch/x86/kernel/asm-offsets.c:2:
/usr/src/linux-2.6.35.7/arch/x86/include/asm/arch_hweight.h: In function `__arch_hweight32':
/usr/src/linux-2.6.35.7/arch/x86/include/asm/arch_hweight.h:29: parse error before string constant ---------->
In file included from include/linux/kobject.h:21,
from include/linux/module.h:16,
from include/linux/crypto.h:21,
from arch/x86/kernel/asm-offsets_32.c:7,
from arch/x86/kernel/asm-offsets.c:2:
include/linux/sysfs.h: At top level:
include/linux/sysfs.h:183: warning: parameter has incomplete type
/usr/src/linux-2.6.35.7/arch/x86/include/asm/cpufeature.h: In function `__static_cpu_has':
/usr/src/linux-2.6.35.7/arch/x86/include/asm/cpufeature.h:315: warning: asm operand 1 probably doesn't match constraints
make[1]: *** [arch/x86/kernel/asm-offsets.s] Error 1
CPU: AMD Athlon(tm) II X2 250 Processor stepping 02
vmare上装了
[root@localhost linux-2.6.35.7]# uname -r
2.4.20-8
打算编译2.6.35.7
步骤:
step1:make menuconfig
step2:make bzImage
出现如下错误:
[root@localhost linux-2.6.35.7]# make bzImage
CHK include/linux/version.h
CHK include/generated/utsrelease.h
CC arch/x86/kernel/asm-offsets.s
In file included from /usr/src/linux-2.6.35.7/arch/x86/include/asm/bitops.h:447,
from include/linux/bitops.h:22,
from include/linux/kernel.h:17,
from /usr/src/linux-2.6.35.7/arch/x86/include/asm/percpu.h:44,
from /usr/src/linux-2.6.35.7/arch/x86/include/asm/current.h:5,
from /usr/src/linux-2.6.35.7/arch/x86/include/asm/processor.h:15,
from /usr/src/linux-2.6.35.7/arch/x86/include/asm/atomic.h:6,
from include/linux/crypto.h:20,
from arch/x86/kernel/asm-offsets_32.c:7,
from arch/x86/kernel/asm-offsets.c:2:
/usr/src/linux-2.6.35.7/arch/x86/include/asm/arch_hweight.h: In function `__arch_hweight32':
/usr/src/linux-2.6.35.7/arch/x86/include/asm/arch_hweight.h:29: parse error before string constant ---------->
In file included from include/linux/kobject.h:21,
from include/linux/module.h:16,
from include/linux/crypto.h:21,
from arch/x86/kernel/asm-offsets_32.c:7,
from arch/x86/kernel/asm-offsets.c:2:
include/linux/sysfs.h: At top level:
include/linux/sysfs.h:183: warning: parameter has incomplete type
/usr/src/linux-2.6.35.7/arch/x86/include/asm/cpufeature.h: In function `__static_cpu_has':
/usr/src/linux-2.6.35.7/arch/x86/include/asm/cpufeature.h:315: warning: asm operand 1 probably doesn't match constraints
make[1]: *** [arch/x86/kernel/asm-offsets.s] Error 1
|
刚好我刚刚搞完,在网上看到你的帖子,就忍不住share一下经验(我有一两年没回答问题了,呵呵),也许正好解决你的问题。我也曾经被这个问题困扰了一天,最后自己修改代码通过编译。我用的是2.6.36的内核。
修改
/usr/src/linux-2.6.35.7/arch/x86/include/asm/arch_hweight.h:29行,
: "="REG_OUT (res)
为
:"=a" (res)
在这个头文件的开头,REG_OUT被定义为"a". 虽然前面有ifdef,但if和else入口REG_OUT都是"a".所以没有什么好担心。
很明显 "="REG_OUT 是正确的代码,但不知为什么GCC预编译器会报告为错误。直接替换成预编译后的代码就行了。kernel那帮人现在也很不认真。很明显没有做过gcc 3.2的测试。
内核2.6.35以后对这个地方进行了修改,加了一些代码,好像是为了解决ppc上的问题。
但估计他们也没想到会引起旧的(RH9)gcc报告这个错误。尽管RH9的GCC 3.2版本也是2.6.35,36版本内核所支持的。
顺便说一句,升级RH9到2.6.35,36的内核,难度相当大。后面有很多陷阱。升级到2.6.18可能简单很多。
修改
/usr/src/linux-2.6.35.7/arch/x86/include/asm/arch_hweight.h:29行,
: "="REG_OUT (res)
为
:"=a" (res)
在这个头文件的开头,REG_OUT被定义为"a". 虽然前面有ifdef,但if和else入口REG_OUT都是"a".所以没有什么好担心。
很明显 "="REG_OUT 是正确的代码,但不知为什么GCC预编译器会报告为错误。直接替换成预编译后的代码就行了。kernel那帮人现在也很不认真。很明显没有做过gcc 3.2的测试。
内核2.6.35以后对这个地方进行了修改,加了一些代码,好像是为了解决ppc上的问题。
但估计他们也没想到会引起旧的(RH9)gcc报告这个错误。尽管RH9的GCC 3.2版本也是2.6.35,36版本内核所支持的。
顺便说一句,升级RH9到2.6.35,36的内核,难度相当大。后面有很多陷阱。升级到2.6.18可能简单很多。