yum -y install libtool gcc gcc-c++
cd gcc-10.2.0/
./contrib/download_prerequisites
mkdir build
cd build
../configure --enable-checking=release --enable-languages=c,c++ --disable-multilib --build=x86_64-redhat-linux
make -j8
make install
cp /usr/local/lib64/libstdc++.so.6.0.28 /usr/lib64/
rm -rf /usr/lib64/libstdc++.so.6
ln -s /usr/lib64/libstdc++.so.6.0.28 /usr/lib64/libstdc++.so.6
编译LLVM
1)下载llvm的源代码
http://llvm.org/releases/3.5.0/llvm-3.5.0.src.tar.xz
mv llvm-3.5.0.src llvm
2)下载clang的源代码
cd llvm/tools
wget http://llvm.org/releases/3.5.0/cfe-3.5.0.src.tar.xz
tar xf cfe-3.5.0.src.tar.xz
mv cfe-3.5.0.src clang
3)下载compiler-rt的源代码
cd ../projects
wget http://llvm.org/releases/3.5.0/compiler-rt-3.5.0.src.tar.xz
tar xf compiler-rt-3.5.0.src.tar.xz
mv compiler-rt-3.5.0.src compiler-rt
4)配置编译选项
cd ../../
mkdir build
cd build
../llvm/configure --enable-optimized CC=gcc CXX=g++
5)编译llvm
make -j2
编译成功后的提示:
llvm[0]: ***** Completed Release+Asserts Build
6)安装编译好的llvm
make install
会安装在/usr/local/bing中
7)检查clang的版本
# clang --version
clang version 3.5.0 (tags/RELEASE_350/final)
如果还是旧版本,需要将/usr/bin/clang指向clang 3.5.0:
ls -s /usr/local/bin/clang /usr/bin/clang
编译安装gdb-7.11.1
到官网http://ftp.gnu.org/gnu/gdb/直接下载最新的版本并进行编译安装:
tar -xvf gdb-7.11.1.tar.gz
cd gdb-7.11.1
./configure
make
make install
整个编译过程持续15分钟左右,当执行make install
时gdb安装出现了错误:WARNING: 'makeinfo' is missing on your sysem,则需安装相关依赖程序:
yum install texinfo libncurses5-dev
依赖安装完成后重新执行make install
就可以了,然后重新启动电脑:
init 6
重起后就可以通过gdb -v
来查看gdb版本,现在已经是7.11.1了,但是当调试程序时出现下面信息时:
warning: File "/usr/local/lib64/libstdc++.so.6.0.21-gdb.py" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
To enable execution of this file add
add-auto-load-safe-path /usr/local/lib64/libstdc++.so.6.0.21-gdb.py
line to your configuration file "/root/.gdbinit".
To completely disable this security protection add
set auto-load safe-path /
line to your configuration file "/root/.gdbinit".
将以下信息放入~/.gdbinit
就可以了:
add-auto-load-safe-path /usr/local/lib64/libstdc++.so.6.0.21-gdb.py
set auto-load safe-path /
若想通过gdb来调试STL容器,则还需要做一些配置,可以通过GDB Python pretty printers
来解决这个问题:
svn checkout svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python stlPrettyPrinter
mv stlPrettyPrinter /usr/local
然后将下面的配置信息放入~/.gdbinit
:
python
import sys
sys.path.insert(0, '/usr/local/stlPrettyPrinter')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end
更多有关GDB Python pretty printers
的信息可以点击这里。