Llvm+clang Compiling and installing

Source: Internet
Author: User
Tags svn

Recently in the Llvm+clang to do something, so by the way, how to compile and install Llvm+clang wrote an article sent here, hoping to help just contact Llvm+clang children's shoes less go some detours (I just touch the time in order to compile and install this cost a great effort, All is tears here not much to say). First of all, I used the Ubuntu Kylin 16.10 operating system (not a virtual machine, I compiled on the virtual machine installed many times to fail). The process is as follows: 1. Download code Source

First install SVN to check out the source of the LLVM code

Aptitude Install Subversion

Then checkout LLVM code Source: 1.2 Check out LLVM

Checkout is the main code of the LLVM project

CD where-you-want-llvm-to-live

SVN co http://llvm.org/svn/llvm-project/llvm/trunk LLVM 1.3 Check out Clang

Clang is the LLVM Project C, C + +, Objective C and Objective C + + frontend

CD Llvm/tools

SVN Co http://llvm.org/svn/llvm-project/cfe/trunk clang

Cd.. /..

1.4 Check out extra Clang tools: (optional)

Extra contains some additional tools developed using the pretext provided by clang, and we can develop our own tools on the basis of these tools.

CD Llvm/tools/clang/tools

SVN Co http://llvm.org/svn/llvm-project/clang-tools-extra/trunk extra

Cd.. /.. /.. /.. 1.5 Check out Compiler-rt

Compiler-rt primarily provides runtime library support for Clang and LLVM

CD llvm/projects

SVN Co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt

Cd.. /.. 1.6 Check out Test Suite Source Code (optional)

CD where-you-want-llvm-to-live

CD llvm/projects

SVN co http://llvm.org/svn/llvm-project/test-suite/trunk test-suit 2. Compile and install

LLVM supports CMake and Autotools for compilation. Different ways of compiling a custom pass are different, for example, if you compile with cmake, you do not need to create a makefile file when you write the pass, but you need to create a CMakeList.txt file.
Before compiling, you need to see the requirements for the system:
Http://llvm.org/docs/GettingStarted.html#requirements 2.1 Mounting CMake

The CMake version installed directly with the directive is too low, so you need to install the cmake yourself.
Download the CMake code source from http://www.cmake.org/download/, unzip it in the installation. (I installed my own cmake3.6)

./bootstrap

Make

Make install 2.2 compile installation

LLVM in order to prevent the compilation of intermediate results distributed in the code source directory, affecting the structure of the code source. Therefore, in-directory compilation is not supported. Additional compilation directories need to be created outside the code source directory.

mkdir Build

CD Build

Cmake-g "Unix makefiles". /llvm

Make

Make install

At make, you can choose the MAKE-JN command to compile in parallel and speed up the compilation. n indicates the number of processors you have.

In addition, it should be emphasized that the previous version of Llvm+clang 3.6 is compiled using./configure, which can only be compiled with the CMake after the 3.6 version.

---restore content ends---

---restore content ends---

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.