android编译kernel时toolchain出现的bug问题page-writeback.c
arm-eabi-gcc -Wp,-MD,mm/.page-writeback.o.d -nostdinc -isystem /vobs/works/froyo/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/include -Iinclude -I/vobs/works/froyo/kernel/arch/arm/include -include include/linux/autoconf.h -D__KERNEL__ -mlittle-endian -Iarch/arm/mach-sc8800g/include -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -O2 -marm -mabi=aapcs-linux -mno-thumb-interwork -funwind-tables -D__LINUX_ARM_ARCH__=5 -march=armv5te -mtune=arm9tdmi -msoft-float -Uarm -Wframe-larger-than=1024 -fno-stack-protector -fomit-frame-pointer -g -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fno-dwarf2-cfi-asm -fconserve-stack -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(page_writeback)" -D"KBUILD_MODNAME=KBUILD_STR(page_writeback)" -c -o mm/.tmp_page-writeback.o mm/page-writeback.c
出现如下错误
CC mm/page-writeback.o
mm/page-writeback.c: In function 'write_cache_pages':
mm/page-writeback.c:820: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See < for instructions.
make[1]: *** [mm/page-writeback.o] Error 1
make: *** [mm] Error 2
---------------------------------------------------------
后来将mm/page-writeback.c文件的第918行注释掉即可,正常编译通过
// BUG_ON(PageWriteback(page));
后来预编译该文件,发现BUG_ON(PageWriteback(page));等效于
do { if (__builtin_expect(!!(PageWriteback(page)), 0)) __bug("mm/page-writeback.c", 918); } while(0);
或者在kernel hacking的Kernel debugging关闭时
do { if (__builtin_expect(!!(PageWriteback(page)), 0)) do { *(int *)0 = 0; } while (1); } while(0);
故使用如下方式等效,仍然出现如上编译错误
// BUG_ON(PageWriteback(page));
if (__builtin_expect(!!(PageWriteback(page)), 0)) {
printk(KERN_CRIT"kernel BUG at %s:%d!\n", __FILE__, __LINE__);
*(int *)0 = 0;
/* Avoid "noreturn function does return" */
for (;;);
}
最后发现将for (;;);去掉之后即可编译通过,但是这样就破坏了代码原来的逻辑,所以可以使用如下方式替换:
// BUG_ON(PageWriteback(page));
/*
* To avoid the android 2.2 arm-eabi-gcc 4.40 toolchain's bug,
* so you can compile the kernel properly [luther.gliethttp]
*/
if (__builtin_expect(!!(PageWriteback(page)), 0)) {
printk(KERN_CRIT"kernel BUG at %s:%d!\n", __FILE__, __LINE__);
*(int *)0 = 0;
/* Avoid "noreturn function does return" */
// for (;;);
asm volatile ("b .");
}
---------------------------------------------------------
发现kernel使用android的prebuilt/linux-x86/toolchain/arm-eabi-4.4.0下的arm-eabi-gcc不能编译通过,该现象在去年8月15号就已经存在,今天很多人都出现了该问题!
锁定到Thu Jan 21 14:24:36 2010 -0800日期之后的toolchain开始就不能编译我们的kernel,具体信息如下:
在该4b06260a916be762d0dd1b93e97306f1b90e3889 哈希之前的toolchain-->arm-eabi-gcc可以正常编译,从Mon Jan 25 09:53:00 2010 -0800的406fda666bb7c8dd4de3294c3827a27c8fd4119c版本开始就不能正常使用arm-eabi-gcc编译kernel了,大家可以尝试一下:
尝试步骤如下:
1. 进入kernel执行如下命令
git clean -xdf
2. 导出arm-eabi-工具链所处系统路径
export PATH=/home/luther.gliethttp/froyo/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin:$PATH
3. 编译
make -j4或make -j4 V=1
目录froyo/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0
commit 406fda666bb7c8dd4de3294c3827a27c8fd4119c
Author: Ying Wang
Date: Mon Jan 25 09:53:00 2010 -0800
Check in historical sdk versions.
.jar and .aidl files are copied from released sdks.
commit 4b06260a916be762d0dd1b93e97306f1b90e3889
Merge: 9e332ec e48ddfc
Author: Kenny Root
Date: Thu Jan 21 14:24:36 2010 -0800
Merge "Updated flex-2.5.4a binary, now works on 10.5 and 10.6."
commit d49c952991fc41108ca48ce44f7c51e873aacd45
Author: Jing Yu
Date: Mon Jan 18 12:38:37 2010 -0800
Check in a new prebuilt toolchain.
GCC synced to @37473-p2. Android-toolchain synced to 153083-p9.
阅读(4691) | 评论(1) | 转发(0) |