在Linux CentOS上編譯並安裝Clang 3.5.0

來源:互聯網
上載者:User

標籤:

編譯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.repoyum 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 bemissing in libstdc++4.6 and implemented in libstdc++4.7. There are numerousC++11 problems with 4.6‘s library, and we don‘t support GCCs or libstdc++ olderthan 4.7.

二、安裝Python 2.7.9

CentOS 6.6內建的是Python 2.6.6,而編譯llvm需要Python 2.7以上。

1)安裝編譯Python需要的包包

yum install zlib-develyum install bzip2-develyum install openssl-develyum install ncurses-develyum install sqlite-devel

2)下載並解壓Python 2.7.9的原始碼

cd /optwget --no-check-certificate https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tar.xztar xf Python-2.7.9.tar.xzcd Python-2.7.9

3)編譯與安裝Python 2.7.9

./configure --prefix=/usr/localmake && 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.xzmv llvm-3.5.0.src llvm

2)下載clang的原始碼

cd llvm/toolswget http://llvm.org/releases/3.5.0/cfe-3.5.0.src.tar.xztar xf cfe-3.5.0.src.tar.xzmv cfe-3.5.0.src clang

3)下載compiler-rt的原始碼

cd ../projectswget http://llvm.org/releases/3.5.0/compiler-rt-3.5.0.src.tar.xztar xf compiler-rt-3.5.0.src.tar.xzmv 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 --versionclang version 3.5.0 (tags/RELEASE_350/final)

如果還是舊版本,需要將/usr/bin/clang指向clang 3.5.0:

ls -s /usr/local/bin/clang /usr/bin/clang

【相關連結】

如何在CentOS上安裝libstdc++4.7

在Linux CentOS 6.6上安裝Python 2.7.9 

在Linux CentOS上編譯並安裝Clang 3.5.0

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.