[Photo] Kunpeng 916-ARM64 architecture source code gcc compilation complete record

[Photo] Kunpeng 916-ARM64 architecture source code gcc compilation complete record


Reference: Kunpeng Software Stack Official Document


1. Preparation stage

  • View system architecture
[root@pc-deeplearning-1 ~]# hostnamectl 
   Static hostname: pc-deeplearning-1
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 65a539173aca43bca524c9829d298907
           Boot ID: 0c07a5693c01472ba997bd83cb43f05b
    Virtualization: kvm
  Operating System: CentOS Linux 7 (AltArch)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 4.14.0-115.el7a.0.1.aarch64
      Architecture: arm64
[root@pc-deeplearning-1 ~]# 
  • View system version
[root@pc-deeplearning-1 ~]# cat /etc/redhat-release 
CentOS Linux release 7.6.1810 (AltArch) 
[root@pc-deeplearning-1 ~]#
  • View the number of virtual machine cpu cores
[root@pc-deeplearning-1 lib64]# lscpu
Architecture:          aarch64
Byte Order:            Little Endian
CPU(s):                32
On-line CPU(s) list:   0-31
Thread(s) per core:    1
Core(s) per socket:    16
Socket(s):             2
NUMA node(s):          1
Model:                 2
BogoMIPS:              100.00
NUMA node0 CPU(s):     0-31
Flags:                 fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
[root@pc-deeplearning-1 lib64]#
  • View virtual machine memory capacity
[root@pc-deeplearning-1 lib64]# free -h
              total        used        free      shared  buff/cache   available
Mem:            31G        659M         12G        668M         19G         24G
Swap:            0B          0B          0B
[root@pc-deeplearning-1 lib64]#

2. Install cmake

2.1 Check whether cmake is installed
rpm -qa |grep cmake

If it is not installed, you need to install it.

2.2 Install cmake
[root@pc-deeplearning-1 src]# yum repolist
[root@pc-deeplearning-1 src]# yum provides cmake
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.huaweicloud.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.huaweicloud.com
cmake-2.8.12.2-2.el7.aarch64 : Cross-platform make system
Repo        : base



[root@pc-deeplearning-1 src]# 
[root@pc-deeplearning-1 src]# yum -y install cmake
Complete!
[root@pc-deeplearning-1 src]#
2.3 View cmake version
[root@pc-deeplearning-1 src]# cmake -version
cmake version 2.8.12.2
[root@pc-deeplearning-1 src]# 

3. Install dependency packages

3.1 Install the following dependencies
yum -y install bison* ncurses*
yum -y install bzip2 wget
3.2 Check whether the dependent installation package is installed successfully
[root@pc-deeplearning-1 src]# rpm -qa | grep bison*
libisofs-1.2.8-4.el7.aarch64
bison-3.0.4-2.el7.aarch64
[root@pc-deeplearning-1 src]# 
[root@pc-deeplearning-1 src]# rpm -qa | grep ncurses*
ncurses-libs-5.9-14.20130511.el7_4.aarch64
ncurses-base-5.9-14.20130511.el7_4.noarch
ncurses-5.9-14.20130511.el7_4.aarch64
[root@pc-deeplearning-1 src]# 
[root@pc-deeplearning-1 src]# rpm -qa | grep bzip2
bzip2-1.0.6-13.el7.aarch64
bzip2-libs-1.0.6-13.el7.aarch64
[root@pc-deeplearning-1 src]# 
[root@pc-deeplearning-1 src]# rpm -qa | grep wget
wget-1.14-18.el7.aarch64
[root@pc-deeplearning-1 src]#

4. gcc download, compile and install

4.1 Check the version of gcc
[root@pc-deeplearning-1 src]# gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@pc-deeplearning-1 src]# 

The version is too low, need to download an updated version

4.2 download gcc7.3
[root@pc-deeplearning-1 software]# wget https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz

2020-11-15 17:49:07 (440 KB/s) - ‘gcc-7.3.0.tar.gz’ saved [112201917/112201917]

[root@pc-deeplearning-1 software]#
4.3 Unzip the gcc7.3 installation package
[root@pc-deeplearning-1 software]# tar -zxf gcc-7.3.0.tar.gz
[root@pc-deeplearning-1 software]#
4.4 In the "gcc-7.3.0" directory, check whether the gcc dependency package has been downloaded and installed
[root@pc-deeplearning-1 software]# cd gcc-7.3.0/
[root@pc-deeplearning-1 gcc-7.3.0]# ./contrib/download_prerequisites 

