简体   繁体   English

如何用 clang 构建 clang?

[英]How to build clang with clang?

I allready build clang(3.2) with MSVC and MinGW succesfully.我已经成功地使用 MSVC 和 MinGW 构建了 clang(3.2)。 But I think it's not the "purely" clang.但我认为这不是“纯粹的”铿锵声。 So could someone give me some instructions or materials about how to use clang to build clang(Windows/Linux)?那么有人可以给我一些关于如何使用clang构建clang(Windows / Linux)的说明或材料吗? And could we use clang indepently(Not depent on GCC or MSVC).我们可以独立使用clang吗(不依赖于GCC或MSVC)。 Thanks all!谢谢大家!

Well get an older version of clang like 3.1. 好吧得到像3.1这样的旧版铿锵声。 (You can pretty much install any version that comes precompiled for your OS) (您几乎可以安装为您的操作系统预编译的任何版本)

Get the sources for a newer version like 3.2. 获取像3.2这样的新版本的来源。

Then (i like cmake+ninja ( http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html )) 然后(我喜欢cmake +忍者( http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html ))

if you unpacked llvm source to ~/llvm_source/llvm 如果你将llvm源解压缩到〜/ llvm_source / llvm

cd ~/llvm_source
mkdir build
cd build
CXX=clang++ CC=clang cmake -G Ninja ../llvm -DCMAKE_BUILD_TYPE=Release
ninja

If you want it for make 如果你想要它

CXX=clang++ CC=clang cmake ../llvm -DCMAKE_BUILD_TYPE=Release
make

Thats it. 而已。

Have fun. 玩得开心。

The current method (as of 27th Feb 17') seems to be as follows, 目前的方法(截至2月27日')似乎如下,

cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++  $LLVM_SRC_DIR # -G Ninja

Where CMAKE_C_COMPILER and CMAKE_CXX_COMPILER are CMake variables define by -D . 其中CMAKE_C_COMPILER和CMAKE_CXX_COMPILER是由-D定义的CMake变量。 Somehow, these variables don't appear in llvm_src/CMakeLists.txt 不知何故,这些变量不会出现在llvm_src / CMakeLists.txt中

When making clang with clang, you will coincide with the already existing definitions of builtin functions and those which yet to be defined again - the compiler gets into troubles of doubled consciousness!!!用clang制作clang时,你会与已经存在的内置函数定义和尚未重新定义的定义重合——编译器陷入双重意识的烦恼! I've got the next:我有下一个:


clang/Basic/BuiltinsX86.def:1907:1: note: previous definition is here TARGET_HEADER_BUILTIN(_ReadWriteBarrier, "v", "nh", "intrin.h", ALL_MS_LANGUAGES, "") clang/Basic/BuiltinsX86.def:1907:1: 注意:之前的定义在这里 TARGET_HEADER_BUILTIN(_ReadWriteBarrier, "v", "nh", "intrin.h", ALL_MS_LANGUAGES, "")

clang\CodeGen\code\CGBuiltin.cpp:638:1: error: reference to '_bittest' is ambiguous BitTest BitTest::decodeBitTestBuiltin(unsigned BuiltinID) { ^ include\winnt.h:2236:17: note: expanded from macro 'BitTest' #define BitTest _bittest ^ include\psdk_inc/intrin-impl.h:1707:16: note: candidate found by name lookup is '_bittest' __buildbittest(_bittest, __LONG32, "l", "I") ^ clang\CodeGen\code\CGBuiltin.cpp:620:8: note: candidate found by name lookup is '(anonymous namespace)::_bit test' struct BitTest { ^ include\winnt.h:2236:17: note: expanded from macro 'BitTest' #define BitTest _bittest ^ clang\CodeGen\code\CGBuiltin.cpp:696:45: error: reference to '_bittest' is ambiguous BitTest BT, ^ include\winnt.h:2236:17: note: expanded from macro 'BitTest' #define BitTest _bittest ^ include\psdk_inc/intrin-impl.h:1707:16: note: candidate found by name lookup is '_bittest' __buildbittest(_bittest, __LONG32, "l", "I") clang\CodeGen\code\CGBuiltin.cpp:638:1: error: reference to '_bittest' is ambiguous BitTest BitTest::decodeBitTestBuiltin(unsigned BuiltinID) { ^ include\winnt.h:2236:17: 注意:从宏扩展' BitTest' #define BitTest _bittest ^ include\psdk_inc/intrin-impl.h:1707:16: 注意:通过名称查找找到的候选是 '_bittest' __buildbittest(_bittest, __LONG32, "l", "I") ^ clang\CodeGen \code\CGBuiltin.cpp:620:8:注意:通过名称查找找到的候选是 '(匿名命名空间)::_bit test' struct BitTest { ^ include\winnt.h:2236:17: 注意:从宏 'BitTest 扩展' #define BitTest _bittest ^ clang\CodeGen\code\CGBuiltin.cpp:696:45:错误:对 '_bittest' 的引用不明确 BitTest BT,^ include\winnt.h:2236:17:注意:从宏 'BitTest 扩展' #define BitTest _bittest ^ include\psdk_inc/intrin-impl.h:1707:16: 注意:通过名称查找找到的候选是 '_bittest' __buildbittest(_bittest, __LONG32, "l", "I")


And so on and on ...等等等等……

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM