构建谷歌 LLVM 7.0.2



如何构建LLVM 7.0.2的Google分支(https://android.googlesource.com/toolchain/llvm,1d739ffb0366421d383e04ff80ec2ee591315116(?我在构建原始LLVM时没有问题。但是运行配置步骤cmake <path/to/llvm/source/root>会产生许多类似的错误:

...
-- Targeting XCore
-- Clang version: 7.0.0
-- Performing Test CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG
-- Performing Test CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG - Failed
CMake Error at tools/clang/tools/diagtool/CMakeLists.txt:14 (target_link_libraries):
The keyword signature for target_link_libraries has already been used with
the target "diagtool".  All uses of target_link_libraries with a target
must be either all-keyword or all-plain.
The uses of the keyword signature are here:
* cmake/modules/LLVM-Config.cmake:105 (target_link_libraries)
* cmake/modules/AddLLVM.cmake:771 (target_link_libraries)

CMake Error at tools/clang/tools/driver/CMakeLists.txt:33 (target_link_libraries):
The keyword signature for target_link_libraries has already been used with
the target "clang".  All uses of target_link_libraries with a target must
be either all-keyword or all-plain.
The uses of the keyword signature are here:
* cmake/modules/LLVM-Config.cmake:105 (target_link_libraries)
* cmake/modules/AddLLVM.cmake:771 (target_link_libraries)

CMake Error at tools/clang/tools/clang-format/CMakeLists.txt:14 (target_link_libraries):
The keyword signature for target_link_libraries has already been used with
the target "clang-format".  All uses of target_link_libraries with a target
must be either all-keyword or all-plain.
The uses of the keyword signature are here:
* cmake/modules/LLVM-Config.cmake:105 (target_link_libraries)
* cmake/modules/AddLLVM.cmake:771 (target_link_libraries)
...

我在Linux Mint 18.2,x86_64机器上。

编辑:如果我跳过"工具"和"测试",那么它可以工作。像这样:cmake -G Ninja -DLLVM_INCLUDE_TESTS=OFF -DLLVM_INCLUDE_TOOLS=OFF <src>.尽管使用ninja构建由于类似原因而失败,即使我指定了标志以跳过构建(而不仅仅是配置("工具"和"测试"——但它无论如何都会尝试构建它们:(

解决了这个问题。签出的代码实际上包含链接(工具/叮当->../../clang( 到与 LLVM 源相同的级别目录。我有一些以前的测试中现有的clang目录,它与Google LLVM 7.0.2不兼容。所以我删除了这个目录并下载了相应的 clang 版本来修复错误。

最新更新