CentOS 7 64-bit environment installs LLVM and Python's llvmlite package

Source: Internet
Author: User
Tags ffi

LLVM is a very powerful compiler, the specific content of the reader's own Baidu a bit

Installation steps:

1. Installing LLVM

2. Install Python's llvmlite package

I. Installing the LLVM (version 3.5)

1. Required Documents

LLVM Source Code

Clang Source Code

Clang Tools Extra Source code

Compiler RT Source Code

Libc++ Source Code

Above these files in this link: http://llvm.org/releases/download.html#3.5

  after the download , four compressed packets are extracted, get four directories:

Llvm-3.5.src

Cfe-3.5.src

Clang-tools-extra-3.5.src

Compiler-rt-3.5.src

Libcxx-3.5.src

Then follow these steps to organize:

MV cfe-3.5. src clangmv clang/llvm-3.5. src/tools/MV clang-tools-extra-3.5. SRC extramv extra/llvm-3.5. src/tools/clang/MV compiler-rt-3.5. SRC compiler-rtmv compiler-rt llvm-3.5. src/ projects/

In this way Clang,clang-tools-extra and COMPILER-RT can be compiled together with LLVM.

Create a new directory on the LLVM-3.5.SRC same level directory build-3.5 and enter:

mkdir build-3.3CD build-3.3

Then configure:

.. /llvm-3.3. Src/configure--enable-optimized--enable-targets=host-only

Note: Here are two options recommended to add , otherwise it will produce huge files, when I first compile, did not add these two options, compiled the result of how big 9.4G (scary?) My disk is exhausted, also reported wrong, Google for a long time to find that the disk space is not enough), takemore than 1.5 hours, plus the results compiled later than the 1g,i5 four core 20 minutes more than the compilation completed.

Then make:

 make-j4

If you are using a virtual machine installed, try to put all the CPU cores on, I use the VMware virtual machine, the machine is i5, 8G of memory. Installed two times, the first time to the virtual Machine 1 core, the result Make-j4, compiled for 2.5 hours. The virtual machine was later given 4 cores, resulting in less than one hours of compilation success. So add a few cores.

Then make install:

sudo  Make Install

Now use clang++-V to see if the installation is successful:

3.5 target:x86_64-unknown-linux-gnuthread model:posix

Next, if you want to use LLVM's C + + compiler, you can refer to these articles:

Http://www.cnblogs.com/codemood/p/3142848.html

Http://www.cnblogs.com/Frandy/archive/2012/10/20/llvm_clang_libcxx_cxx11.html

Http://www.cnblogs.com/ralphjzhang/archive/2011/12/02/2272671.html

The above three articles gave me a lot of installation ideas, thanks to these authors.

Two. Install Python's Llvmlite package:

1. Installation Preparation

python2.7 version See this link: https://pypi.python.org/pypi/llvmlite/

Version of llvm3.5 installed successfully

2. Download the https://pypi.python.org/pypi/llvmlite/from the Llvmlite website and unzip it, and you will see the following files:

  

Then, in this directory, enter the command line to install the following command:

$ python setup.py Build

 If an error occurs, this error is most likely to occur:

/usr/local/lib/python2.7/dist-packages/setuptools/dist.py:291: Userwarning:the version specified ('0.3.0-12-GCC70FBA'is a invalid version, this could not be work as expected with newer versions of Setuptools, Pip, and PyPI. See PEP the  for  Moredetails. "details."%self.metadata.versionrunningInstallrunning Buildgot version from VCS {'version':'0.3.0-12-GCC70FBA',' Full':'cc70fba418d0624f87fd9b18687ca4663b41cd4f'}running Build_ext/usr/bin/python ffi/BUILD.PYLLVM Version ... Traceback (most recent call Last): File"ffi/build.py", line the,inch<module>Main () File"ffi/build.py", line104,inchMain Main_posix ('Linux','. so') File"ffi/build.py", line the,inchMain_posix"To the path for Llvm-config"%(Llvm_config,)) RUNTIMEERROR:LLVM -config failed executing, please point llvm_config to the path  for llvm- configerror:command'/usr/bin/python'Failed with exit status1

What does it mean by this mistake?

You can open the build.py this Python file under the FFI directory,

  

See the 86th line, in fact, the error is to tell us that the program can not find the llvm_config configuration path, and you are missing the Java environment variables and then to configure the Java environment variables very similar.

So how do I find the path to the llvm_config executable file?

You can use:

$Whereis llvm-config
Note: Be sure to install the llvm3.5 successfully. The result of the above command is the path to the executable file.

How does that end up solving the problem?

Take a look at the following methods:

$sudochmod u+x/etc/Environment Open  /etc/Environment this file Then add your path such as: Llvm_config="/usr/local/bin/llvm-config", this is the directory of my installation, you may be different,
$whereis llvm-config command return what you add
Add this path to the last line of the/etc/environment file and restart the machine (be sure to restart the machine)

Re-install:

$ python setup.py Build

If you still get an error, then this could be the mistake:

  

In fact, because of the lack of this-lstdc++ link caused.

So how does this work out?

Refer to this article: http://blog.csdn.net/linwhwylb/article/details/7039252/

Or you enter this command to install the relevant file:

sudo Yum Install glibc-static libstdc++-static

  Re-install:

$ python setup.py Build
No error, right? Then you enter the command below to run a routine.
$ python runtests.py

  

You should have successfully installed this time, right? Congratulations, Kujinganlai, this is the joy of success!!! ^......^

If you still have a problem at this time, you can comment on this article or contact me [email protected]

  

CentOS 7 64-bit environment installs LLVM and Python's llvmlite package

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.