gmp-6.1.0.tar.bz2: OK
mpfr-3.1.4.tar.bz2: OK
mpc-1.0.3.tar.gz: OK
isl-0.16.1.tar.bz2: OK
All prerequisites downloaded successfully.
[root@pc-deeplearning-1 gcc-7.3.0]# 

You can see that isl, gmp, mpc, mpfr have been downloaded

4.5 Compile gcc.

The "-j" parameter can use multi-core CPU to speed up the compilation speed. In this operation, a 32-core CPU is used, so here is "-j32".

(Note: First, it was operated in accordance with the official documentation of Kunpeng Software Stack, make -j16, and then the speed was very slow; after listening to the guidance of the great god, Ctrl-C interrupted and then made -j32, the speed was very fast)

4.5.1 The number of CPU cores can be queried through the following commands:
[root@pc-deeplearning-1 gcc-7.3.0]# cat /proc/cpuinfo| grep "processor"| wc -l
32
[root@pc-deeplearning-1 gcc-7.3.0]#
4.5.2 View the current directory
[root@pc-deeplearning-1 gcc-7.3.0]# pwd
/opt/software/gcc-7.3.0
[root@pc-deeplearning-1 gcc-7.3.0]#
4.5.3 Create gcc compilation directory
[root@pc-deeplearning-1 gcc-7.3.0]# mkdir gcc-build-7.3.0
[root@pc-deeplearning-1 gcc-7.3.0]# cd gcc-build-7.3.0
[root@pc-deeplearning-1 gcc-build-7.3.0]# pwd
/opt/software/gcc-7.3.0/gcc-build-7.3.0
[root@pc-deeplearning-1 gcc-build-7.3.0]# 
[root@pc-deeplearning-1 gcc-build-7.3.0]# ../configure --enable-checking=release --enable-language=c,c++ --disable-multilib --prefix=/usr
4.5.4 Because of 32vcpu, use make -j32 to compile and run
[root@pc-deeplearning-1 gcc-build-7.3.0]# make -j32
4.5.5 Perform installation
[root@pc-deeplearning-1 gcc-build-7.3.0]# make install
4.5.6 Make sure that "libstdc++.so" is in the "/usr/lib64" directory
[root@pc-deeplearning-1 gcc-build-7.3.0]# cd /usr/lib64

Query the location of "libstdc++.so"

[root@pc-deeplearning-1 lib64]# ll |grep libstdc++.so
lrwxrwxrwx.  1 root root       19 Nov 15 19:48 libstdc++.so -> libstdc++.so.6.0.24
lrwxrwxrwx.  1 root root       19 Nov 15 19:48 libstdc++.so.6 -> libstdc++.so.6.0.24
-rwxr-xr-x.  1 root root  1057320 Oct 30  2018 libstdc++.so.6.0.19
-rwxr-xr-x.  1 root root 11844176 Nov 15 19:48 libstdc++.so.6.0.24
-rw-r--r--.  1 root root     2385 Nov 15 19:48 libstdc++.so.6.0.24-gdb.py
lrwxrwxrwx.  1 root root       19 Mar 20  2020 libstdc++.so.6.old -> libstdc++.so.6.0.19
[root@pc-deeplearning-1 lib64]# 

Make sure the soft connection exists

[root@pc-deeplearning-1 lib64]# ll |grep libstdc++.so.6.0.24
lrwxrwxrwx.  1 root root       19 Nov 15 19:48 libstdc++.so -> libstdc++.so.6.0.24
lrwxrwxrwx.  1 root root       19 Nov 15 19:48 libstdc++.so.6 -> libstdc++.so.6.0.24
-rwxr-xr-x.  1 root root 11844176 Nov 15 19:48 libstdc++.so.6.0.24
-rw-r--r--.  1 root root     2385 Nov 15 19:48 libstdc++.so.6.0.24-gdb.py
[root@pc-deeplearning-1 lib64]#

5. Check the gcc version

[root@pc-deeplearning-1 lib64]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/aarch64-unknown-linux-gnu/7.3.0/lto-wrapper
Target: aarch64-unknown-linux-gnu
Configured with: ../configure --enable-checking=release --enable-language=c,c++ --disable-multilib --prefix=/usr
Thread model: posix
gcc version 7.3.0 (GCC) 
[root@pc-deeplearning-1 lib64]#

This concludes this article!

Contact information:

WeChat public account:
Insert picture description here
WeChat:
Insert picture description here

If you think this article is helpful to you, please click like and then go!
More exciting, stay tuned!
Welcome to follow this blogger!

Guess you like

Origin blog.csdn.net/frdevolcqzyxynjds/article/details/109710860