LLVM-4.0.1 linux配置安装(64位Ubuntu16)

本文为转载,原博客地址:https://blog.csdn.net/fan2273/article/details/76439042


还是那个最近在弄的Surround360,它的硬件控制部分,需要使用Halide这个开源的图像处理语言,而这个语言又依赖了LLVM,要求版本在3.7以上。

通常来说,这其实就是个嵌套配置的问题,一般各个官网或者git里面都有安装配置的手册。

比如,Halide里面的安装手册就包含了如何配置LLVM的指令。

Acquiring LLVM

Building halide requires at least llvm 3.7, along with the matching version of clang. llvm-config and clang must be somewhere in the path. If your OS does not have packages for llvm-3.7, you can find binaries for it at http://llvm.org/releases/download.html. Download an appropriate package and then either install it, or at least put the bin subdirectory in your path. (This works well on OS X and Ubuntu.)

If you want to build it yourself, first check it out from subversion:

% svn co https://llvm.org/svn/llvm-project/llvm/branches/release_37 llvm3.7
% svn co https://llvm.org/svn/llvm-project/cfe/branches/release_37 llvm3.7/tools/clang

Then build it like so:

% cd llvm3.7
% mkdir build
% cd build
% cmake -DLLVM_ENABLE_TERMINFO=OFF -DLLVM_TARGETS_TO_BUILD="X86;ARM;NVPTX;AArch64;Mips;PowerPC" -DLLVM_ENABLE_ASSERTIONS=ON -DCMAKE_BUILD_TYPE=Release ..
% make -j8

then to point Halide to it:

export LLVM_CONFIG=<path to llvm>/build/bin/llvm-config
export CLANG=<path to llvm>/build/bin/clang
总的来说,就是告诉你官网可以下载install,或者你也可以自己编译安装。

但是,实际上我去官网找最近的发布版的时候,只有源码包。但最大的问题是,官网的页面,咋一看之下并没有给出安装手册和说明之类的东西。

抱着百度大学和CSDN的希望,我也找了LLVM linux的关键词看看,并自己尝试了一下,但发现走不通。

这里给出一个老版本的配置教程:http://blog.csdn.net/wangyulinyy/article/details/39211115

这个教程的步骤主要在 ./configure 上有问题,执行的时候会看见终端报“LLVM已不再支持configure,请使用cmake编译”

这个时候,又回到了Halide给出的LLVM配置手册,因为这里的安装时基于cmake编译的。但细心的同学可以看到,可能由于维护或者不太重要的原因,cmake后面跟的配置命令,targetbuild是x86,而我的Ubuntu是64位。

其实可以尝试执行以下,反正我的报错了。

这里,给出LLVM官网的编译安装步骤

这个步骤藏的比较深,但认真搜寻官网也可以找得到。

http://releases.llvm.org/4.0.1/docs/CMake.html

这里我也不多说了,直接贴出官方的手册:

但是,首先请注意,请确定自己的clang装在了llvm/tools文件夹下

(如果不理解,请按照上面Halide给出的步骤,执行至cmake命令时,再使用LLVM官网给出的步骤)

请注意,第四步中path/to/llvm/source/root指的是/LLVM源码根目录,这个目录下有CMakeList和configure文件

编译时间比较长,静等……

We use here the command-line, non-interactive CMake interface.

  1. Download and install CMake. Version 3.4.3 is the minimum required.

  2. Open a shell. Your development tools must be reachable from this shell through the PATH environment variable.

  3. Create a build directory. Building LLVM in the source directory is not supported. cd to this directory:

    $ mkdir mybuilddir
    $ cd mybuilddir
    
  4. Execute this command in the shell replacing path/to/llvm/source/root with the path to the root of your LLVM source tree:

    $ cmake path/to/llvm/source/root
    

    CMake will detect your development environment, perform a series of tests, and generate the files required for building LLVM. CMake will use default values for all build parameters. See the Options and variables section for a list of build parameters that you can modify.

    This can fail if CMake can’t detect your toolset, or if it thinks that the environment is not sane enough. In this case, make sure that the toolset that you intend to use is the only one reachable from the shell, and that the shell itself is the correct one for your development environment. CMake will refuse to build MinGW makefiles if you have a POSIX shell reachable through the PATH environment variable, for instance. You can force CMake to use a given build tool; for instructions, see the Usage section, below.

  5. After CMake has finished running, proceed to use IDE project files, or start the build from the build directory:

    $ cmake --build .
    

    The --build option tells cmake to invoke the underlying build tool (makeninjaxcodebuildmsbuild, etc.)

    The underlying build tool can be invoked directly, of course, but the --build option is portable.

  6. After LLVM has finished building, install it from the build directory:

    $ cmake --build . --target install
    

    The --target option with install parameter in addition to the --build option tells cmake to build the install target.

    It is possible to set a different install prefix at installation time by invoking the cmake_install.cmake script generated in the build directory:

    $ cmake -DCMAKE_INSTALL_PREFIX=/tmp/llvm -P cmake_install.cmake


注意:

LLVM对系统缓存和交换分区SWAP要求较高。我已多次在42% 60%遇到了

internal compiler error: Killed

的报错(进程假死,被直接kill掉了)。

推荐大家不要在虚拟机上尝试,或者尽量分配较多的SWAP和内存。(本人内存分配4G,SWAP调整到2G,仍然卡死)

阅读更多
个人分类: 软件安装方法集锦
上一篇拍人更美!谷歌工程师揭秘Pixel 2手机黑科技
下一篇msvcp100d.dll丢失的有效解决方法
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