前几天刚装上号称能与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 即可。
阅读(988) | 评论(0) | 转发(0) |