CentOS 7 编译安装clang+llvm
天在CentOS上将最新版本的LLVM套件(LLVM,Clang和Libc++)编译安装好了,中间遇到了不少问题。虽然已经有很多博客介绍如何编译安装LLVM了,但是根据我自己亲身体验的情况来看,还是有地方需要注意的,也有东西值得跟大家分享一下。

下面开始:
首先从http://releases.llvm.org/download.html#4.0.1这边下载最新的版本。如果从SVN下载代码的话,已经是5.0的开发版本了。如果需要使用稳定版本,推荐自己下载4.0.1的代码包,需要下载4个文件:
下载好了以后,四个压缩包都解压出来,得到四个目录:
llvm-4.0.1.src
cfe-4.0.1.src
clang-tools-extra-4.0.1.src
compiler-rt-4.0.1.src
然后按下面的步骤组织:
mv cfe-4.0.1.src clang
mv clang/ llvm-4.0.1.src/tools/ mv clang-tools-extra-4.0.1.src extra
mv extra/ llvm-4.0.1.src/tools/clang/ mv compiler-rt-4.0.1.src compiler-rt
mv compiler-rt llvm-4.0.1.src/projects/
这样以后clang,clang-tools-extra和compiler-rt就可以和llvm一起编译了。
在llvm-4.0.1.src同一层目录上新建个目录build-4.0.1并进入:
mkdir build-4.0.
cd build-4.0.
然后Configure and build LLVM and Clang:
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr/local/clang -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=On ../llvm-4.0..src/
-DCMAKE_INSTALL_PREFIX=directory— Specify for directory the full pathname of where you want the LLVM tools and libraries to be installed (default/usr/local).-DCMAKE_BUILD_TYPE=type— Valid options for type are Debug, Release, RelWithDebInfo, and MinSizeRel. Default is Debug.-DLLVM_ENABLE_ASSERTIONS=On— Compile with assertion checks enabled (default is Yes for Debug builds, No for all other build types).
注意 : 这后两个选项推荐大家加上 ,否则会产生巨大的文件,我第一次编译的时候,没有加上这两个选项,编译出来的结果多大 9.4G (够吓人的吧?把我的磁盘都耗尽了,还报错,google了好久才发现是磁盘空间不够) ,耗时超过一个半小时。
然后make:
make -j 4
- The default target (i.e.
make) will build all of LLVM - The
check-alltarget (i.e.make check-all) will run the regression tests to ensure everything is in working order. - CMake will generate build targets for each tool and library, and most LLVM sub-projects generate their own
check-<project>target. - Running a serial build will be slow. Make sure you run a parallel build; for
make, usemake -j.
尽量把几个核都用上,加快编译速度。
然后make install:
sudo make install
最后,因为是按照自己指定的路径安装,所以需要添加环境变量。
echo "export PATH=$PATH:/usr/local/clang/bin" >> /etc/bashrc
. /etc/bashrc


安装过程主要参考这几篇文章:
http://clang.llvm.org/get_started.html
http://llvm.org/docs/GettingStarted.html#checkout
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
http://www.tuicool.com/articles/ZBveeu
CentOS 7 编译安装clang+llvm的更多相关文章
- centos下编译安装lnmp
centos下编译安装lnmp 本文以centos为背景在其中编译安装nginx搭建lnmp环境. 编译安装nginx时,需要事先安装 开发包组"Development Tools" ...
- CentOS 7 编译安装 Code::Blocks
CentOS 7 编译安装 Code::Blocks yum install cairo-devel yum install pango-devel yum install atk-devel yum ...
- centos mysql 编译安装
centos mysql 编译安装 1.安装 创建MySQL用户 sudo useradd mysql 下载MySQL的源码包,我们这里使用的时5.5.18 安装依赖 sudo yum -y inst ...
- 转:在CentOS下编译安装GCC
转:https://teddysun.com/432.html 在CentOS下编译安装GCC 技术 秋水逸冰 发布于: 2015-09-02 更新于: 2015-09-02 6519 次围观 ...
- CentOS 下编译安装Apache
CentOS 下编译安装Apache 卸载原有的apache 首先从 http://httpd.apache.or 下载apache源码包httpd-2.4.4.tar.gz然后从 http://ap ...
- Centos 7 编译安装llvm 8.0.0
参考连接:https://www.cnblogs.com/BinBinStory/p/7499527.html https://blog.csdn.net/llwy1428/article/detai ...
- CentOS 6.5 安装Clang 3.5.0
来自引用: http://www.cnblogs.com/dudu/p/4294374.html 编译llvm几乎耗费了1个小时-.. 编译CoreCLR需要Clang 3.5,而CentOS上安装的 ...
- centos系统编译安装nginx+php环境另加独立mysql教程
以前看过的安装nginx+php环境都带了mysql数据库了,这个是因为很多站长都是nginx+php+mysql都在同一台服务器了,那么今天我们是单独处理了,一个是nginx+php环境,然后mys ...
- centos手动编译安装apache、php、mysql
64位centos 5.5手动安装lamp,要求curl.json.pdo_mysql.gd,记录如下. centos 5.4.5.5.5.6的内核都是2.6.18,都可以安装php 5.3. 卸载旧 ...
随机推荐
- v-for给img的src动态赋值问题
做一个轮播图,给img赋值src <el-carousel-item v-for="(item, index) in carouselImgs" :key="ind ...
- [Algorithm] 171. Excel Sheet Column Number
Given a column title as appear in an Excel sheet, return its corresponding column number. For exampl ...
- ent facebook 开源的golang orm 框架
ent 是facebook 开源的golang orm 框架,简单强大,具有提下特性 schema 即代码 方便的图遍历 静态类型以及显示api 多种存储引擎支持(当前是mysql,sqlite,以及 ...
- csp 201903-3 损坏的RAID5
问题描述 试题编号: 201903-3 试题名称: 损坏的RAID5 时间限制: 1.0s 内存限制: 512.0MB 问题描述: 答题栏 核
- mvc基础配置
视图解析器 在spring-mvc文件中编写 <!--配置视图解析器--> <bean class="org.springframework.web.servlet.vie ...
- minimap2 长reads比对工具
minimap2 github 官网 https://github.com/lh3/minimap2 安装 git clone https://github.com/lh3/minimap2 cd m ...
- IDEA 调试图文教程,让 bug 无处藏身!
阅读本文大概需要 6.2 分钟. 来源:http://t.cn/EoPN7J2 Debug用来追踪代码的运行流程,通常在程序运行过程中出现异常,启用Debug模式可以分析定位异常发生的位置,以及在运行 ...
- 【译文】走出Java ClassLoader迷宫 Find a way out of the ClassLoader maze
本文是一篇译文.原文:Find a way out of the ClassLoader maze 对于类加载器,普通Java应用开发人员不需要了解太多.但对于系统开发人员,正确理解Java的类加载器 ...
- Spring Cloud 学习--Hystrix应用
上一篇介绍了Hystrix基本功能和单独使用的方式,今天继续学习如何将Hystrix融入SpringCloud组件中去. 在Ribbon上使用熔断器 在 pom.xml 文件中引入 hystrix 的 ...
- python windows下安装pip及rarfile
python之所以被广泛使用,倒不见得是本身语法简单,而是而nodejs/javascript一样把三方库的依赖管理简化了,而不用和java一样非得通过maven管理,而且还得打包后在classpat ...