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

下面开始:

首先从http://releases.llvm.org/download.html#4.0.1这边下载最新的版本。如果从SVN下载代码的话,已经是5.0的开发版本了。如果需要使用稳定版本,推荐自己下载4.0.1的代码包,需要下载4个文件:

LLVM source code

Clang source code

Clang Tools Extra source code

Compiler RT source code

下载好了以后,四个压缩包都解压出来,得到四个目录:

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-all target (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, use make -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的更多相关文章

  1. centos下编译安装lnmp

    centos下编译安装lnmp 本文以centos为背景在其中编译安装nginx搭建lnmp环境. 编译安装nginx时,需要事先安装 开发包组"Development Tools" ...

  2. CentOS 7 编译安装 Code::Blocks

    CentOS 7 编译安装 Code::Blocks yum install cairo-devel yum install pango-devel yum install atk-devel yum ...

  3. centos mysql 编译安装

    centos mysql 编译安装 1.安装 创建MySQL用户 sudo useradd mysql 下载MySQL的源码包,我们这里使用的时5.5.18 安装依赖 sudo yum -y inst ...

  4. 转:在CentOS下编译安装GCC

    转:https://teddysun.com/432.html 在CentOS下编译安装GCC 技术  秋水逸冰  发布于: 2015-09-02  更新于: 2015-09-02  6519 次围观 ...

  5. CentOS 下编译安装Apache

    CentOS 下编译安装Apache 卸载原有的apache 首先从 http://httpd.apache.or 下载apache源码包httpd-2.4.4.tar.gz然后从 http://ap ...

  6. Centos 7 编译安装llvm 8.0.0

    参考连接:https://www.cnblogs.com/BinBinStory/p/7499527.html https://blog.csdn.net/llwy1428/article/detai ...

  7. CentOS 6.5 安装Clang 3.5.0

    来自引用: http://www.cnblogs.com/dudu/p/4294374.html 编译llvm几乎耗费了1个小时-.. 编译CoreCLR需要Clang 3.5,而CentOS上安装的 ...

  8. centos系统编译安装nginx+php环境另加独立mysql教程

    以前看过的安装nginx+php环境都带了mysql数据库了,这个是因为很多站长都是nginx+php+mysql都在同一台服务器了,那么今天我们是单独处理了,一个是nginx+php环境,然后mys ...

  9. 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. 卸载旧 ...

随机推荐

  1. 对MVVM的理解

    MVVM是Model-view-ViewMoudel的缩写 Model代表数据类型,也可以在Model中定义数据修改和操作的业务逻辑: View代表UI组件,负责将数据模型转化为UI展现出来: Vie ...

  2. js 实现页面点击按钮复制内容

    前言: 我们平时在页面中是按照长按来实现复制相关的内容,那么怎么用js实现点击按钮实现复制相关的内容呢?请看如下方法: 实现步骤: 1.引入相关的js(ClipboardJS插件) <scrip ...

  3. npkill 一个方便的npm 包清理工具

    npm 包很好用,但是占用空间太多了,npkill 提供了一个方便的工具,可以帮助我们查找安装的npm 包,以及进行清理 安装 npm install -g npkill 简单使用 命令 npkill ...

  4. Harbor高可用

    项目需求: 实现Harbor的HTTPS高可用,由于Harbor 服务器配置不高,直接做HTTPS对上传下载镜像时,若docker客户端多时,会非常慢,为了提高harbor的效率,采用以下方式来解决. ...

  5. K8s的存储卷使用总结

    K8s的存储卷: 它有四种存储卷: 1. emptyDir: 空目录,这种存储卷会随着Pod的删除而被清空,它一般作为缓存目录使用,或临时目录, 当做缓存目录时,通常会将一块内存空间映射到该目录上,让 ...

  6. AttributeError: module ‘select’ has no attribute 'epoll’

    场景:mac 下导入的 ‘select’ 包 import select,然后在 主函数 中创建的 epoll 对象 epl = select.epoll(),运行报错如下 Traceback (mo ...

  7. SpringCloud-Feign声明式服务调用

    在前面的文章中可以发现当我们通过RestTemplate调用其它服务的API时,所需要的参数须在请求的URL中进行拼接,如果参数少的话或许我们还可以忍受,一旦有多个参数的话,这时拼接请求字符串就会效率 ...

  8. [Beta阶段]测试报告

    [Beta阶段]测试报告 博客目录 测试方法及过程 在正式发布前,为检验后端各接口功能的正确性,后端服务器对压力的耐受程度,以及前端各页面.功能的运行情况,我们对我们的服务器及小程序进行了多种测试.除 ...

  9. Video标签动态修改src地址播放问题

    不管在React或Vue中,将一个变量赋值给src属性,当修改这个变量的值时,video播放的还是原来的视频. Vue中 <video id="root"> <s ...

  10. Transform the vot dataset into 4 corner format

    Transform the vot dataset into 4 corner format Matlab code to change the 8 value ground truth into 4 ...