ubuntu编译linux kernel v2.6.30 各种错误排除

一、资源准备

1、下载一个较稳定的老版本,2.6.30, 并解压源码:

1 wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.30.tar.xz
2 tar Jxf linux-2.6.30.tar.xz
3 cd linux-2.6.30/

 

2、生成基本的配置信息:

make defconfig

  

二、工具配置

接下来要对内核默认配置文件进行修改,有3中方式,gconfig、xconfig和menuconfig, 分别依赖与gtk+2.0、qt3和libncurses5-dev。 通过相应命令安装依赖的包后,就可一进行配置了;

1、使用menuconfig进行配置

1 sudo apt-get install libncurses5-dev
2 make menuconfig

 

2、使用gconfig进行配置

make gconfig
*
* Unable to find the GTK+ installation. Please make sure that
* the GTK+ 2.0 development package is correctly installed...
* You need gtk+-2.0, glib-2.0 and libglade-2.0.
*
make[1]: *** No rule to make target `scripts/kconfig/.tmp_gtkcheck', needed by `scripts/kconfig/gconf.o'.  Stop.
make: *** [gconfig] Error 2

需要安装以下软件包,然后重新开始:

1 sudo apt-get install libgtk2.0-dev libglib2.0-dev libglade2-dev
2 make gconfig

 

3、使用xconfig进行配置

这个对qt3依赖,已经安装了qt3-dev-tools也不行呢,没有找到解决方案,所以放弃折腾了;谁有好方法解决请告知哇。

$make gconfig
  HOSTCC  scripts/kconfig/gconf.o
In file included from /usr/include/gtk-2.0/gtk/gtk.h:236:0,
                 from /usr/include/libglade-2.0/glade/glade-xml.h:26,
                 from /usr/include/libglade-2.0/glade/glade.h:28,
                 from scripts/kconfig/gconf.c:16:
/usr/include/gtk-2.0/gtk/gtkitemfactory.h:47:1: warning: function declaration isn’t a prototype
scripts/kconfig/gconf.c: In function ‘text_insert_help’:
scripts/kconfig/gconf.c:469:3: warning: format not a string literal and no format arguments
scripts/kconfig/gconf.c: In function ‘on_introduction1_activate’:
scripts/kconfig/gconf.c:754:6: warning: format not a string literal and no format arguments
scripts/kconfig/gconf.c: In function ‘on_about1_activate’:
scripts/kconfig/gconf.c:772:6: warning: format not a string literal and no format arguments
scripts/kconfig/gconf.c: In function ‘on_license1_activate’:
scripts/kconfig/gconf.c:791:6: warning: format not a string literal and no format arguments
scripts/kconfig/gconf.c: At top level:
scripts/kconfig/images.c:6:20: warning: ‘xpm_load’ defined but not used
scripts/kconfig/images.c:36:20: warning: ‘xpm_save’ defined but not used
scripts/kconfig/images.c:66:20: warning: ‘xpm_back’ defined but not used
scripts/kconfig/images.c:175:20: warning: ‘xpm_symbol_no’ defined but not used
scripts/kconfig/images.c:192:20: warning: ‘xpm_symbol_mod’ defined but not used
scripts/kconfig/images.c:209:20: warning: ‘xpm_symbol_yes’ defined but not used
scripts/kconfig/images.c:226:20: warning: ‘xpm_choice_no’ defined but not used
scripts/kconfig/images.c:243:20: warning: ‘xpm_choice_yes’ defined but not used
scripts/kconfig/images.c:277:20: warning: ‘xpm_menu_inv’ defined but not used
scripts/kconfig/images.c:294:20: warning: ‘xpm_menuback’ defined but not used
scripts/kconfig/gconf.c:957:13: warning: ‘renderer_toggled’ defined but not used
  HOSTLD  scripts/kconfig/gconf
scripts/kconfig/gconf arch/x86/Kconfig

 

 

三、错误排除

1、出现错误syscall_trace_leave

arch/x86/include/asm/ptrace.h:146:13: note: previous declaration of 'syscall_trace_leave' was here
make[2]: *** [arch/x86/kernel/ptrace.o] Error 1
make[1]: *** [arch/x86/kernel] Error 2
make: *** [arch/x86] Error 2

