Compile and install clang 3.5.0 on Linux CentOS for Redhat and Clang3.8__linux

Source: Internet
Author: User
Tags install openssl

Compiling CORECLR requires clang 3.5, and CentOS is installed Clang 3.4.2 (the most new version of Yum repos), can only manually compile the LLVM source code to install.

(Note: The CentOS version is 6.6)

I. Installation of libstdc++4.7

(Note: If it is CentOS 7.0, this step is not required)

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/

If you do not install, the following error prompts appear when configure configures the compilation options:

We detected a missing feature in the standard C + + library that is known to is
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
4.7.

Second, install Python 2.7.9

(Note: If it is CentOS 7.0, this step is not required)

CentOS 6.6 is a Python 2.6.6, and compiling LLVM requires more than 2.7 python.

1 Install the package you need to compile the python

Yum install zlib-devel
yum install bzip2-devel yum install openssl-devel yum install ncurses-devel yum
Install Sqlite-devel

2 download and extract the Python 2.7.9 source code

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 Compiling and installing the Python 2.7.9

./configure--prefix=/usr/local make
&& make Altinstall

4 point python command to Python 2.7.9

Ln-s/usr/local/bin/python2.7/usr/local/bin/python

Third, add swap partition

If the compiled machine memory is relatively small, it is recommended that you add a swap partition. I was testing the machine only 1G memory, in the compilation process, "C + +: Internal compiler error:killed (program Cc1plus)" error.

1 Create and activate the swap file (for example, 2G):

DD If=/dev/zero of=/swapfile bs=1k count=2048000
mkswap/swapfile
swapon/swapfile

2) Modify the/etc/fstab file to allow the Exchange file to start automatically loaded, add the following content:

/swapfile               swap    defaults        0 0

Iv. compiling LLVM

1) Download the source code of LLVM

HTTP://LLVM.ORG/RELEASES/3.5.0/LLVM-3.5.0.SRC.TAR.XZ
MV Llvm-3.5.0.src LLVM

2) Download the source code of 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) Download the source code of 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) Configure compilation options

Cd.. /.. /
mkdir Build
CD Build
.. /llvm/configure--enable-optimized CC=GCC cxx=g++

5) Compiling LLVM

Make-j2

Prompt for success after compilation:

LLVM[0]: * * * Completed release+asserts Build

6 The installation of a good LLVM

Make install

will be installed in the/usr/local/bing.

7) Check the clang version

# clang--version
clang version 3.5.0 (tags/release_350/final)

If it's an older version, you need to point the/usr/bin/clang to clang 3.5.0:

Ls-s/usr/local/bin/clang/usr/bin/clang
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.