Linux内核编译——瞎编译导致的问题
最近买了itop-4412 的板⼦ 准被从内核移植  驱动编写  应⽤编程重新⾛⼀遍,刚开始很多问题没有搞懂,导致下⾯⼀些问题,后⾯会整理从0编译的⽂档
Makefile:506: arch//Makefile: No such file or directory
make: *** No rule to make target 'arch//Makefile'.  Stop.
ARCH?= $(SUBARCH) 这⾥不能修改成 ARCH?= $(arm)
Makefile中 $是递归展开如果arm在之前没有定义则ARCH展开为空
应该改为ARCH?= arm
gcc: error: unrecognized argument in option ‘-mabi=aapcs-linux’
gcc: note: valid arguments to ‘-mabi=’ are: ms sysv
gcc: error: unrecognized command line option ‘-mlittle-endian’
gcc: error: unrecognized command line option ‘-mno-thumb-interwork’
gcc: error: unrecognized command line option ‘-mfpu=vfp’
Kbuild:21: recipe for target 'kernel/bounds.s' failed
make[1]: *** [kernel/bounds.s] Error 1
Makefile:1097: recipe for target 'prepare0' failed
make: *** [prepare0] Error 2
CROSS_COMPLIE?= /home/cjx/Linux/Linux/LinuxTool/CompileTool/arm-2009q3/bin/arm-none-linux-
gnueabi-
这个问题是猜测是由于编译器OABI  ,⽽我下载最新的内核是只⽀持EABI的编译器所以没法通过,所以我⼜下载
了3.1的版本来编译,去掉内核中的Kernel Features->Use the ARM EABIto compile the kernel选项
cc1: error: unrecognized command line option "-fstack-protector-strong"
Kbuild:35: recipe for target 'kernel/bounds.s' failed
make[1]: *** [kernel/bounds.s] Error 1
gnu编译器
Makefile:980: recipe for target 'prepare0' failed
make: *** [prepare0] Error 2
这是由于编译器太⽼的原因 换个编译器 重新修改下Makefile编译器路径
fixdep: error opening depfile: kernel/.bounds.s.d: No such file or directory
Kbuild:35: recipe for target 'kernel/bounds.s' failed
make[1]: *** [kernel/bounds.s] Error 2
Makefile:980: recipe for target 'prepare0' failed
make: *** [prepare0] Error 2
有⼈说还是编译器不兼容内核的原因 可以查Documentation/Changes 看内核需要最低版本的编译器
Gnu C                  3.2                    # gcc --version
换了4.4.3的版本还是不⾏
bounds.c⾥⾯是个跳跃函数
这⾥看问题的描述是在Kbuild的35⾏,Kbuild是内核的配置⽂件,这⾥看出bounds.s 是由bounds.c⽣成的,
但是为什么⽣成不了呢,最后想想还是编译器不⾏,⼜把下载了3.3.2的版本,编译⼜出现下⾯的问题
error: unrecognized command line option '-fstack-protector-strong
解决办法:
在kernel⽬录下:
make menuconfig
在 General setup——
Optimize very unlikely/likely branches  把该项在编译该项中去掉。如下图:
或者把⼦选项Stack Protector buffer overflow detection 设置为None
接着编译
Assembler messages:
Error: unknown architecture `armv7-a'
scripts/Makefile.build:257: recipe for target 'scripts/mod/empty.o' failed
make[2]: *** [scripts/mod/empty.o] Error 1
scripts/Makefile.build:402: recipe for target 'scripts/mod' failed
make[1]: *** [scripts/mod] Error 2
Makefile:555: recipe for target 'scripts' failed
make: *** [scripts] Error 2
这应该是menuconfig没有配置好的原因,
在System Type中选择Samsung S3C24XX SoCs
/
home/cjx/usr/local/arm/3.3.2/bin/../lib/gcc-lib/arm-linux/3.3.2/../../../../arm-linux/bin/as: unrecognized option '-gdwarf-2' scripts/Makefile.build:293: recipe for target 'usr/initramfs_data.o' failed
make[1]: *** [usr/initramfs_data.o] Error 1
Makefile:937: recipe for target 'usr' failed
make: *** [usr] Error 2
这⾥看还是gcc有问题没有 gdwarf-2 的选项
最终⼜换了编译器通过,后续要分析下编译器与内核的关系
CHK    include/lease
Cannot use CONFIG_CC_STACKPROTECTOR_STRONG: -fstack-protector-strong not supported by compiler Makefile:1090: recipe for target 'prepare-compiler-check' failed
make: *** [prepare-compiler-check] Error 1
说明编译器不⽀持更强的堆栈保护,
在 >General setup->Stack Protector buffer overflow detection (Regular)  --->
改成Regular
这个变量在arch/Kconfig⾥⾯

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。