编译gcc

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的信息可以点击这里

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值