Cross-compiler naming rules and detailed explanation (arm/gnu/none/linux/eabi/eabihf/gcc/g++)

When engaging in embedded development under Linux systems, a cross-compiler is definitely an essential tool. When used in many situations, you will see various compilation tools, such as:

arm-linux-gcc
arm-linux-gnueabi-gcc
arm-none-linux-eabi-gcc
arm-none-symbianelf-gcc
arm-none-uclinuxeabi-gcc
arm-none-linux-gnueabi-gcc
arm-cortex_a8-linux-gnueabi-gcc
mips-malta-linux-gnu-gcc

Do you know why these compilation tools are called so, what their respective meanings are, and in what situations they are used? Let’s explain them one by one below.

General rules for naming

Generally speaking, the naming rule for cross-compilation tool chains is: arch-core-kernel-system-language. in:

arch: architecture, such as ARM, MIPS, etc., indicating which target platform the compiler is used for;
core: Which CPU Core is used, such as Cortex A8; or the supplier of the specified tool chain. If there is no special designation, leave it blank. This group of naming is relatively flexible. Among the cross-compilation chains provided by some manufacturers, some are named after the manufacturer, some are named after the development board, or they are directly none or cross;
Kernel: The OS that is running, the ones I have seen include Linux, uclinux, and bare (no OS);
system: Specifications of library functions and target images selected by the cross-compilation chain, such as gnu, gnueabi, etc. Among them, gnu is equivalent to glibc + oabi; gnueabi is equivalent to glibc + eabi. If not specified, it can also be left blank;
language: Compiled language, indicating which language the compiler is used to compile. The most common ones are gcc and g++;
Note: This rule is a guess and has not been seen in any official information. Moreover, the naming of some compilation chains does not follow this rule, and it is not clear whether this is due to historical reasons. If anyone has seen a detailed description of this rule in the documentation, please point out the error.

Example description

Here are some examples of the most common compilers in practical applications:

1. arm-linux-gcc

2. arm-none-linux-gnueabi-gcc

Let me first explain the second “arm-none-linux-gnueabi-gcc”. It expresses a compiler that does not specify a specific tool chain supplier and can be used for Linux systems based on ARM architecture. It can be used to compile ARM architecture. u-boot, Linux kernel, linux applications, etc.

arm-none-linux-gnueabi-gcc is an ARM cross-compilation tool based on GCC launched by Codesourcery (now acquired by Mentor). It can be used to cross-compile codes in all aspects of the ARM system, including bare metal programs, u-boot, Linux kernel, filesystem and App applications.

arm-none-linux-gnueabi is based on gcc and uses the Glibc library, which has excellent floating point operations. Generally, ARM9, ARM11, and Cortex-A cores can be used with Linux operating systems.

Then let’s look at the relationship between arm-linux-gcc and arm-none-linux-gnueabi-gcc.

Simply put, arm-linux-gcc is a soft link to arm-none-linux-gnueabi-gcc. as follows:

leon@Ubuntu:/opt/mini2440/toolschain/4.4.3/bin$ ls -l arm-linux-gcc
lrwxrwxrwx 1 leon leon 26 July 24 2010 arm-linux-gcc -> arm-none-linux-gnueabi-gcc

This is the arm-linux-gcc v4.4.3 compiler I installed myself.

