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

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里面是个跳跃函数

这里看问题的描述是在Kbuild35行,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/config/kernel.release
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里面

猜你喜欢

转载自blog.csdn.net/cheng401733277/article/details/79827750
今日推荐