源码安装gperftools工具
下载gperftools源码
https://github.com/gperftools/gperftools/releases/download/gperftools-2.16/gperftools-2.16.tar.gz
注:需要下载github上release版本,如果直接下载master分支上源码,将可能出现各种编译报错
Linux Centos
[root@localhost gperftools-2.16]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
[root@localhost gperftools-2.16]#
[root@localhost gb]# pwd
/home/gb
[root@localhost gb]# mkdir build
[root@localhost gb]# tar -zxvf gperftools-2.16.tar.gz
[root@localhost gb]# ls -tlr
-rw-rw-r--. 1 gb gb 912590 May 17 17:03 libunwind-1.7.2.tar.gz
-rw-rw-r--. 1 gb gb 2405927 May 17 17:03 gperftools-2.16.tar.gz
drwxrwxr-x. 2 gb gb 6 May 17 17:04 build
drwxr-xr-x. 9 gb gb 4096 May 17 17:05 gperftools-2.16
[root@localhost gb]# cd gperftools-2.16/
[root@localhost gperftools-2.16]# ./configure --prefix=/home/gb/build
[root@localhost gperftools-2.16]# make
[root@localhost gperftools-2.16]# make install
[root@localhost gperftools-2.16]# cd ../
[root@localhost gb]# ls -tlr
-rw-rw-r--. 1 gb gb 912590 May 17 17:03 libunwind-1.7.2.tar.gz
-rw-rw-r--. 1 gb gb 2405927 May 17 17:03 gperftools-2.16.tar.gz
drwxr-xr-x. 10 gb gb 4096 May 17 17:32 gperftools-2.16
drwxrwxr-x. 6 gb gb 56 May 17 17:32 build
[root@localhost gb]# cd build/
[root@localhost build]# ls -tlr
total 4
drwxr-xr-x. 2 root root 42 May 17 17:32 bin
drwxr-xr-x. 4 root root 28 May 17 17:32 share
drwxr-xr-x. 3 root root 24 May 17 17:32 include
drwxr-xr-x. 3 root root 4096 May 17 17:32 lib
[root@localhost build]# cd lib
[root@localhost lib]# pwd
/home/gb/build/lib
[root@localhost lib]# ls -tlr
total 92476
-rwxr-xr-x. 1 root root 3046360 May 17 17:32 libtcmalloc_minimal.so.4.5.18
lrwxrwxrwx. 1 root root 29 May 17 17:32 libtcmalloc_minimal.so.4 -> libtcmalloc_minimal.so.4.5.18
lrwxrwxrwx. 1 root root 29 May 17 17:32 libtcmalloc_minimal.so -> libtcmalloc_minimal.so.4.5.18
-rwxr-xr-x. 1 root root 1076 May 17 17:32 libtcmalloc_minimal.la
-rwxr-xr-x. 1 root root 3446608 May 17 17:32 libtcmalloc_minimal_debug.so.4.5.18
lrwxrwxrwx. 1 root root 35 May 17 17:32 libtcmalloc_minimal_debug.so.4 -> libtcmalloc_minimal_debug.so.4.5.18
lrwxrwxrwx. 1 root root 35 May 17 17:32 libtcmalloc_minimal_debug.so -> libtcmalloc_minimal_debug.so.4.5.18
-rwxr-xr-x. 1 root root 1118 May 17 17:32 libtcmalloc_minimal_debug.la
-rwxr-xr-x. 1 root root 5536656 May 17 17:32 libtcmalloc.so.4.5.18
lrwxrwxrwx. 1 root root 21 May 17 17:32 libtcmalloc.so.4 -> libtcmalloc.so.4.5.18
lrwxrwxrwx. 1 root root 21 May 17 17:32 libtcmalloc.so -> libtcmalloc.so.4.5.18
-rwxr-xr-x. 1 root root 1020 May 17 17:32 libtcmalloc.la
-rwxr-xr-x. 1 root root 5899392 May 17 17:32 libtcmalloc_debug.so.4.5.18
lrwxrwxrwx. 1 root root 27 May 17 17:32 libtcmalloc_debug.so.4 -> libtcmalloc_debug.so.4.5.18
lrwxrwxrwx. 1 root root 27 May 17 17:32 libtcmalloc_debug.so -> libtcmalloc_debug.so.4.5.18
-rwxr-xr-x. 1 root root 1062 May 17 17:32 libtcmalloc_debug.la
-rwxr-xr-x. 1 root root 1041968 May 17 17:32 libprofiler.so.0.5.13
lrwxrwxrwx. 1 root root 21 May 17 17:32 libprofiler.so.0 -> libprofiler.so.0.5.13
lrwxrwxrwx. 1 root root 21 May 17 17:32 libprofiler.so -> libprofiler.so.0.5.13
-rwxr-xr-x. 1 root root 1020 May 17 17:32 libprofiler.la
-rwxr-xr-x. 1 root root 5939400 May 17 17:32 libtcmalloc_and_profiler.so.4.6.13
lrwxrwxrwx. 1 root root 34 May 17 17:32 libtcmalloc_and_profiler.so.4 -> libtcmalloc_and_profiler.so.4.6.13
lrwxrwxrwx. 1 root root 34 May 17 17:32 libtcmalloc_and_profiler.so -> libtcmalloc_and_profiler.so.4.6.13
-rwxr-xr-x. 1 root root 1112 May 17 17:32 libtcmalloc_and_profiler.la
-rw-r--r--. 1 root root 8753752 May 17 17:32 libtcmalloc_minimal.a
-rw-r--r--. 1 root root 9812458 May 17 17:32 libtcmalloc_minimal_debug.a
-rw-r--r--. 1 root root 15397860 May 17 17:32 libtcmalloc.a
-rw-r--r--. 1 root root 16341578 May 17 17:32 libtcmalloc_debug.a
-rw-r--r--. 1 root root 2796524 May 17 17:32 libprofiler.a
-rw-r--r--. 1 root root 16630346 May 17 17:32 libtcmalloc_and_profiler.a
drwxr-xr-x. 2 root root 144 May 17 17:32 pkgconfig
[root@localhost lib]#
Linux ARM64
[root@localhost gperftools-2.16]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
[root@localhost gperftools-2.16]#
[root@localhost gb]# pwd
/home/gb
[root@localhost gb]# mkdir build
[root@localhost gb]# tar -zxvf gperftools-2.16.tar.gz
[root@localhost gb]# ls -tlr
-rw-rw-r--. 1 gb gb 912590 May 17 17:03 libunwind-1.7.2.tar.gz
-rw-rw-r--. 1 gb gb 2405927 May 17 17:03 gperftools-2.16.tar.gz
drwxrwxr-x. 2 gb gb 6 May 17 17:04 build
drwxr-xr-x. 9 gb gb 4096 May 17 17:05 gperftools-2.16
[root@localhost gb]# cd gperftools-2.16/
#设置交叉工具链安装的目录
[root@localhost gb]# export PATH=$PATH:/opt/chain_tool/gcc_arm_10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin
[root@localhost gperftools-2.16]# ./configure --host=aarch64-none-linux-gnu --prefix=/home/gb/build
[root@localhost gperftools-2.16]# make
[root@localhost gperftools-2.16]# make install
[root@localhost gperftools-2.16]# cd ../
[root@localhost gb]# ls -tlr
-rw-rw-r--. 1 gb gb 912590 May 17 17:03 libunwind-1.7.2.tar.gz
-rw-rw-r--. 1 gb gb 2405927 May 17 17:03 gperftools-2.16.tar.gz
drwxr-xr-x. 10 gb gb 4096 May 17 17:32 gperftools-2.16
drwxrwxr-x. 6 gb gb 56 May 17 17:32 build
[root@localhost gb]# cd build/
[root@localhost build]# ls -tlr
total 4
drwxr-xr-x. 2 root root 42 May 17 17:32 bin
drwxr-xr-x. 4 root root 28 May 17 17:32 share
drwxr-xr-x. 3 root root 24 May 17 17:32 include
drwxr-xr-x. 3 root root 4096 May 17 17:32 lib
[root@localhost build]# cd lib
[root@localhost lib]# pwd
/home/gb/build/lib
[root@localhost lib]# ls -tlr
total 92476
-rwxr-xr-x. 1 root root 3046360 May 17 17:32 libtcmalloc_minimal.so.4.5.18
lrwxrwxrwx. 1 root root 29 May 17 17:32 libtcmalloc_minimal.so.4 -> libtcmalloc_minimal.so.4.5.18
lrwxrwxrwx. 1 root root 29 May 17 17:32 libtcmalloc_minimal.so -> libtcmalloc_minimal.so.4.5.18
-rwxr-xr-x. 1 root root 1076 May 17 17:32 libtcmalloc_minimal.la
-rwxr-xr-x. 1 root root 3446608 May 17 17:32 libtcmalloc_minimal_debug.so.4.5.18
lrwxrwxrwx. 1 root root 35 May 17 17:32 libtcmalloc_minimal_debug.so.4 -> libtcmalloc_minimal_debug.so.4.5.18
lrwxrwxrwx. 1 root root 35 May 17 17:32 libtcmalloc_minimal_debug.so -> libtcmalloc_minimal_debug.so.4.5.18
-rwxr-xr-x. 1 root root 1118 May 17 17:32 libtcmalloc_minimal_debug.la
-rwxr-xr-x. 1 root root 5536656 May 17 17:32 libtcmalloc.so.4.5.18
lrwxrwxrwx. 1 root root 21 May 17 17:32 libtcmalloc.so.4 -> libtcmalloc.so.4.5.18
lrwxrwxrwx. 1 root root 21 May 17 17:32 libtcmalloc.so -> libtcmalloc.so.4.5.18
-rwxr-xr-x. 1 root root 1020 May 17 17:32 libtcmalloc.la
-rwxr-xr-x. 1 root root 5899392 May 17 17:32 libtcmalloc_debug.so.4.5.18
lrwxrwxrwx. 1 root root 27 May 17 17:32 libtcmalloc_debug.so.4 -> libtcmalloc_debug.so.4.5.18
lrwxrwxrwx. 1 root root 27 May 17 17:32 libtcmalloc_debug.so -> libtcmalloc_debug.so.4.5.18
-rwxr-xr-x. 1 root root 1062 May 17 17:32 libtcmalloc_debug.la
-rwxr-xr-x. 1 root root 1041968 May 17 17:32 libprofiler.so.0.5.13
lrwxrwxrwx. 1 root root 21 May 17 17:32 libprofiler.so.0 -> libprofiler.so.0.5.13
lrwxrwxrwx. 1 root root 21 May 17 17:32 libprofiler.so -> libprofiler.so.0.5.13
-rwxr-xr-x. 1 root root 1020 May 17 17:32 libprofiler.la
-rwxr-xr-x. 1 root root 5939400 May 17 17:32 libtcmalloc_and_profiler.so.4.6.13
lrwxrwxrwx. 1 root root 34 May 17 17:32 libtcmalloc_and_profiler.so.4 -> libtcmalloc_and_profiler.so.4.6.13
lrwxrwxrwx. 1 root root 34 May 17 17:32 libtcmalloc_and_profiler.so -> libtcmalloc_and_profiler.so.4.6.13
-rwxr-xr-x. 1 root root 1112 May 17 17:32 libtcmalloc_and_profiler.la
-rw-r--r--. 1 root root 8753752 May 17 17:32 libtcmalloc_minimal.a
-rw-r--r--. 1 root root 9812458 May 17 17:32 libtcmalloc_minimal_debug.a
-rw-r--r--. 1 root root 15397860 May 17 17:32 libtcmalloc.a
-rw-r--r--. 1 root root 16341578 May 17 17:32 libtcmalloc_debug.a
-rw-r--r--. 1 root root 2796524 May 17 17:32 libprofiler.a
-rw-r--r--. 1 root root 16630346 May 17 17:32 libtcmalloc_and_profiler.a
drwxr-xr-x. 2 root root 144 May 17 17:32 pkgconfig
参考文献
gperftools源码下载直址
Linux代码性能分析工具
C++ 性能分析的实战指南(gperftools工具)
性能测试工具gperftools使用
使用gperftools对程序进行性能分析
交叉编译 gperftools 及使用
Gperftools交叉编译
gperftools 编译教程