如何在Eclipse上构建LLVM源代码?

3

我正在尝试向LLVM编译器基础设施中添加新的pass。 我已经能够使用make构建LLVM-2.9。但是我想使用Eclipse进行构建,以便我可以跟踪代码。 我使用LinuxGcc工具链和CDT内部构建器(带有CDT-7.0的Eclipse)将LLVM源文件导入到C++项目中。但是它会出现一些错误。 这是否是使用Eclipse构建LLVM的正确方法? 请告诉我使用Eclipse构建LLVM源码的步骤。 注意:平台为ubuntu。

2个回答

7
  1. Tools/versions used by me:

    • eclipse 4.3 Kepler, CDT 8.2.1
    • Oracle Java SDK 1.7.0_45
    • cmake 2.8.11.2
    • LLVM 3.5svn
  2. Create a folder for CDT project files in your workspace. I.e. workspace/llvm.

  3. Generate CDT project files with cmake (being in workspace/llvm):

    cmake -G "Eclipse CDT4 - Unix Makefiles" -D_ECLIPSE_VERSION=4.3 ../../src/llvm
    

    If eclipse version is not set the generator will assume 3.7 and inform you that it can be changed by CMAKE_ECLIPSE_VERSION option, what turns out to be the wrong name for that option.

  4. Increase eclipse heap allocation size. The default setting is too small and C++ Indexer would hang the whole IDE. Replace default settings with

    -Xms512m
    -Xmx1024m
    

    in eclipse.ini file.

  5. Import the project into your workspace. File → Import... → General → Existing Projects into Workspace.

  6. The project llvm can be built as one (option Build Project). There are also separated targets created for every lib and executable, placed in [Targets] folder. Individual target can be built with option Make Targets → Build...

我已经成功使用你的答案构建了LLVM + Clang。现在我遇到了一个问题,就是索引器覆盖所有源文件所需的时间。你有什么提示可以减少这个索引时间吗? - Manuel Selva

2
你可以使用cmake -G"Eclipse CDT4 - Unix Makefiles"来生成本地Eclipse项目集。这可能需要调整你的CMakeLists.txt,以删除源内构建的检查(因为Eclipse只支持在同一目录中的项目文件和源代码,但由于某种原因,当前的CMakeLists仅允许MSVS)- 只需按照错误消息操作即可。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接