编译CoreCLR需要Clang 3.5,而CentOS上安装的是Clang 3.4.2(yum repos中最新版也是这个),只能自己手工编译LLVM的源代码进行安装。
(注:CentOS的版本是6.6)
一、安装libstdc++4.7
wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo yum install devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++ ln -s /opt/rh/devtoolset-2/root/usr/bin/* /usr/local/bin/
如果不安装,在configure配置编译选项时会出现下面的错误提示:
We detected a missing feature in the standard C++ library that was known to be missing in libstdc++4.6 and implemented in libstdc++4.7. There are numerous C++11 problems with 4.6‘s library, and we don‘t support GCCs or libstdc++ older than 4.7.
二、安装Python 2.7.9
CentOS 6.6自带的是Python 2.6.6,而编译llvm需要Python 2.7以上。
1)安装编译Python需要的包包
yum install zlib-devel yum install bzip2-devel yum install openssl-devel yum install ncurses-devel yum install sqlite-devel
2)下载并解压Python 2.7.9的源代码
cd /opt wget --no-check-certificate https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tar.xz tar xf Python-2.7.9.tar.xz cd Python-2.7.9
3)编译与安装Python 2.7.9
./configure --prefix=/usr/local make && make altinstall
4)将python命令指向Python 2.7.9
ln -s /usr/local/bin/python2.7 /usr/local/bin/python
三、编译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 .../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
【相关链接】
在Linux CentOS 6.6上安装Python 2.7.9
时间: 2024-10-11 05:48:41