Build latest llvm/clang/lldb

env: CentOS 7

latest version is: 6.01

the steps was recorded as below:

1.download src packge The LLVM Compiler Infrastructure Project

2. download & install latest cmake

bash-4.2$ cd CMake-3.12.0
bash-4.2# ./bootstrap && make && make install
-- Installing: /usr/local/bin/cmake
-- Installing: /usr/local/bin/ctest
-- Installing: /usr/local/bin/cpack


bash-4.2$ sudo yum install zlib

3. build llvm

bash-4.2$ mkdir build
bash-4.2$ cd build

bash-4.2# cmake  ../llvm-6.0.1.src
-- Build files have been written to: /home/alex/Downloads/build

bash-4.2# cmake --build .
bash-4.2# cmake --build . --target install

-- Installing: /usr/local/bin/llvm-config
-- Installing: /usr/local/bin/llvm-lto
-- Installing: /usr/local/bin/llvm-profdata
-- Installing: /usr/local/bin/bugpoint
-- Installing: /usr/local/lib/BugpointPasses.so
-- Installing: /usr/local/bin/llvm-dsymutil
-- Installing: /usr/local/bin/llc

4.build clang

bash-4.2$ mkdir clangbuild
bash-4.2$ cd clangbuild
bash-4.2# cmake ../cfe-6.0.1.src/
bash-4.2# cmake --build .

bash-4.2# cmake --build . --target install
-- Installing: /usr/local/lib/cmake/clang/ClangTargets-noconfig.cmake
-- Installing: /usr/local/lib/cmake/clang/ClangConfig.cmake

bash-4.2# clang
clang-6.0: error: no input files
bash-4.2# 

5. build lldb

bash-4.2$ sudo yum install libedit-devel libxml2-devel ncurses-devel python-devel swig

bash-4.2$ mkdir lldb
bash-4.2$ cd lldb
bash-4.2$ 
bash-4.2$ cmake ../lldb-6.0.1.src/
bash-4.2$ cmake --build .
bash-4.2# cmake --build . --target install
CMake Error at scripts/cmake_install.cmake:41 (file):
  file INSTALL cannot find "/home/alex/Downloads/lldb/lib/python2.7".

bash-4.2# ls lib64
python2.7
bash-4.2# 
bash-4.2# cp  lib64/python2.7/  lib/ -R
bash-4.2# cmake --build . --target install

better way:

put the clang/lldb source code under llvm/tools, then the cmake once .

Clang – Getting Started

Building LLDB

5.fix the lldb python interface issue

bash-4.2$ lldb
(lldb) script
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named lldb.embedded_interpreter
Traceback (most recent call last):
  File "<string>", line 1, in <module> 



bash-4.2$ ls /usr/local/lib/python2.7/site-packages/ -l
total 48
drwxr-xr-x. 5 root root  4096 7月  29 16:31 lldb
-rwxr-xr-x. 1 root root  8840 7月  29 14:56 readline.so
-rw-r--r--. 1 root root 30130 7月  29 16:15 six.py
bash-4.2$ su 
Password: 
bash-4.2# mv /usr/local/lib/python2.7/site-packages/* /usr/lib/python2.7/site-packages/ 



bash-4.2# lldb
(lldb) script
Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
>>> 2+2
4
>>> 

    原文作者:Alex Xu
    原文地址: https://zhuanlan.zhihu.com/p/40793869
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