编译Linux内核3.2 for ARM时出错 [英] Error when compiling Linux kernel 3.2 for ARM
问题描述
我正在学习本教程,以便为ARM编译Linux内核3.2并使用QEMU进行模拟: $ b
https://balau82.wordpress.com/2012/03/31 / compile-linux-kernel-3-2-arm-and-emulate-with-qemu /
我遵循以下步骤:
-
wget http://www.kernel.org/pub/linux/kernel/v3.0/linux- 3.2.tar.bz2
-
tar xjf linux-3.2.tar.bz2
-
export ARCH = arm
-
export CROSS_COMPILE = arm-linux-gnueabi-
-
cd linux-3.2
-
make vexpress_defconfig
-
make all
-
cd ..
-
arm-linux-gnueabi-gcc -static init.c -o init
-
echo init | cpio -o --format = newc> initramfs
-
qemu-system-arm -M vexpress -a9 -kernel linux-3.2 / arch / arm / boot / zImage -initrd initramfs -serial stdio -appendconsole = tty1
我的问题是当我尝试第7步发生这个问题:
$ b $ pre $ include / linux / compiler-gcc.h:94:30:致命错误:linux /compiler-gcc5.h:没有这样的文件或目录
编译终止。
/home/ramy/QEMU_Learn/kernel/linux-3.2/./Kbuild:35:目标'kernel / bounds.s'的配方失败
make [1]:*** [kernel / bounds .s] Error 1
Makefile:985:recipe'prepare0'failed
I我正在使用Ubuntu操作系统,我正在使用Linaro工具链来编译内核。
我也检查了PATH变量,结果如下:
$ printenv | grep PATH
XDG_SESSION_PATH = / org / freedesktop / DisplayManager / Session0
XDG_SEAT_PATH = / org / freedesktop / DisplayManager / Seat0
DEFAULTS_PATH = / usr / share / gconf / ubuntu.default .path
PATH = / usr / local / sbin:/ usr / local / bin:/ usr / sbin:/ usr / bin:/ sbin:/ bin:/ usr / games:/ usr / local / games: / snap / bin:/ home / ramy / gcc-arm-none-eabi-5_3-2016q1 / bin
MANDATORY_PATH = / usr / share / gconf / ubuntu.mandatory.path
$ c $你的内核版本(3.2.0)太老了,不兼容使用的gcc(gcc- 5)。您可以使用gcc-4编译内核,或使用更新的内核版本。
您的内核特别包含在 linux / compiler-gcc.h
header
http://lxr.free-electrons.com/source/include/linux/compiler-gcc.h?v=3.2#L91
<$ (x)#define __gcc_header(x)#x
92 #define _gcc_header(x)__gcc_header(linux / compiler-gcc ## xh)
93 #define gcc_header( x)_gcc_header(x)
94#包括gcc_header(__ GNUC__)
不同gcc版本的文件( GNUC 是gcc的主要版本)。它支持gcc-3和gcc-4,但不支持gcc-5:
http://lxr.free-electrons.com/source/include/linux/?v=3.2
C文件编译器-gcc.h 3705字节
C文件编译器-gcc3.h 631字节
C文件编译器-gcc4.h 2073字节
C文件compiler-intel.h 746字节
C文件compiler.h 8628字节
您可能会尝试将编译器-gcc4.h
重写为 compiler-gcc5.h
,但您应该了解这个怎么做。您可能不会将gcc4复制到gcc5,会有不正确的宏。
已添加编译器-gcc5.h
仅限于Linux内核版本3.18: http:// lxr.free-electrons.com/source/include/linux/compiler-gcc5.h?v=3.18 (不在3.17 http://lxr.free-electrons.com/source/include/linux/compiler-gcc5.h?v=3.17 )
旧版linaro编译器(在gcc-5之前) https://releases.linaro.org/components/toolchain/binaries/4.9-2016.02/
并根据对于JJ Hakala评论,在3.2。* kernel,3.2.81的最新版本中有编译器-gcc5头文件: https://www.kernel.o rg / pub / linux / kernel / v3.0 / linux-3.2.81.tar.gz - 只需将wget命令和tar xjf更改为此版本并重试即可。
I am following this tutorial to compile Linux kernel 3.2 for ARM and emulate with QEMU:
https://balau82.wordpress.com/2012/03/31/compile-linux-kernel-3-2-for-arm-and-emulate-with-qemu/
I am following the below steps:
wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.2.tar.bz2
tar xjf linux-3.2.tar.bz2
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabi-
cd linux-3.2
make vexpress_defconfig
make all
cd ..
arm-linux-gnueabi-gcc -static init.c -o init
echo init|cpio -o --format=newc > initramfs
qemu-system-arm -M vexpress-a9 -kernel linux-3.2/arch/arm/boot/zImage -initrd initramfs -serial stdio -append "console=tty1"
My problem is when I try step 7 (make all), this problem happens:
include/linux/compiler-gcc.h:94:30: fatal error: linux/compiler-gcc5.h: No such file or directory
compilation terminated.
/home/ramy/QEMU_Learn/kernel/linux-3.2/./Kbuild:35: recipe for target 'kernel/bounds.s' failed
make[1]: *** [kernel/bounds.s] Error 1
Makefile:985: recipe for target 'prepare0' failed
I am working Ubuntu operating system, and I am using Linaro tool chain to compile the kernel.
I have also checked the PATH variable and here is the result:
$ printenv | grep PATH
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
DEFAULTS_PATH=/usr/share/gconf/ubuntu.default.path
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/ramy/gcc-arm-none-eabi-5_3-2016q1/bin
MANDATORY_PATH=/usr/share/gconf/ubuntu.mandatory.path
Your kernel version (3.2.0) is too old and not compatible with used gcc (gcc-5). You may use gcc-4 to compile kernel, or use newer kernel version.
Your kernel has special include in linux/compiler-gcc.h
header
http://lxr.free-electrons.com/source/include/linux/compiler-gcc.h?v=3.2#L91
91 #define __gcc_header(x) #x
92 #define _gcc_header(x) __gcc_header(linux/compiler-gcc##x.h)
93 #define gcc_header(x) _gcc_header(x)
94 #include gcc_header(__GNUC__)
It will include different files for different gcc versions (GNUC is major version of gcc). It supports gcc-3 and gcc-4, but not gcc-5:
http://lxr.free-electrons.com/source/include/linux/?v=3.2
C file compiler-gcc.h 3705 bytes
C file compiler-gcc3.h 631 bytes
C file compiler-gcc4.h 2073 bytes
C file compiler-intel.h 746 bytes
C file compiler.h 8628 bytes
You may try to rewrite compiler-gcc4.h
to compiler-gcc5.h
, but you should understand how to do this. You may not just copy gcc4 to gcc5, there will incorrect macro.
The compiler-gcc5.h
was added only to linux kernel version 3.18: http://lxr.free-electrons.com/source/include/linux/compiler-gcc5.h?v=3.18 (not in 3.17 http://lxr.free-electrons.com/source/include/linux/compiler-gcc5.h?v=3.17)
Older linaro compiler (before gcc-5) is https://releases.linaro.org/components/toolchain/binaries/4.9-2016.02/
And according to JJ Hakala comment, there is the compiler-gcc5 header in last version of 3.2.* kernel, the 3.2.81: https://www.kernel.org/pub/linux/kernel/v3.0/linux-3.2.81.tar.gz - just change wget command and tar xjf to this version and retry.
这篇关于编译Linux内核3.2 for ARM时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!