According to the latest news from Huawei's official website, the compiler tool Ark compiler has been released. According to reports, the Ark compiler is a cross-compiler suite developed by GCC. It includes front-ends for C, C++, and Fortran, as well as libraries for these languages (such as libstdc++, libgcc, etc.). HCC runs on an X86 linux architecture server and the generated binary runs on the Aarch64 architecture server.
Preparation before installation
1) Environmental requirements
The Ark compiler supports the following 64-bit operating systems.
SUSE12sp4 and above.
Ubuntu 16.04 and above.
Other glibc versions are available in Linux distributions 2.22 and above.
2) Get the package
Installing the Ark compiler requires an open source package as shown in Table 2-1.
GCC 7.3.0 编译器源码包 https://ftp.gnu.org/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz
Binutils 2.31.1 汇编器、链接器等二进制工具集源码包 https://ftp.gnu.org/gnu/binutils/binutils-2.31.1.tar.gz
Glibc 2.29 GNU libc 库源码包 https://git.linaro.org/toolchain/glibc.git/snapshot/glibc-2.29.tar.gz
Mpc 1.1.0 复数运算库 https://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz
GNU MPFR 4.0.2 多精度浮点计算库 https://www.mpfr.org/mpfr-current/mpfr-4.0.2.tar.gz
isl 0.21 集和线性约束范围内整数点关系的操作库 http://isl.gforge.inria.fr/isl-0.21.tar.gz
Install the HCC compiler
1) Operation steps
You can use the HCC tarball to install HCC anywhere under the current user privilege without affecting the use of other compilers.
a) Introduce the operation portal, for example, log in to the XX environment with the XX account.
b) Login HCC download address to download the compressed package
c) Copy the tarball to the directory you want to install.
The command script is as follows.
Cp hcc_arm64le.tar.gz /path/to/your/dir
d) Unzip the package.
The command script is as follows.
Tar zxvf hcc_arm64le.tar.gz
e) Set environment variables.
The environment variable command script is set as shown below.
The build tools provided by the HCC compiler are in the =/path/to/your/dir/hcc_arm64le/bin directory.
2) Check after installation
After the HCC compiler is installed, you can run the aarch64-linux-gnu-gcc -v command to query the HCC version.
Download source code:Download now
According to Huawei's official introduction, the Ark compiler is the first static compiler to completely replace the language virtual machine, completely without an interpreter. A compiler that takes into account Java development efficiency and C language runtime efficiency. Compared to the existing compilation mechanism:
- The Ark compiler is a static compilation method. In the existing Android system, running an application first starts the virtual machine, then reads the application code and interprets the execution one by one. It will occupy more processing resources and affect the efficiency of program execution. Of course, there are also early or runtime compilation techniques, such as AOT or JIT, that convert some of the programs into machine code and execute them directly on the CPU. However, it is still not possible to do 100% to get rid of virtual machine execution, which is the key to the current Android camp is not as good as the IOS camp.
- The static compilation mode of the Huawei Ark compiler can directly translate the dynamic features in the language into machine code. After the application is installed, the mobile phone can run the program at full speed, completely eliminating the drawbacks of the virtual machine and bringing about great improvement in efficiency.
- The Ark compiler is a compiler deployed in the development environment, and the existing compilation process mainly occurs on the mobile phone, which brings additional resource consumption.
At present, the Ark compiler is compiled and optimized for the general-purpose ARM chip architecture. In the future, the capabilities of the Kirin chip will be maximized through software and hardware co-design. At the same time, the Ark compiler supports Java standard usage, and the three-party application can be compiled directly without modifying the code. But if you want to get better performance or memory improvements, you can adjust the code structure and optimize with the Ark compiler.