|
下面是FC5下編譯2.4.20的例子,F(xiàn)C5有bug,中文命名文件會沒有反映,建議用穩(wěn)定的FC4,F(xiàn)C5內(nèi)核貌似2.6.15還是18忘了。 1.準備2.4.20的源代碼 $tar jxf linux-2.4.20.tar.bz2 $mv linux-2.4.20 linux $cd linux $make mrproper $make config $make dep 上面這些步驟都能順利 通過 $make bzImage 一會就出現(xiàn)了如下的 錯誤 /usr/linux-2.4.20/include/linux/smp.h:29: error: conflicting types for 'smp_send_reschedule' /usr/linux-2.4.20/include/asm/smp.h:42: error: previous declaration of 'smp_send_reschedule' was here In file included from /usr/linux-2.4.20/include/linux/unistd.h:9,from init/main.c:17: /usr/linux-2.4.20/include/asm/unistd.h:375: warning: conflicting types for built-in function '_exit' 這是因為FC5下的GCC版本太新(gcc4.1) 建議使用 gcc 2.95或者gcc3.2進行編譯(Dave Thompson) 在網(wǎng)上尋找了一會,發(fā)現(xiàn)其實FC5下可以安裝一個pachage,就可以使用gcc3.2,同時不會影響當前的gcc4.1。 于是就在 ftp://rpmfind.net/linux/fedora/core/5/i386/os/Fedora/RPMS/compat-gcc-32-3.2.3-55.fc5.i386.rpm 里下載了一個 該包的大致描述為:The compatibility GNU Compiler Collection Fedora Core 5 for i386,馬上進行安裝 $rpm -ivh compat-gcc-32-3.2.3-55.fc5.i386.rpm 安裝完成后在/usr/bin下多了一個gcc32 于是馬上修改Makefile,把里面的CC修改為 gcc32,接著 $make bzImage 經(jīng)過漫長的等待(不長,也就15分鐘左右),結(jié)果等來的卻是: {standard input}: Assembler messages: {standard input}:936: Error: suffix or operands invalid for `mov' {standard input}:937: Error: suffix or operands invalid for `mov' {standard input}:1031: Error: suffix or operands invalid for `mov' {standard input}:1032: Error: suffix or operands invalid for `mov' {standard input}:1083: Error: suffix or operands invalid for `mov' {standard input}:1084: Error: suffix or operands invalid for `mov' {standard input}:1086: Error: suffix or operands invalid for `mov' {standard input}:1098: Error: suffix or operands invalid for `mov' 結(jié)論:是FC5下的binutils的一個bug, 下載相應的補丁 http://www./pub/linux/devel/binutils/linux-2.6-seg-5.patch 在待編譯的內(nèi)核源碼(本例為linux-2.4.20/)的根目錄下進行patch操作: $patch -p1 patching file arch/i386/kernel/process.c Hunk #1 succeeded at 693 with fuzz 1 (offset 96 lines). patching file arch/i386/kernel/vm86.c Hunk #1 FAILED at 294. 1 out of 1 hunk FAILED -- saving rejects to file arch/i386/kernel/vm86.c.rej patching file arch/x86_64/kernel/process.c Hunk #1 succeeded at 458 with fuzz 2 (offset 67 lines). Hunk #2 succeeded at 443 with fuzz 2 (offset -14 lines). Hunk #3 FAILED at 458. Hunk #4 FAILED at 479. 2 out of 4 hunks FAILED -- saving rejects to file arch/x86_64/kernel/process.c.rej patching file include/asm- i386/system.h Hunk #1 succeeded at 84 (offset 3 lines). Hunk #2 FAILED at 96. 1 out of 2 hunks FAILED -- saving rejects to file include/asm-i386/system.h.rej $make bzImage 又是漫長的等待,出現(xiàn)如下錯誤 {standard input}: Assembler messages: {standard input}:936: Error: suffix or operands invalid for `mov' {standard input}:937: Error: suffix or operands invalid for `mov' {standard input}:1031: Error: suffix or operands invalid for `mov' {standard input}:1032: Error: suffix or operands invalid for `mov' make[1]: *** [process.o] 錯誤 1 make[1]: Leaving directory `/usr/src/linux/arch/i386/kernel' make: *** [_dir_arch/i386/kernel] 錯誤 2 是as的問題,再編輯 arch/i386/kernel/process.c 在579行,將 asm volatile("movl %%" #seg ",%0":"=m" (*(int *)&(value))) 改成 asm volatile("mov %%" #seg ",%0":"=m" (value)) 執(zhí)行 $make bzImage 一切正常 $make modules $make modules_install 出現(xiàn)了如下的信息 cd /lib/modules/2.4.20; \ mkdir -p pcmcia; \ find kernel -path '*/pcmcia/*' -name '*.o' | xargs -i -r ln -sf ../{} pcmcia if [ -r System.map ]; then /sbin/depmod -ae -F System.map 2.4.20; fi Version requires old depmod, but couldn't run /sbin/depmod.old: No such file or directory make: *** [_modinst_post] 錯誤 2 那就創(chuàng)建一個depmod.old的鏈接 $ln -s /sbin/depmod /sbin/depmod.old $make modules_install $mkinitrd -f -v /boot/initrd-2.4.20.img 2.4.20 一切正常,修改相應的 lino或者 grub,重新啟動。 如果你不是用FC5,再遇到錯誤貼出來我給你看。。。。 |
|
|