Cross-compilation tool chain

Source: Internet
Author: User
Tags naming convention printf
Cross-compilation Toolchain cross-compiling is the process of compiling a program on a platform that can run on a different architecture, such as compiling a program on a PC platform (X86 CPU) that can run on an arm-based CPU platform, and the compiled program cannot run on the X86 CPU platform.  Must be placed on the ARM CPU platform to run, although two platforms use Linux systems. The cross-compilation toolchain is a comprehensive development environment consisting of compilers, connectors, and interpreters, and the cross-compilation toolchain consists mainly of three parts, Binutils, GCC, and glibc. Sometimes for the sake of reducing the size of the LIBC library, other C libraries can be used instead of glibc, such as UCLIBC, DIETLIBC, and Newlib.
Classification and Description

From the license, there is a free license version and a paid license version.

The free version currently has three major tools provider, the first is GNU (provide source code, self-compiled production), the second is Codesourcery, the third is Linora.

The paid version has the ARMCC provided by arm, the compiler provided by IAR, and so on, because these prices are relatively expensive, not suitable for learning user use, so do not tell. ARM-NONE-LINUX-GNUEABI-GCC: Codesourcery (currently acquired by mentor) is a GCC-based arm cross-compilation tool. Code that can be used to cross-compile all aspects of an arm (32-bit) system, including bare-metal programs, u-boot, Linux kernel, filesystem, and app applications. ARM-LINUX-GNUEABIHF-GCC: is an arm cross-compilation tool launched by Linaro company based on GCC. Code that can be used to cross-compile all aspects of an arm (32-bit) system, including bare-metal programs, u-boot, Linux kernel, filesystem, and app applications. AARCH64-LINUX-GNU-GCC: is an arm cross-compilation tool launched by Linaro company based on GCC. Can be used to cross-compile bare metal programs in ARMV8 64-bit targets, u-boot, Linux kernel, filesystem, and app applications. ARM-NONE-ELF-GCC: Codesourcery (currently acquired by mentor) is a GCC-based arm cross-compilation tool. Can be used to cross-compile arm MCU (32-bit) chip, such as ARM7, ARM9, CORTEX-M/R chip program. ARM-NONE-EABI-GCC: Is the GNU-launched Arm cross-compilation tool. Can be used to cross-compile arm MCU (32-bit) chip, such as ARM7, ARM9, CORTEX-M/R chip program. naming rules

The naming convention for the cross-compilation toolchain is: Arch [-vendor] [-os] [-(GNU) Eabi] arch– architecture, such as Arm,mips vendor– toolchain provider os– target operating system eabi– embedded Application Binary interface (Embedd Ed application Binary Interface)

Depending on whether the operating system is supported or not, ARM GCC can be divided into supported and unsupported operating systems, such as Arm-none-eabi: There is no operating system, and it is not natural to support functions that are closely related to the operating system, such as fork (2). He uses newlib, a C library dedicated to embedded systems. Arm-none-linux-eabi: For Linux, using glibc instance 1, ARM-NONE-EABI-GCC

(Arm architecture,no Vendor,not target an operating system,complies with the arm EABI)
Bare-metal systems for compiling the ARM architecture (including boot, kernel for ARM Linux, not for compiled Linux applications application), generally suitable for ARM7, cortex-m, and cortex-r cores, so it is not supported by those operating systems A closely related function, such as fork (2), uses newlib, a C library dedicated to embedded systems. 2, ARM-NONE-LINUX-GNUEABI-GCC

(ARM architecture, no vendor, creates binaries that run on the Linux operating system, and uses the GNU EABI)

Mainly used in the ARM architecture based Linux system, can be used to compile the arm architecture of U-boot, Linux kernel, Linux applications and so on. Arm-none-linux-gnueabi is based on GCC and uses the GLIBC library, which has been optimized by Codesourcery company to launch the compiler. The Arm-none-linux-gnueabi-xxx cross-compilation tool has excellent floating-point operations. General ARM9, ARM11, cortex-a kernel, with Linux operating system will be used. 3, ARM-EABI-GCC

Android ARM compiler. 4, ARMCC

ARM's compiled tools, like Arm-none-eabi, can compile bare-metal programs (u-boot, kernel), but not Linux applications. ARMCC general and ARM development tools, Keil MDK, ADS, RVDS and DS-5 compilers are ARMCC, so ARMCC compiler are charged (except Patriotic edition, hehe ~ ~). 5, ARM-NONE-UCLINUXEABI-GCC and ARM-NONE-SYMBIANELF-GCC

Arm-none-uclinuxeabi for Uclinux, using GLIBC.

Arm-none-symbianelf used for Symbian, and did not know what the C library was. Codesourcery

Codesourcery launched the product called Sourcery g++ Lite Edition, which is based on the command-line of the compiler is free, can be downloaded on the official website, and the IDE and debug tools included in it is chargeable, of course there are 30 days trial version.

Currently Codesourcery has been acquired by Mentor Graphics, so the original website style has all changed to Mentor style, but Sourcery g++ Lite Edition can also be registered for free download.

Codesourcery has been working on the development and optimization of the arm target GCC, and its arm gcc is currently very good in the market, many patches may not have been accepted by GCC, so it should still be used directly (and he provided under Windows [MinGW Cross-compiled] And Linux under the binary version, more convenient, if not very time and interest, do not recommend the download SRC source package to compile their own, very troublesome, codesourcery to the shell script many times there is no way to directly use, you have to extract the key part of the manual execution, but also the cost of energy and time, If you want to know the details, you don't have to compile it yourself to see what steps he is building, if you're interested in cross-compiler. ABI and EABI

ABI: Binary Application Interface (application binary Interface (ABI) for the ARM Architecture). In computers, applying a binary interface describes a low-level interface between an application (or other type) and an operating system or another application.

EABI: Embedded ABI. Embedded application binary interfaces specify standard conventions for file formats, data types, register usage, stacked organization optimizations, and parameters in an embedded software. Developers using their own assembly language can also use EABI as an interface to the assembly language generated by the compatible compiler.

The main difference between the two is that the ABI is on the computer, Eabi is embedded on the platform (such as arm,mips, etc.). ARM-LINUX-GNUEABI-GCC and ARM-LINUX-GNUEABIHF-GCC

The two cross compilers are suitable for Armel and ARMHF two different architectures, and Armel and ARMHF have different strategies for floating-point operations (with the FPU arm to support both floating-point arithmetic strategies).

In fact, these two cross compilers are only GCC's option-mfloat-abi the default values are different. GCC options-mfloat-abi have three values soft, SOFTFP, hard (both of which require the FPU floating point unit in arm, soft and the latter are compatible, but SOFTFP and hard two modes are incompatible):
Soft: Use the software mode instead of the FPU for floating point calculations, even if the FPU floating point unit is not used.
The default value of the Softfp:armel architecture (corresponding compiler for ARM-LINUX-GNUEABI-GCC) is calculated using the FPU, but the parameters are transmitted by ordinary registers, so when the interrupt is done, only the ordinary registers are saved, the interrupt load is small, But the parameters need to be converted to floating-point recalculation.
The default value of the HARD:ARMHF architecture (corresponding compiler ARM-LINUX-GNUEABIHF-GCC) is calculated using the FPU, and the parameters are also transmitted using the floating-point registers in the FPU, eliminating the need for conversions with the best performance, but with high interrupt loads.

Save the contents of the C file used in the following test to MFLOAT.C:
#include <stdio.h>
int main (void)
{
Double a,b,c;
A = 23.543;
b = 323.234;
c = b/a;
printf ("The 13/2 =%f\n", c);
printf ("Hello World!\n");
return 0;
}

1. Compile with ARM-LINUX-GNUEABIHF-GCC and use the "-V" option for more detailed information:
# arm-linux-gnueabihf-gcc-v Mfloat.c
collect_gcc_options= '-V '-march=armv7-a '-mfloat-abi=hard '-mfpu=vfpv3-d16′ '-mthumb '
-mfloat-abi=hard

You can see that hard hardware floating point mode is used.

2. Compile with ARM-LINUX-GNUEABI-GCC:
# arm-linux-gnueabi-gcc-v Mfloat.c
collect_gcc_options= '-V '-march=armv7-a '-mfloat-abi=softfp '-mfpu=vfpv3-d16′ '-mthumb '
-mfloat-abi=softfp

You can see the use of SOFTFP mode.

Reference Cross compiler differences between Arm-linux-gnueabi and ARM-LINUX-GNUEABIHF: http://www.cnblogs.com/xiaotlili/p/3306100.html The difference between Arm-none-linux-gnueabi,arm-none-eabi and Arm-eabi: http://blog.csdn.net/mantis_1984/article/details/21049273 What ' s the difference between arm-linux-/arm-none-linux-gnueabi-/arm-fsl-linux-gnueabi-in ltib?https:// community.freescale.com/thread/313490

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.