【图文】鲲鹏916-ARM64架构源码gcc编译完整记录

嘟嘟鱼啊鱼
发布于 2022-8-15 19:44
浏览
0收藏

参考:鲲鹏软件栈官方文档

https://www.huaweicloud.com/kunpeng/software/mysql0.html

1、准备阶段
 ● 查看系统架构

[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 ~]#

 ● 查看系统版本

 [root@pc-deeplearning-1 ~]# cat /etc/redhat-release 
 CentOS Linux release 7.6.1810 (AltArch) 
 [root@pc-deeplearning-1 ~]#

 ● 查看虚拟机cpu核数

[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]#

 ● 查看虚拟机内存容量

[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、安装cmake
2.1检查cmake是否安装

 rpm -qa |grep cmake

如果未安装,需要安装。

 

2.2安装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查看cmake版本

 [root@pc-deeplearning-1 src]# cmake -version
 cmake version 2.8.12.2
 [root@pc-deeplearning-1 src]#

3、安装依赖包
3.1安装以下依赖包

 yum -y install bison* ncurses*
yum -y install bzip2 wget

3.2检查依赖安装包是否安装成功

[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下载、编译安装

4.1检查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]#

版本太低,需要下载更新版本

4.2下载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解压gcc7.3安装包

[root@pc-deeplearning-1 software]# tar -zxf gcc-7.3.0.tar.gz
[root@pc-deeplearning-1 software]#

4.4在“gcc-7.3.0”目录下,检查gcc的依赖包是否已下载和安装

[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]#

可以看到已经下载完isl、gmp、mpc、mpfr

 

4.5编译gcc。
“-j”参数可利用多核CPU加快编译速度,在本操作中,使用的是32核CPU,所以此处为“-j32”。

(注意:一上来是按照鲲鹏软件栈官方文档操作,make -j16,然后速度很慢;听大神指点,Ctrl-C中断后又make -j32,速度很快)

4.5.1可通过下述命令查询CPU核数:

[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查看当前所在目录

[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创建gcc编译目录

[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 因为32vcpu,所以用make -j32去编译去跑

[root@pc-deeplearning-1 gcc-build-7.3.0]# make -j32

4.5.5执行安装

[root@pc-deeplearning-1 gcc-build-7.3.0]# make install

4.5.6确定“libstdc++.so”是在“/usr/lib64”目录下

[root@pc-deeplearning-1 gcc-build-7.3.0]# cd /usr/lib64

查询“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]#

确定软连接存在

[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、查看gcc版本

 [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]#

 

 

 

文章转载自公众号:码哥字节

已于2022-8-15 19:44:19修改
收藏
回复
举报
回复
    相关推荐