免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 812 | 回复: 0
打印 上一主题 下一主题

gcc4.3 编译内核错误 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-04-12 20:31 |只看该作者 |倒序浏览
前几天刚装上号称能与windows相媲美的openSUSE11.1。openSUSE的桌面的确挺漂亮的,使用起来有种舒适的感觉。系统上的Pidgin还可以上qq。由于学习的需要,我下载2.6.23内核,并给内核打上rtai-3.6.2的实时补丁。然后make menuconfig, make编译内核。但是在编译的过程中出现了这样的错误:
kernel/built-in.o: In function `timespec_add_ns':
/home/wbs/source/linux/include/linux/time.h:174: undefined reference to `__udivdi3'
/home/wbs/source/linux/include/linux/time.h:179: undefined reference to `__umoddi3'
/home/wbs/source/linux/include/linux/time.h:174: undefined reference to `__udivdi3'
/home/wbs/source/linux/include/linux/time.h:179: undefined reference to `__umoddi3'
/home/wbs/source/linux/include/linux/time.h:174: undefined reference to `__udivdi3'
/home/wbs/source/linux/include/linux/time.h:179: undefined reference to `__umoddi3'
make: *** [.tmp_vmlinux1] 错误 1
在网上搜了一下,据说是gcc的问题。因为系统使用的是gcc4.3,gcc4.3据说不能编译内核。因为它会用到libgcc未定义的函数。现在有两种解决方案。
一种是:
QUOTE:static inline void timespec_add_ns(struct timespec *a, u64 ns)
{
        ns += a->tv_nsec;
        while(unlikely(ns >= NSEC_PER_SEC)) {
+               /* The following asm() prevents the compiler from
+                * optimising this loop into a modulo operation.  */
+               asm("" : "+r"(ns));
+
                ns -= NSEC_PER_SEC;
                a->tv_sec++;
        }
在原先include/linux/time.h中的该函数中增加:asm("" : "+r"(ns));用来防止编译器对while循环进行优化。
另一种解决方法是:
QUOTE:edit kernel Makefile
add to KBUILD_CFLAGS -fno-tree-scev-cprop
QUOTE:Linux 2.6 tree as of this minute doesn't compile with gcc 4.3 trunk. You need
to add -fno-tree-scev-cprop to the KBUILD_CFLAGS, but this is not upstreamed
yet and I am not sure if it'll be accepted in case it results in a performance
regression.
即在Makefile中的CFLAGS中添加-fno-tree-scev-cprop 即可。


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/93336/showart_1898743.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP