代码之家  ›  专栏  ›  技术社区  ›  hyperdelia

使用CMake遵循Pass教程时出现内部LLVM语法错误

  •  0
  • hyperdelia  · 技术社区  · 10 年前

    我正在尝试遵循教程 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 include目录。

    我的第一个想法是,CMake试图使用不同的编译器(Clang与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>>
    
    1 回复  |  直到 10 年前
        1
  •  0
  •   Community Mohan Dere    9 年前

    因此,经过大量研究后,发现LLVM和CMake支持源代码外构建的方式存在不一致。LLVM二进制文件使用 -fno-rtti ,所以CMake会抱怨缺少符号,除非它也使用 -fno rtti公司 编译LLVM过程时。

    我通过添加 SET(CMAKE_CXX_FLAGS "-Wall -fno-rtti") 添加到我的CMakeLists。最里面的目录中的txt文件。

    这是受此启发的 question 也在StackOverflow上。

    推荐文章