LLVM,Clang
在使用xcode时常常会遇到这2个概念,今天总结一下。
wiki中关于llvm的描述:
LLVM提供了完整編譯系統的中間層,它會將中間語言(IF, Intermediate form)從編譯器取出與最佳化,最佳化後的IF接著被轉換及鏈結到目標平台的汇编语言。LLVM可以接受來自GCC工具鏈所編譯的IF,包含它底下現存的編譯器。
请参考以下链接,http://www.weiphone.com/apple/blog/2009-09-27/The_heart_of_Snow_Leopard_LLVM_and_Clang_206356.shtml
Clang 和 LLVM 的更多资料,请参看官方文档,http://llvm.org http://clang.llvm.org
以下是clang tools的简要介绍
DESCRIPTION
clang is a C, C++, and Objective-C compiler which encompasses preprocessing, parsing, optimization, code
generation, assembly, and linking. Depending on which high-level mode setting is passed, Clang will stop
before doing a full link. While Clang is highly integrated, it is important to understand the stages of
compilation, to understand how to invoke it. These stages are:
Driver
The clang executable is actually a small driver which controls the overall execution of other tools
such as the compiler, assembler and linker. Typically you do not need to interact with the driver, but
you transparently use it to run the other tools.
Preprocessing
This stage handles tokenization of the input source file, macro expansion, #include expansion and
handling of other preprocessor directives. The output of this stage is typically called a ".i" (for
C), ".ii" (for C++), ".mi" (for Objective-C) , or ".mii" (for Objective-C++) file.
Parsing and Semantic Analysis
This stage parses the input file, translating preprocessor tokens into a parse tree. Once in the form
of a parser tree, it applies semantic analysis to compute types for expressions as well and determine
whether the code is well formed. This stage is responsible for generating most of the compiler warnings
as well as parse errors. The output of this stage is an "Abstract Syntax Tree" (AST).
Code Generation and Optimization
This stage translates an AST into low-level intermediate code (known as "LLVM IR") and ultimately to
machine code. This phase is responsible for optimizing the generated code and handling target-specific
code generation. The output of this stage is typically called a ".s" file or "assembly" file.
Clang also supports the use of an integrated assembler, in which the code generator produces object
files directly. This avoids the overhead of generating the ".s" file and of calling the target
assembler.
Assembler
This stage runs the target assembler to translate the output of the compiler into a target object file.
The output of this stage is typically called a ".o" file or "object" file.
Linker
This stage runs the target linker to merge multiple object files into an executable or dynamic library.
The output of this stage is typically called an "a.out", ".dylib" or ".so" file.
The Clang compiler supports a large number of options to control each of these stages. In addition to
compilation of code, Clang also supports other tools:
Clang Static Analyzer
The Clang Static Analyzer is a tool that scans source code to try to find bugs through code analysis. This
tool uses many parts of Clang and is built into the same driver.
LLVM,Clang的更多相关文章
- LLVM每日谈21 一些编译器和LLVM/Clang代码
作者:闪亮宁(snsn1984) 一些自己的收藏LLVM/Clang代码,而他自己写一些一点点LLVM/Clang译器的代码.在这里把这些代码库分享出来,欢迎大家交流探讨. 1.crange http ...
- llvm+clang编译安装
最近一段时间在llvm+clang上做一些东西,所以顺便将自己如何编译安装llvm+clang写了篇文章发在这里,希望能帮助刚接触llvm+clang的童鞋少走一些弯路(我刚接触的时候为了编译安装这个 ...
- Sublime Text3 & MinGW & LLVM CLang 安装配置C-C++编译环境
Sublime Text是一款强大的跨平台代码编辑器,小巧而且丰富实用的功能是Visual Studio不能比拟的,但是编译运行是一个软肋,本文通过在sublime中配置g++编译器实现程序的编译功能 ...
- Objective-C中的self与LLVM Clang新引入的instancetype
我们知道,大部分面向对象语言对于一个类的成员方法都有一个隐含的参数.在C++.Java.C#和JavaScript中是this,而在Objective-C中则是self.当然,由于Objective- ...
- Linux c++ vim环境搭建系列(2)——Ubuntu18.04.4编译安装llvm clang
2. 源码编译安装llvm clang 参考网址: https://llvhttps
- 编译llvm+clang
第一步,下载llvm代码: git clone git@github.com:llvm-mirror/llvm.git 第二步,进入llvm/tools目录并下载clang代码 cd llvm/too ...
- Windows 7 X64平台编译LLVM+clang
1 源码包 去LLVM官方网站下载最新的源码,Windows平台下载三个即可(2019.04.24版本为LLVM 8.0.0): LLVM source code (.sig) Clang sourc ...
- LLVM/Clang编译相关研究
https://blog.csdn.net/guojin08/article/details/54310858 https://juejin.im/entry/5c64da44518825620b45 ...
- 在Linux下使用LLVM Clang以及Blocks
可以从这个链接下载:http://llvm.org/releases/download.html sudo apt-get install llvm sudo apt-get install clan ...
随机推荐
- chrom_input_click
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- mysql-分页查询方案
一.直接使用limit最简单查询方法: , 在中小数据量的情况下,这样的SQL足够用了,唯一需要注意的问题就是确保使用了索引. 随着数据量的增加,页数会越来越多,查看后几页的SQL就可能类似: , 言 ...
- shell expr的用法
root@tcx4440-03:~# var=$var+1root@tcx4440-03:~# echo $var3+1 要想达到预期结果,用下列三种方法: (1)let "var+=1&q ...
- 【CodeForces 626C】Block Towers
题意 给你n,m,如果 n个2的倍数和m个3的倍数,这n+m个数各不相同,那么求最大的数的最小值. 分析 方法1:枚举最大值为i,直到 i/2+i/3-i/6(不重复的2或3的倍数)≥n+m,并且要i ...
- yield实例
如下 # __author__ = liukun # coding:utf-8 def it(): print ('hello') yield 1 yield 1 a= it() print(&quo ...
- BIEE 配置邮箱服务器
找个免费邮件服务器126或者163的 登录em地址,点击“部署”——>“邮件”——>“锁定并编辑”——>应用——>激活更改——>重新启动以应用最近更改——>重新启动 ...
- spring获取ApplicationContext对象的方法——ApplicationContextAware
一. 引言 工作之余,在看一下当年学的spring时,感觉我们以前都是通过get~ set~方法去取spring的Ioc取bean,今天就想能不能换种模型呢?因为我们在整合s2sh时,也许有那么一天就 ...
- BZOJ1083 繁忙的都市
Description 城市C是一个非常繁忙的大都市,城市中的道路十分的拥挤,于是市长决定对其中的道路进行改造.城市C的道路是这样分布的:城市中有n个交叉路口,有些交叉路口之间有道路相连,两个交叉路口 ...
- poj2774 后缀数组 求最长公共子串
Reference:IOI2009论文 http://www.cnblogs.com/ziyi--caolu/p/3192731.html #include "stdio.h" # ...
- ASP.NET MVC 过滤器详解
http://www.fwqtg.net/asp-net-mvc-%E8%BF%87%E6%BB%A4%E5%99%A8%E8%AF%A6%E8%A7%A3.html 我经历了过滤器的苦难,我想到了还 ...