If you want to install the compiler, according to the information I have searched so far, it seems that there is no ready-made apt-get install command that can be installed directly. You can only go to the official website (http://sourcery.mentor.com/public/gnu_toolchain/ arm-none-linux-gnueabi/) download the installation package, compile and install it yourself. The specific installation and compilation steps will not be described in detail here. You can search for them by yourself. There are many.

In addition, the website also has many compilers for other architecture platforms (misp, x86, powerpc). The download address is:
http://sourcery.mentor.com/public/gnu_toolchain/.

3. arm-linux-gnueabi-gcc

Translated, it is based on the arm architecture, suitable for any CPU model, under the Linux system, and can compile a C language compiler that complies with the GNU specifications and the ABI interface requirements of the embedded platform.

Similarly, the component in this compiler suite used to compile C++ is called arm-linux-gnueabi-g++.

Under the Ubuntu system, the compiler package can be installed directly using the following command:

sudo apt-get install gcc-arm-linux-gnueabi
sudo apt-get install g++ -arm-linux-gnueabi

4. arm-linux-gnueabihf-gcc

arm-linux-gnueabihf-gcc is an ARM cross-compilation tool launched by Linaro Company (http://www.linaro.org/) based on GCC. It can be used to cross-compile code in all aspects of the ARM system, including bare metal programs, u- boot, Linux kernel, filesystem and App applications.

arm-linux-gneabihf-gcc is similar to CodeSourcery’s arm-none-linux-gnueabi-gcc. They can be used to compile all code based on the ARM platform. CodeSourcery’s cross-compilation tool was released earlier, starting in 2005 until now. Linaro is a non-profit company jointly developed by manufacturers such as ARM, Freescale, IBM, Samsung, ST-Ericsson and TI to develop common software for system-on-a-chip (SoC) platforms of different semiconductor companies. Linaro was founded in 2010 and released the first version of ARM Cortex-A-based SoC performance optimization software tools in November of that year.

Please note to distinguish it from arm-linux-gnueabi-gcc in the second point above, these are two different compilers. They are applicable to two different architectures, armel and armhf respectively. Please see the explanation of the third point below for details.

5. arm-none-eabi-gcc

Translated, it is based on arm architecture, suitable for any CPU model (it can also be understood as not specifying a specific tool chain supplier), bare metal systems without operating systems (including ARM Linux boot and kernel, not suitable for compiling Linux Application) can compile a c language compiler that meets the ABI interface requirements of the embedded platform. It is generally suitable for chips with ARM7, Cortex-M and Cortex-R cores, so it does not support functions that are closely related to the operating system, such as fork(2). It uses newlib, a C library dedicated to embedded systems.

Note: There is a concept here called ABI/EABI, please see the explanation of point 3.

6. arm-none-uclinuxeabi-gcc and arm-none-symbianelf-gcc

arm-none-uclinuxeabi for uCLinux, using Glibc.
arm-none-symbianelf is used for symbian, I have never used it and I don’t know what the C library is.

7, armcc

The compilation tool launched by ARM has similar functions to arm-none-eabi. It can compile bare metal programs (u-boot, kernel), but cannot compile Linux applications. armcc is generally used together with ARM development tools. The compilers in Keil MDK, ADS, RVDS and DS-5 are all armcc, so the armcc compiler is charged (except for the patriotic version, haha~~).

Several concepts

1. ABI and EABI

ABI: Application Binary Interface. In computers, the application binary interface describes the low-level interface between an application (or other type) and the operating system or other applications;
EABI: Embedded ABI, a binary application program interface (Embeded Application Binary Interface) used in embedded systems. EABI specifies standard conventions for file formats, data types, register usage, stack organization optimization, and parameters in an embedded software. Developers using their own assembly language can also use EABI as an interface to assembly language generated by a compatible compiler.
The main difference between the two is that ABI is on the computer, and EABI is on the embedded platform (such as ARM, MIPS, etc.).

2. gnueabi and gnueabihf

gcc-arm-linux-gnueabi – The GNU C compiler for armel architecture
gcc-arm-linux-gnueabihf – The GNU C compiler for armhf architecture
It can be seen that these two cross-compilers are suitable for two different architectures, armel and armhf. The two architectures, armel and armhf, adopt different strategies for floating-point operations (only arm with FPU can support these two floating-point operations strategies) .

In fact, the two cross-compilers are just different in the default value of the gcc option -mfloat-abi. The gcc option -mfloat-abi has three values: soft, softfp, and hard (the latter two require an fpu floating point unit in the arm. soft is compatible with the latter two, but the softfp and hard modes are incompatible with each other. ):

soft: Does not use fpu for floating point calculations, even if there is an fpu floating point unit, but uses software mode.
softfp: The default value used by the armel architecture (the corresponding compiler is gcc-arm-linux-gnueabi). It is calculated using fpu, but the parameters are passed in ordinary registers. In this way, when an interrupt occurs, only ordinary registers need to be saved, and the interrupt load is small. But the parameters need to be converted to floating point and then calculated.
hard: The default value adopted by the armhf architecture (corresponding compiler gcc-arm-linux-gnueabihf) is calculated using fpu, and the parameters are also transferred using the floating-point register in the fpu, eliminating the need for conversion. The performance is the best, but the interrupt load high.
Finally, here are some download address links collected:

1. Mentor official website: [
https://www.mentor.com/embedded-software/sourcery-tools/sourcery-codebench/editions/lite-edition/】

2. ARM official website: [https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads]

3. Linaro official website: [https://www.linaro.org/downloads/]

4. gnu official website: [ftp://ftp.gnu.org/gnu/gcc]
—————-
Original link: https://blog.csdn.net/LEON1741/article/details/81537529

The knowledge points of the article match the official knowledge files, and you can further learn relevant knowledge. Cloud native entry-level skills treeHomepageOverview 15640 people are learning the system