当前位置:  开发笔记 > 前端 > 正文

使用cmake构建和打包LLVM clang 3.4

如何解决《使用cmake构建和打包LLVMclang3.4》经验,为你挑选了0个好方法。

cmake大约两周前开始学习并喜欢它.到目前为止,我已经成功地构建和包装(与本地系统封装格式)libc++abi,libc++,llvm3.4所有cmake(libc++abi我自己cmake设置)为RHEL 6.x中,20 +的Fedora和Ubuntu 12.04 LTS +.

我想创建一个C++构建环境

    让我们libstdc++完全依赖GNU GCC(因此我们不希望从上述发行版或LLVM Debian/Ubuntu夜间软件包下载站点获得任何LLVM RPM/DEB )

    使我们能够完全探索C++ 11和C++ 1y.换句话说,我们可以尝试,甚至我们想同时保持我们所有的编译系统干净,包管理系统最前沿LLVM /铛随时随地.

尽管如此,我试图在运行Ubuntu 12.04 LTS 64bit的构建主机上构建clang3.4 cmake,并使用由我构建的纯粹的 clang 3.3 而不依赖于GNU libstdc++,以及libc++3.3和libc++abi.后两者也没有libstdc++依赖.我也是这样建造的.

我非常了解Clang - Getting Started网页,并成功使用了那里的说明.但这些正是我不想使用的.他们是不正确太:对CMakeLists.txtclang3.4明确规定如下:

 1  # If we are not building as a part of LLVM, build Clang as an
 2  # standalone project, using LLVM as an external library:
 3  if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
 4    project(Clang)
 5    cmake_minimum_required(VERSION 2.8)
 6  
 7    set(CLANG_PATH_TO_LLVM_SOURCE "" CACHE PATH
 8      "Path to LLVM source code. Not necessary if using an installed LLVM.")
 9    set(CLANG_PATH_TO_LLVM_BUILD "" CACHE PATH
10      "Path to the directory where LLVM was built or installed.")

请参阅第1行和第2行.但是,我还没有找到任何有关如何设置的LLVM文档CLANG_PATH_TO_LLVM_BUILD.我尝试了以下方法:

cmake -DCLANG_PATH_TO_LLVM_BUILD="../../llvm-3.4/build" ..

并得到以下错误:

$ clang3.4/_tars/clang-3.4/build$ cmake -DCLANG_PATH_TO_LLVM_BUILD="../../llvm-3.4/build" ..
-- The C compiler identification is Clang 3.3.0
-- The CXX compiler identification is Clang 3.3.0
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++
-- Check for working CXX compiler: /usr/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMake Error at CMakeLists.txt:39 (include):
  include could not find load file:

    AddLLVM


CMake Error at CMakeLists.txt:40 (include):
  include could not find load file:

    TableGen


-- Performing Test C_SUPPORTS_FLAG
-- Performing Test C_SUPPORTS_FLAG - Success
-- Performing Test CXX_SUPPORTS_FLAG
-- Performing Test CXX_SUPPORTS_FLAG - Success
-- Building with -fPIC
-- Performing Test SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG
-- Performing Test SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG - Success
-- Found LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so (found version "2.7.8") 
-- Clang version: 3.4
-- Performing Test CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG
-- Performing Test CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG - Success
CMake Error at utils/TableGen/CMakeLists.txt:3 (add_tablegen):
  Unknown CMake command "add_tablegen".


-- Configuring incomplete, errors occurred!

但那不对!LLVM + compiler-rt已经使用我们自己的构建主机安装DEB.和,

$ llvm/clang3.4/_tars/clang-3.4/build$ ls /usr/share/llvm/cmake
AddLLVM.cmake             ChooseMSVCCRT.cmake      linux_issue.cmake  LLVMConfigVersion.cmake   pkg.cmake
AddLLVMDefinitions.cmake  GetSVN.cmake             LLVM-Config.cmake  LLVMParseArguments.cmake  TableGen.cmake
arch.cmake                HandleLLVMOptions.cmake  LLVMConfig.cmake   LLVMProcessSources.cmake

因此,所有必需的cmake模块都在那里 - 就在系统上!

我很感激有关如何使用已经安装的LLVM 3.4 + 3.4 强制clang构建3.4 的提示.cmakecompiler-rt

更新:

我决定做以下事情:

$ llvm/clang3.4/_tars/clang-3.4/build$ cmake -DCLANG_PATH_TO_LLVM_BUILD="/usr" ..
-- Building with -fPIC
-- Clang version: 3.4
-- Found Subversion: /usr/bin/svn (found version "1.6.17") 
-- Configuring done
-- Generating done
-- Build files have been written to: ../llvm/clang3.4/_tars/clang-3.4/build
../llvm/clang3.4/_tars/clang-3.4/build$ make -j 2
Scanning dependencies of target ClangDriverOptions
Scanning dependencies of target clang-tblgen
[  0%] Building Options.inc...
[  0%] ../llvm/clang3.4/_tars/clang-3.4/include/clang/Driver/Options.td:15:9: error: Could not find include file 'llvm/Option/OptParser.td'
include "llvm/Option/OptParser.td"
        ^
.../llvm/clang3.4/_tars/clang-3.4/include/clang/Driver/Options.td:15:9: Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangASTNodesEmitter.cpp.o
error: Unexpected input at top level
include "llvm/Option/OptParser.td"
        ^
make[2]: *** [include/clang/Driver/Options.inc.tmp] Error 1
make[1]: *** [include/clang/Driver/CMakeFiles/ClangDriverOptions.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[  0%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangAttrEmitter.cpp.o
[  0%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangCommentCommandInfoEmitter.cpp.o
[  0%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangCommentHTMLTagsEmitter.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangDiagnosticsEmitter.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangSACheckersEmitter.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/NeonEmitter.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/TableGen.cpp.o
Linking CXX executable ../llvm/clang3.4/_tars/llvm-3.4/build/bin/clang-tblgen
[  1%] Built target clang-tblgen
make: *** [all] Error 2

那更好.看起来clang3.4的默认值CMakeLists.txt甚至不是QA-ed x-(Yikes x-(

推荐阅读
有风吹过best
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有