Set up a cross-compiler when compiling Linux kernel __linux

Source: Internet
Author: User

By default, the kernel build system default kernel is compiled locally, that is, the compiled kernel is running on the same architecture as the host system. If you are compiling the kernel for another schema, that is, cross compilation, we need to set two variables: Arch and Cross_compile. which

Arch indicates the target architecture, that is, what platform the compiled kernel runs on, such as x86, ARM, or MIPS.

cross_compile Specifies the prefix of the cross compiler to use. For our cross tool chain, the prefix is i686-none-linux-gnu-.

In the top-level makefile, we can see that the compiler, linker, and so on in the tool chain are prefixed by $ (cross_compile):
Linux-3.7.4/makefile:
As = $ (cross_compile) as
LD = $ (cross_compile) LD
CC = $ (cross_compile) gcc
CPP = $ (CC)-E
AR = $ (cross_compile) AR
NM = $ (cross_compile) NM
Strip = $ (cross_compile) strip
Objcopy = $ (cross_compile) objcopy
Objdump = $ (cross_compile) objdump

You can define these two variables in a variety of ways, such as by defining Arch, cross_compile in an environment variable, or by assigning values to these two variables by naming behavior each time you execute make, such as:
Make arch=i386 cross_compile=i686-none-linux-gnu-

You can also change the top layer makefile directly. This method is more convenient, but be careful to avoid damaging makefile files. In this book we use the following script in the top-level makefile:
Linux-3.7.4/makefile:
ARCH? = $ (Subarch)
Cross_compile? = $ (config_cross_compile: "%" =%)

Change to:
Linux-3.7.4/makefile:
ARCH? = i386
Cross_compile? = i686-none-linux-gnu-

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.