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. Due to the architectural differences between Kunpeng and x86, the Go compilation systems also vary. During porting, you need to install different compiler suites for the architectures. If the codebase contains Go assembly code, adaptation is required.
The following describes how to port the Go compilation system to the Kunpeng platform. Download the latest AArch64 Golang that has a better support for AArch64. Versions 1.13 and later are recommended.
Download address: https://go.dev/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
