Porting the Go Compilation System
The Go language is a compiled language. Figure 1 shows the process from the source code to an executable file. The Go program is compiled into a binary file. The file is loaded by the OS to the memory and executed by the CPU. The process is similar to that in C/ C++. The difference is that the Go program has its unique compiler, assembler, and linker. The architecture of the Kunpeng server is different from that of the x86 server. As a result, the Go compilation system of the Kunpeng server is also different from that of the x86 server. During porting, you need to install different compiler suites for the architectures. If the code contains the Go assembly, adaptation modification is required.
The following describes how to port the Go compilation system to the Kunpeng platform. Download the latest AArch64 Golang, which has a better support for AArch64. The recommended version is 1.13 or later.
Download address: https://go.dev/dl/
Download address in China: https://studygolang.com/dl
Decompress the downloaded binary package to the installation directory, for example, /usr/local. Generally, you need to set three environment variables: GOROOT (the software package location in the system), GOPATH (the working directory, which needs to be set based on the actual code directory), and PATH (the bin directory of Go). Set environment variables in the .profile or /etc/profile file as follows:
echo "export GOROOT=/usr/local/go" >> ~/.profile echo "export PATH=$GOPATH/bin:$GOROOT/bin:$PATH" >> ~/.profile source ~/.profile
