我正在尝试按照教程here开发一个“Hello,World”LLVM传递 - 我正在使用该教程here链接的指南来实现LLVM源目录。但是,当我尝试遵循本教程时,CMake会报告LLVM本身内部的一些错误。
我有以下目录结构:
HelloWorld/
CMakeLists.txt
HelloWorld/
CMakeLists.txt
HelloWorld.cpp
我的HelloWorld.cpp
和两个CMakeLists.txt
直接从上面链接的教程中复制和粘贴。
我运行CMake HelloWorld
并成功生成CMake配置。但是,当我运行make
时。我从LLVM代码库本身报告了大量错误。
[ 50%] Building CXX object CMakeFiles/LLVMPassName.dir/Vectorize.cpp.o
In file included from /Volumes/andromeda/HelloWorld/HelloWorld.cpp:1:
In file included from /usr/local/Cellar/llvm/3.6.2/include/llvm/Pass.h:377:
In file included from /usr/local/Cellar/llvm/3.6.2/include/llvm/PassSupport.h:27:
In file included from /usr/local/Cellar/llvm/3.6.2/include/llvm/PassRegistry.h:20:
In file included from /usr/local/Cellar/llvm/3.6.2/include/llvm-c/Core.h:18:
In file included from /usr/local/Cellar/llvm/3.6.2/include/llvm-c/Support.h:17:
/usr/local/Cellar/llvm/3.6.2/include/llvm/Support/DataTypes.h:57:3: error: "Must #define
__STDC_LIMIT_MACROS before #including Support/DataTypes.h"
# error "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h"
^
/usr/local/Cellar/llvm/3.6.2/include/llvm/Support/DataTypes.h:61:3: error: "Must #define
__STDC_CONSTANT_MACROS before " "#including Support/DataTypes.h"
# error "Must #define __STDC_CONSTANT_MACROS before " \
列表一直在继续,所有这些都引用LLVM头文件中的错误。这是使用Homebrew彻底安装LLVM。为了使链接工作,我必须将CPLUS_INCLUDE_PATH
设置为LLVM的Homebrew包含目录。
我的第一个想法是CMake尝试使用不同的编译器(Clang vs. GCC,反之亦然),但将CMAKE_CXX_COMPILER
设置为指向我的clang
或g++
安装没有帮助。
有没有人对这里可能存在的问题有任何想法?
在评论中跟随@oak提供的链接之后,我能够摆脱前两个Support / DataType错误。但是,许多错误仍然存在。
In file included from /usr/local/Cellar/llvm/3.6.2/include/llvm/Pass.h:377:
In file included from /usr/local/Cellar/llvm/3.6.2/include/llvm/PassSupport.h:27:
In file included from /usr/local/Cellar/llvm/3.6.2/include/llvm/PassRegistry.h:21:
/usr/local/Cellar/llvm/3.6.2/include/llvm/ADT/DenseMap.h:543:63: error: a space is required
between consecutive right angle brackets (use '> >')
typename BucketT = detail::DenseMapPair<KeyT, ValueT>>
^
/usr/local/Cellar/llvm/3.6.2/include/llvm/ADT/DenseMap.h:694:63: error: a space is required
between consecutive right angle brackets (use '> >')
typename BucketT = detail::DenseMapPair<KeyT, ValueT>>
答案 0 :(得分:0)
因此,经过大量研究后发现,LLVM和CMake如何支持源外构建存在不一致。 LLVM二进制文件使用-fno-rtti
构建,因此CMake会抱怨缺少符号,除非在编译LLVM传递时它也使用SET(CMAKE_CXX_FLAGS "-Wall -fno-rtti")
。
通过将{{1}}添加到最里面目录中的CMakeLists.txt文件,我修复了所有麻烦(包括Oak提出的临时修复解决的问题)。
这也受到了StackOverflow上的question的启发。