I started studying cmake
about 2 weeks ago and like it. Thus far, I have been successful in building and packaging (with the native system packaging format) libc++abi
, libc++
, llvm
3.4 all with cmake
(libc++abi
with my own cmake
setup) for RHEL 6.x, Fedora 20+, and Ubuntu 12.04 LTS+.
我大约两周前开始学习cmake,喜欢它。到目前为止,我已经成功地构建和打包了(使用本机系统打包格式)libc++abi、libc++、llvm 3.4和cmake (libc++abi和我自己的cmake设置),用于RHEL 6。x, Fedora 20+,和Ubuntu 12.04 LTS+。
I would like to create a C++ build environment that
我想创建一个c++构建环境。
-
Frees us from dependency on GNU GCC and
libstdc++
completely (thus we don't want any LLVM RPM/DEB from these aforementioned distros or the LLVM Debian/Ubuntu nightly packages download site) - 将我们从对GNU GCC和libstdc++的依赖中解放出来(因此我们不需要这些前面提到的distros或LLVM Debian/Ubuntu夜间软件包下载站点的LLVM RPM/DEB)。
- Enables us to explore fully C++11 and C++1y. In other words, we can try even the bleeding edge LLVM/clang anytime we want to while keeping all our build systems clean with package management systems.
- 使我们能够充分地探索c++ 11和c++ 1y。换句话说,我们可以在任何时候尝试使用流边LLVM/clang,同时保持所有的构建系统与包管理系统保持一致。
Nevertheless, I hit a snag in attempting to build clang
3.4 with cmake
, on a build host running Ubuntu 12.04 LTS 64bit, with a pure clang 3.3 built by me without any dependency on GNU libstdc++
, together with libc++
3.3 and libc++abi
. The later two have no libstdc++
dependency either. I built both that way too.
尽管如此,我在尝试用cmake构建clang 3.4时遇到了一个障碍,在一个运行Ubuntu 12.04 LTS 64位的构建主机上,我使用了一个纯粹的clang 3.3,没有依赖GNU libstdc++,与libc++ 3.3和libc++abi一起构建。后面的两个也没有libstdc++依赖关系。我也是这么做的。
I know of the Clang - Getting Started Web page really well and have used the instructions there successfully. But these are exactly what I don't want to use. They are incorrect too: the CMakeLists.txt
of clang
3.4 clearly states the following:
我知道Clang -开始网页很好,并且已经成功地使用了那里的指示。但这些正是我不想使用的。他们也不正确:CMakeLists。clang 3.4 txt明确声明如下:
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.")
See line 1 and 2. But, I have not found any LLVM documentation regarding how to set the CLANG_PATH_TO_LLVM_BUILD
. I tried the following:
参见第1行和第2行。但是,我还没有找到关于如何设置CLANG_PATH_TO_LLVM_BUILD的LLVM文档。我试着以下:
cmake -DCLANG_PATH_TO_LLVM_BUILD="../../llvm-3.4/build" ..
and got the following errors:
并得到以下错误:
$ 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!
But that's not right! The LLVM + compiler-rt
has been installed on the build host with our own DEB
. And,
但这是不正确的!使用我们自己的DEB在构建主机上安装了LLVM +编译-rt。而且,
$ 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
So, all required cmake
modules are there - right on the system!
所以,所有需要的cmake模块都在系统上!
I would appreciate a hint as to how to coerce clang
3.4 to build with cmake
, with an already installed LLVM 3.4 + compiler-rt
3.4.
我想了解一下如何强制clang 3.4与cmake一起构建,并且已经安装了LLVM 3.4 +编译器-rt 3.4。
Update:
更新:
I decided to do the following:
我决定做以下工作:
$ 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
That's better. Looks like clang
3.4's default CMakeLists.txt
is not even QA-ed x-( Yikes x-(
这是更好的。看起来像clang 3.4的默认CMakeLists。txt甚至不是QA-ed x-(Yikes x-(
2 个解决方案
#1
4
I decided to tough it out as any self-respecting engineer would do :) I simply vi-ed the following two files and add full path to the offending include, and then that's that.
我决定像任何一个有自尊心的工程师一样坚持到底:)我只是简单地把下面两个文件加起来,然后加上一条完整的路径,然后就是这样。
-
Options.td
- Options.td
CC1AsOptions.td
- CC1AsOptions.td
Now I can build all desired LLVM main projects without libstdc++
dependency, all linked with libc++
and libc++abi
. Hooray :)
现在,我可以在没有libstdc++依赖的情况下构建所有想要的LLVM主项目,它们都与libc++和libc++abi有关。万岁:)
So, I have confirmed that
我已经证实了。
- Some instructions given in Getting Started: Building and Running Clang are misleading, e.g. 7.
- 开始时给出的一些指示:构建和运行Clang是具有误导性的,例如7。
- All main LLVM projects (except
compiler-rt
AFAIK) can be built withcmake
. There is no need to lump them together under the LLVM source tree for building. You definitely can build nearly all of them separately on Linux, unlike what these "official" documentation may lead you to believe :> - 所有主LLVM项目(编译器-rt AFAIK除外)都可以用cmake构建。在LLVM源代码树下,不需要将它们合并在一起。您肯定可以在Linux上单独构建几乎所有的文件,而这些“官方”文档可能会让您相信:>。
The LLVM team should really think through and minimize the apparent cyclic dependency among all projects. Bootstrapping LLVM/clang on various Linux distros (especially older ones such as RHEL 5.x) without GNU libstdc++
dependency is too tedious - speaking from my first hand experience. They can be done (I have done it :) but it's not for the faint of heart.
LLVM团队应该认真考虑并最小化所有项目中明显的循环依赖关系。如果没有GNU libstdc++的依赖,可以在不同的Linux发行版上(特别是旧的版本,比如RHEL 5.x)上启动LLVM/clang,这太冗长了——从我的第一次经验来看。他们可以做(我已经做过了),但这不是为胆小的人做的。
#2
2
I think this project does what you're trying to do:
我认为这个项目做了你想做的事情:
https://github.com/rsmmr/install-clang
https://github.com/rsmmr/install-clang
I've used it on FC16+, but did run into bootstrapping issues on RHEL5.x.
我在FC16+上使用过,但是在RHEL5.x上遇到了引导问题。
#1
4
I decided to tough it out as any self-respecting engineer would do :) I simply vi-ed the following two files and add full path to the offending include, and then that's that.
我决定像任何一个有自尊心的工程师一样坚持到底:)我只是简单地把下面两个文件加起来,然后加上一条完整的路径,然后就是这样。
-
Options.td
- Options.td
CC1AsOptions.td
- CC1AsOptions.td
Now I can build all desired LLVM main projects without libstdc++
dependency, all linked with libc++
and libc++abi
. Hooray :)
现在,我可以在没有libstdc++依赖的情况下构建所有想要的LLVM主项目,它们都与libc++和libc++abi有关。万岁:)
So, I have confirmed that
我已经证实了。
- Some instructions given in Getting Started: Building and Running Clang are misleading, e.g. 7.
- 开始时给出的一些指示:构建和运行Clang是具有误导性的,例如7。
- All main LLVM projects (except
compiler-rt
AFAIK) can be built withcmake
. There is no need to lump them together under the LLVM source tree for building. You definitely can build nearly all of them separately on Linux, unlike what these "official" documentation may lead you to believe :> - 所有主LLVM项目(编译器-rt AFAIK除外)都可以用cmake构建。在LLVM源代码树下,不需要将它们合并在一起。您肯定可以在Linux上单独构建几乎所有的文件,而这些“官方”文档可能会让您相信:>。
The LLVM team should really think through and minimize the apparent cyclic dependency among all projects. Bootstrapping LLVM/clang on various Linux distros (especially older ones such as RHEL 5.x) without GNU libstdc++
dependency is too tedious - speaking from my first hand experience. They can be done (I have done it :) but it's not for the faint of heart.
LLVM团队应该认真考虑并最小化所有项目中明显的循环依赖关系。如果没有GNU libstdc++的依赖,可以在不同的Linux发行版上(特别是旧的版本,比如RHEL 5.x)上启动LLVM/clang,这太冗长了——从我的第一次经验来看。他们可以做(我已经做过了),但这不是为胆小的人做的。
#2
2
I think this project does what you're trying to do:
我认为这个项目做了你想做的事情:
https://github.com/rsmmr/install-clang
https://github.com/rsmmr/install-clang
I've used it on FC16+, but did run into bootstrapping issues on RHEL5.x.
我在FC16+上使用过,但是在RHEL5.x上遇到了引导问题。