官术网_书友最值得收藏!

Compiling the compiler

Binary distributions of the GCC toolchain are available to download for a number of specific targets and host machines. To compile the code for the ARM Cortex-M microprocessors, the arm-none-eabi toolchain is made available for most GNU/Linux distributions. However, in some cases, it might be handy to build the toolchain entirely from the sources. This might be, for example, when the compiler for a certain target does not exist yet or is not shipped in binary format for our favorite development environment. This process is also useful to better understand the various components that are required to build the tools.

Crosstool-NG is an open source project, which consists of a set of scripts aimed to automate the process of creating a toolchain. The tool retrieves the selected version of each and every component, then creates an archive of the toolchain that can be redistributed in binary form. This is normally not necessary, while sometimes useful when it is necessary to modify the sources for a specific component, such as, for example, the C libraries that are finally integrated in the toolchain. It is easy to create a new configuration in crosstool-NG, thanks to its configurator, based on the Linux kernel menuconfig. After installing crosstool-NG, the configurator can be invoked by using:

$ ct-ng menuconfig

Once the configuration has been created, the build process can be started. Since the operation requires retrieving all the components, patching them, and building the toolchain, it may take several minutes, depending on the speed of the host machine and the internet connection, to retrieve all the components. The build process can be started by issuing:

$ ct-ng build

Predefined configurations are available for compiling commonly used toolchains, mostly for targets running Linux. When compiling a toolchain for a Linux target, there are a few C libraries to choose from. In our case, since we want a bare-metal toolchain, newlib is the default choice. Several other libraries provide an implementation of a subset of the C standard library, such as uClibc and musl. The newlib library is a small cross-platform C library mostly designed for embedded systems with no operating system on board, and it is provided as the default in many GCC distributions, including the arm-none-eabi cross-compiler distributed by ARM.

主站蜘蛛池模板: 霍山县| 卓尼县| 宁陕县| 连南| 信宜市| 平阳县| 锦州市| 凤庆县| 旺苍县| 吴桥县| 辉县市| 宝清县| 峨眉山市| 法库县| 武平县| 民权县| 蕉岭县| 弥勒县| 祁东县| 桐梓县| 历史| 阿鲁科尔沁旗| 色达县| 皮山县| 长泰县| 龙口市| 衡东县| 鹰潭市| 延寿县| 文水县| 酒泉市| 武定县| 彰武县| 改则县| 合江县| 祁门县| 黔西| 天全县| 永修县| 惠州市| 安国市|