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. 卸载旧 ...
随机推荐
- JSON Web Token (JWT) - Introduction
To validate the challenge, connect as admin.------------以admin登陆 https://jwt.io/introduction/ ...
- matlab 只安装部分产品
- sourceforge文件下载过慢
sourceforge文件下载过慢,可以用下面网址镜像下载, http://sourceforge.mirrorservice.org 按搜索到的项目的英文字母依次查询,如http://sourcef ...
- Sequelize 数据类型
Sequelize.STRING // VARCHAR(255)Sequelize.STRING(1234) // VARCHAR(1234)Sequelize.STRING.BINARY // VA ...
- Excel填坑[0]
Excel填坑[0] 本着一天水一贴的原则(放p),我又来填坑了.今天做一个很简单的排队图,虽然不难,但因为手机显示问题折腾了半天.感觉做图做表格不仅仅是靠技术,更重要的是思维. 就是这张图,看起来平 ...
- 【转】Spring Boot @Condition 注解,组合条件你知道吗
原文:https://www.cnblogs.com/FraserYu/p/11280420.html 上一篇文章 你应该知道的 @ConfigurationProperties 注解的使用姿势,这一 ...
- rtsp 客户端请求视频的时候支持输入用户名和密码的格式
rtsp://[<username>[:<password>]@]<server-address-or-name>[:<port>][/<path ...
- SpringCloud Gateway跨域配置
Springboot版本:2.1.8.RELEASE SpringCloud版本:Greenwich.SR2 yml配置: spring: cloud: gateway: globalcors: co ...
- Oracle系列十三 视图
视图 :从表中抽出的逻辑上相关的数据集合. 视图是一种虚表. 视图建立在已有表的基础上, 视图赖以建立的这些表称为基表. 向视图提供数据内容的语句为 SELECT 语句, 可以将视图理解为存储起来的 ...
- (转)Ngx_Lua使用分享
原文:https://www.cnblogs.com/yanzi-meng/p/9450999.html ngx_lua 模块详细讲解(基于openresty)---https://www.cnblo ...