Linux 2.6.32.27在Debian 7下编译不过的问题

现象:
v2.6.32.61在Debian 7 i386下编译正常,后来切换到v2.6.32.27,首先遇到一个编译不过的问题,后来确定由提交1解决了。
提交1出现在v2.6.32.61中,v2.6.32.60中还没有,好新啊!
后来又出现了-m elf_i386不识别的编译错误,确定由提交2解决了。
后来编译时出现很多warning,发现是由提交3解决的。


这三个问题都是由于Debian 7使用了gcc 4.7所导致的。Linux kernel是蛋,gcc是鸡,蛋离不开鸡。


在这个过程中温习了git branch, git checkout, git log的用法
尤其是深刻体会到了很多commit只在某个branch中存在,在master中是没有的。
linux.git和linux-stable.git的区别有了更明确的体会。


一个有趣的问题,如何判断某个commit从哪个tag开始存在的?
可以用以下命令来得到所有tag的时间,与git show某个commit的时间作对比就可以了
git log --tags --simplify-by-decoration --format="%ci %d"


下面这些命令的结果分别是什么?可以思考一下
git log --simplify-by-decoration --format="%ci %d"
git log --format="%ci %d"
git log --oneline
git log --format="%ci %d" --oneline
git log --simplify-by-decoration --pretty=medium 
git log --format="%ci %s %d"
git log --simplify-by-decoration --format="%ci %s %d" 
git log --simplify-by-decoration --format="%ci %s %d" --stat

========================================================(commit 1)
git show 4ed3bb08f1698c62685278051c19f474fbf961d2
commit 4ed3bb08f1698c62685278051c19f474fbf961d2
Author: Willy Tarreau <w@1wt.eu>
Date:   Fri Jun 7 07:11:37 2013 +0200


    x86, ptrace: fix build breakage with gcc 4.7
    
    Christoph Biedl reported that 2.6.32 does not build with gcc 4.7 on
    i386 :
    
      CC      arch/x86/kernel/ptrace.o
    arch/x86/kernel/ptrace.c:1472:17: error: conflicting types for 'syscall_trace_enter'
    In file included from /«PKGBUILDDIR»/arch/x86/include/asm/vm86.h:130:0,
                     from /«PKGBUILDDIR»/arch/x86/include/asm/processor.h:10,
                     from /«PKGBUILDDIR»/arch/x86/include/asm/thread_info.h:22,
                     from include/linux/thread_info.h:56,
                     from include/linux/preempt.h:9,
                     from include/linux/spinlock.h:50,
                     from include/linux/seqlock.h:29,
                     from include/linux/time.h:8,
                     from include/linux/timex.h:56,
                     from include/linux/sched.h:56,
                     from arch/x86/kernel/ptrace.c:11:
    /«PKGBUILDDIR»/arch/x86/include/asm/ptrace.h:145:13: note: previous declaration of 'syscall_trace_enter' was here
    arch/x86/kernel/ptrace.c:1517:17: error: conflicting types for 'syscall_trace_leave'
    In file included from /«PKGBUILDDIR»/arch/x86/include/asm/vm86.h:130:0,
                     from /«PKGBUILDDIR»/arch/x86/include/asm/processor.h:10,
                     from /«PKGBUILDDIR»/arch/x86/include/asm/thread_info.h:22,
                     from include/linux/thread_info.h:56,
                     from include/linux/preempt.h:9,
                     from include/linux/spinlock.h:50,
                     from include/linux/seqlock.h:29,
                     from include/linux/time.h:8,
                     from include/linux/timex.h:56,
                     from include/linux/sched.h:56,
                     from arch/x86/kernel/ptrace.c:11:
    /«PKGBUILDDIR»/arch/x86/include/asm/ptrace.h:146:13: note: previous declaration of 'syscall_trace_leave' was here
    make[4]: *** [arch/x86/kernel/ptrace.o] Error 1
    make[3]: *** [arch/x86/kernel] Error 2
    make[3]: *** Waiting for unfinished jobs....
    
    He also found that this issue did not appear in more recent kernels since
    this asmregparm disappeared in 3.0-rc1 with commit 1b4ac2a935 that was
    applied after some UM changes that we don't necessarily want in 2.6.32.
    
    Thus, the cleanest fix for older kernels is to make the declaration in
    ptrace.h match the one in ptrace.c by specifying asmregparm on these
    functions. They're only called from asm which explains why it used to
    work despite the inconsistency in the declaration.
    
    Reported-by: Christoph Biedl <linux-kernel.bfrz@manchmal.in-ulm.de>
    Tested-by: Christoph Biedl <linux-kernel.bfrz@manchmal.in-ulm.de>
    Signed-off-by: Willy Tarreau <w@1wt.eu>


diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
index 0f0d908..e668d72 100644
--- a/arch/x86/include/asm/ptrace.h
+++ b/arch/x86/include/asm/ptrace.h
@@ -2,6 +2,7 @@
 #define _ASM_X86_PTRACE_H
 
 #include <linux/compiler.h>    /* For __user */
+#include <linux/linkage.h>     /* For asmregparm */
 #include <asm/ptrace-abi.h>
 #include <asm/processor-flags.h>
 
@@ -142,8 +143,8 @@ extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
                         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)
 {

========================================================(commit 2)
git show ed215240d3a6a99573660e33e3034202368d025e


diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
index 6b4ffed..dd78ef6 100644
--- a/arch/x86/vdso/Makefile
+++ b/arch/x86/vdso/Makefile
@@ -25,7 +25,7 @@ targets += vdso.so vdso.so.dbg vdso.lds $(vobjs-y)
 
 export CPPFLAGS_vdso.lds += -P -C
 
-VDSO_LDFLAGS_vdso.lds = -m elf_x86_64 -Wl,-soname=linux-vdso.so.1 \
+VDSO_LDFLAGS_vdso.lds = -m64 -Wl,-soname=linux-vdso.so.1 \
                        -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096
 
 $(obj)/vdso.o: $(src)/vdso.S $(obj)/vdso.so
@@ -69,7 +69,7 @@ vdso32.so-$(VDSO32-y)         += sysenter
 vdso32-images                  = $(vdso32.so-y:%=vdso32-%.so)
 
 CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds)
-VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -Wl,-soname=linux-gate.so.1
+VDSO_LDFLAGS_vdso32.lds = -m32 -Wl,-soname=linux-gate.so.1
 
 # This makes sure the $(obj) subdirectory exists even though vdso32/
 # is not a kbuild sub-make subdirectory.

========================================================(commit 3)
git show 126a2f643ee673c6dfdf782fc84ffb400bd3c4c5
commit 126a2f643ee673c6dfdf782fc84ffb400bd3c4c5
Author: Dave Jones <davej@redhat.com>
Date:   Thu Apr 21 17:28:13 2011 -0400


    kbuild: Disable -Wunused-but-set-variable for gcc 4.6.0
    
    commit af0e5d565d2fffcd97d1e2d89669d627cc04e8b8 upstream.
    
    Disable the new -Wunused-but-set-variable that was added in gcc 4.6.0
    It produces more false positives than useful warnings.
    
    This can still be enabled using W=1
    [gregkh - No it can not for 2.6.32, but we don't care]
    
    Signed-off-by: Dave Jones <davej@redhat.com>
    Acked-by: Sam Ravnborg <sam@ravnborg.org>
    Tested-by: Sam Ravnborg <sam@ravnborg.org>
    Signed-off-by: Michal Marek <mmarek@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


diff --git a/Makefile b/Makefile
index 400a175..3cc6d4f 100644
--- a/Makefile
+++ b/Makefile
@@ -537,6 +537,9 @@ ifndef CONFIG_CC_STACKPROTECTOR
 KBUILD_CFLAGS += $(call cc-option, -fno-stack-protector)
 endif
 
+# This warning generated too much noise in a regular build.
+KBUILD_CFLAGS += $(call cc-option, -Wno-unused-but-set-variable)
+
 ifdef CONFIG_FRAME_POINTER
 KBUILD_CFLAGS  += -fno-omit-frame-pointer -fno-optimize-sibling-calls

 else


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值