解决方案参考这个补丁: https://patchwork.kernel.org/patch/1301031/

Patch

--- linux-2.6.32.59/arch/x86/include/asm/ptrace.h
+++ fix_ptrace.o_compile_error/arch/x86/include/asm/ptrace.h
@@ -130,6 +130,7 @@ 
 #ifdef __KERNEL__
 
 #include 
+#include 
 
 struct cpuinfo_x86;
 struct task_struct;
@@ -142,8 +143,8 @@ 
              int error_code, int si_code);
 void signal_fault(struct pt_regs *regs, void __user *frame, char *where);
 
-extern long syscall_trace_enter(struct pt_regs *);
-extern void syscall_trace_leave(struct pt_regs *);
+extern asmregparm long syscall_trace_enter(struct pt_regs *);
+extern asmregparm void syscall_trace_leave(struct pt_regs *);
 
 static inline unsigned long regs_return_value(struct pt_regs *regs)
 {

 

2、错误gcc不识别-m参数

gcc: error: unrecognized command line option ‘-m’
gcc: error: elf_i386: No such file or directory
make[1]: *** [arch/x86/vdso/vdso32-int80.so.dbg] Error 1

由于我现在用的是ubuntu 12.10 使用的是gcc-4.7,发现了一个新版本的移植的问题,所以安装gcc-4.5,然后重新链接就搞定了,可以继续编译:

sudo apt-get install gcc-4.5
cd /usr/bin
sudo ln -s -f gcc-4.5 gcc

继续编译中:

#使用-j4指定4个线程编译
make -j4

 

四、编译成功

基本使用的默认设置,就是第一步的make defconfig后的配置参数,然后make -j4,好像编译的挺快的,后面在详细研究以下各种参数,已经如何启用这个自己编译的内核 :)。

  CHK     include/linux/version.h
  CHK     include/linux/utsrelease.h
  SYMLINK include/asm -> include/asm-x86
  CALL    scripts/checksyscalls.sh
  CHK     include/linux/compile.h
  VDSOSYM arch/x86/vdso/vdso32-int80-syms.lds
  VDSOSYM arch/x86/vdso/vdso32-sysenter-syms.lds
  VDSOSYM arch/x86/vdso/vdso32-syms.lds
  LD      arch/x86/vdso/built-in.o
  LD      vmlinux.o
  MODPOST vmlinux.o
WARNING: modpost: Found 3 section mismatch(es).
To see full details build your kernel with:
'make CONFIG_DEBUG_SECTION_MISMATCH=y'
  GEN     .version
  CHK     include/linux/compile.h
  UPD     include/linux/compile.h
  CC      init/version.o
  LD      init/built-in.o
  LD      .tmp_vmlinux1
  KSYM    .tmp_kallsyms1.S
  AS      .tmp_kallsyms1.o
  LD      .tmp_vmlinux2
  KSYM    .tmp_kallsyms2.S
  AS      .tmp_kallsyms2.o
  LD      .tmp_vmlinux3
  KSYM    .tmp_kallsyms3.S
  AS      .tmp_kallsyms3.o
  LD      vmlinux
  SYSMAP  System.map
  SYSMAP  .tmp_System.map
  OBJCOPY arch/x86/boot/compressed/vmlinux.bin
  GZIP    arch/x86/boot/compressed/vmlinux.bin.gz
  LD      arch/x86/boot/compressed/piggy.o
  LD      arch/x86/boot/compressed/vmlinux
  OFFSETS arch/x86/boot/offsets.h
  AS      arch/x86/boot/header.o
  CC      arch/x86/boot/version.o
  LD      arch/x86/boot/setup.elf
  OBJCOPY arch/x86/boot/setup.bin
  OBJCOPY arch/x86/boot/vmlinux.bin
  BUILD   arch/x86/boot/bzImage
Root device is (8, 11)
Setup is 10060 bytes (padded to 10240 bytes).
System is 3539 kB
CRC d3a625ec
Kernel: arch/x86/boot/bzImage is ready  (#2)
  Building modules, stage 2.
  MODPOST 2 modules

转载于:https://www.cnblogs.com/QuLory/archive/2012/09/27/2706429.html

你可能感兴趣的:(ubuntu编译linux kernel v2.6.30 各种错误排除)