4

我一直按照http://clang.llvm.org/docs/LibASTMatchersTutorial.html上的说明使用 ninja 设置 Clang。

一切顺利,直到我ccmake ../llvm按照网页上的说明将 Clang 设置为自己的编译器(我在 中设置CMAKE_CXX_COMPILER了我最近编译的 clang++ 二进制文件$TARGETFOLDER/clang-llvm/build/bin/clang++)。

之后,当我输入 时ninja,会显示以下错误:

$ ccmake ../llvm/
$ ninja

[50/2561] Building C object lib/Support/CMakeFiles/LLVMSupport.dir/ConvertUTF.c.o
FAILED: /usr/bin/cc  -DGTEST_HAS_RTTI=0 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fPIC -Wall -W -Wno-unused-parameter -Wwrite-strings -Wmissing-field-initializers -pedantic -Wno-long-long -Wno-comment -fcolor-diagnostics -ffunction-sections -fdata-sections -Ilib/Support -I$TARGETFOLDER/clang-llvm/llvm/lib/Support -Iinclude -I$TARGETFOLDER/clang-llvm/llvm/include -MMD -MT lib/Support/CMakeFiles/LLVMSupport.dir/ConvertUTF.c.o -MF "lib/Support/CMakeFiles/LLVMSupport.dir/ConvertUTF.c.o.d" -o lib/Support/CMakeFiles/LLVMSupport.dir/ConvertUTF.c.o   -c $TARGETFOLDER/clang-llvm/llvm/lib/Support/ConvertUTF.c

cc: error: unrecognized command line option ‘-fcolor-diagnostics’

[50/2561] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/CommandLine.cpp.o
ninja: build stopped: subcommand failed.

我已经在两台装有 Ubuntu 13.10 和 Ubuntu 14.04 的机器上对其进行了测试,并且出现了同样的错误。

有任何想法吗?

4

1 回答 1

4

正如 Hongxu Chen 所指出的以及这篇文章中提到的http://clang-developers.42468.n3.nabble.com/Compilation-issues-Ubuntu-14-10-td4042443.html,您还需要将 CMAKE_C_COMPILER 设置为最近内置clang(文档中未提及)。

Clang 现在与忍者一起工作。

于 2015-01-29T17:52:56.190 回答