Getting started with llvm in seven days (Linux Version) -- Day 1

Source: Internet
Author: User

Author: snsn1984

Opening remarks:

The process of learning llvm is a long and arduous process that requires a lot of time and effort. Not only that, but the START process is not easy. A good start is half the success. I combined my learning process and recommended the learning process to others, and sorted out this seven-day llvm zero-basic entry-level blog series. The main goal is to let people without the llvm Foundation complete some pass work through this series of learning, and to successfully learn on their own and know how to learn, know what you should learn. If you have any suggestions, please feel free to give feedback and discuss them.

Step 1: Have a preliminary impression on llvm
Here, http://llvm.org/is the official website of llvm, if English is good enough, and have enough patience, from here you can find everything you want. In addition, you can refer to my previous blog posts:
Http://blog.csdn.net/snsn1984/article/details/8036032 it tells you concisely what llvm is.

Step 2: Check what llvm is.
After we have a preliminary impression on llvm, we still don't know what llvm is, so let's take a look. From the http://llvm.org/releases/download.html#3.2 here, Select Download llvm 3.2 (3.2 is the latest version of the current release version, you can also see previous versions on this page) the llvm source codeclang source codecompiler RT source code to download the three, download and decompress, after decompression should be obtained three names are llvm-3.2.src, clang-3.2.src, compiler-rt-3.2.src. At this time, you need to rename these three folders, The llvm-3.2.src rename can be as expected, here we recommend Rename to llvm-3.2; clang-3.2.src Rename to clang, and put this folder as a whole under the llvm-3.2/tools, contains the top-level folder clang; The compiler-rt-3.2.src is renamed to compiler-RT, and the overall folder containing the top-level folder is placed under the llvm-3.2/projects. Open a terminal, switch to the llvm-3.2 directory, and enter the following command: mkdir buildcd buildcmake .. /make then you can see a lot of executable files in the llvm-3.2/build/bin directory. (If you do not use make install, you can use multiple versions of llvm on the system for research and modification .) At this time, you can run the following command to see clang :. /clang-v. /clang-help can write a simple helloworld program and use clang for compilation. The usage is the same as that of GCC :. /clang hello. c. /. out

Step 3: What is clang?
We just compiled our own llvm, but we use clang. What is clang? Let's take a look:
ClangIs an "llvm native" C/C ++/objective-C compiler, which aims to deliver amazingly fast compiles (e.g. about3x faster than GCC when compiling objective-C
Code in a debug configuration), extremely usefulerror and warning messages and to provide a platform for building great source level tools. theclang static analyzer
Is a tool that automates finds bugs in your code, and is a great example of the sort of tool that can be built using the clang frontend as a library to parse C/C ++ code.
This is an official brief introduction to clang.
You can also participate in my previous blog post: http://blog.csdn.net/snsn1984/article/details/8232943 here briefly introduces the knowledge of clang.

At this time, we should be able to skillfully use clang to compile our own program.

------------------------------------- Indicate the source for reprinting. --------------------------------------------------

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.