使用cmake从llvm源目录开发llvm传递 [英] developing an llvm pass with cmake out of llvm source directory

查看:1328
本文介绍了使用cmake从llvm源目录开发llvm传递的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的项目目录下开发一个llvm pass。为此,我遵循 http:// llvm中的信息.org / docs / CMake.html#developing-llvm-pass-of-source 。我在这个链接中适当地创建我的CMakeFiles,我的最终项目目录是:

  |  -  src 
| | - CMakeLists.txt
| | - bigForPass
| | | - CMakeLists.txt
| | | - bigForPass.cpp
| | | - merged.bc
| | - build

我还将我的源文件与llvm根目录链接,没有任何问题。
最后,我在'build'文件夹下构建,我的共享库成功创建,没有问题(在build / bin文件夹下),名称为LLVMHello1.dylib。
然而,当我尝试使用命令运行我的通过merged.bc文件(其中包含我的llvm代码)

  opt -load ../build/bin/LLVMHello1.dylib -bishe_insert< merged.bc> final.bc 

我一直收到错误;

 打开'../build/bin/LLVMHello1.dylib'时出错:dlopen(../ build / bin / LLVMHello1.dylib,9):未找到符号:__ZTIN4llvm10ModulePassE 
引用自:../build/bin/LLVMHello1.dylib
预期在:flat命名空间
在../build/bin/LLVMHello1.dylib
中 - 请求被忽略。有任何想法和建议对此赞赏吗?


p>提前多谢。

解决方案

来自 http://www.jiang925.com/node/28


未定义符号:_ZTIN4llvm12FunctionPassE LLVM主构建系统和用于构建
源代码的cmake支持之间存在不一致性
。 LLVM二进制文件构建时没有运行时类型info
-fno-rtti。因此,源外传递必须以相同的方式构建
,否则选择将抱怨符号
_ZTIN4llvm12FunctionPassE未定义。



要解决这个问题,LLVM必须使用RTTI启用编译。添加
-DLLVM_REQUIRES_RTTI = 1到cmake,或添加REQUIRES_RTTI = 1来生成。


SET(CMAKE_CXX_FLAGS-Wall -fno-rtti)到我的传递图书馆的CMakeLists.txt,然后它的工作。


I am trying to develop an llvm pass under my project directory. For that, I follow the info in http://llvm.org/docs/CMake.html#developing-llvm-pass-out-of-source. I create my CMakeFiles appropriately as in this link and my final project directory is like;

|-- src
|   |-- CMakeLists.txt
|   |-- bigForPass
|   |   |-- CMakeLists.txt
|   |   |-- bigForPass.cpp
|   |   |-- merged.bc
|   |-- build

I also linked my source files with llvm root directory without any problem. Finally I make the build under the 'build' folder and my shared library is created successfully with no problems (under build/bin folder) with the name LLVMHello1.dylib. However, when I try to run my pass over merged.bc file (which contains my llvm code) with the command

opt -load ../build/bin/LLVMHello1.dylib -bishe_insert <merged.bc> final.bc

I keep getting the error;

Error opening '../build/bin/LLVMHello1.dylib': dlopen(../build/bin/LLVMHello1.dylib, 9): Symbol not found: __ZTIN4llvm10ModulePassE
  Referenced from: ../build/bin/LLVMHello1.dylib
  Expected in: flat namespace
 in ../build/bin/LLVMHello1.dylib
  -load request ignored.

Any ideas and suggestions on this appreciated ?

Thanks a lot in advance.

解决方案

from http://www.jiang925.com/node/28

Undefined Symbol: _ZTIN4llvm12FunctionPassE There is an inconsistency between LLVM main build system and the cmake support for building out-of-source. The LLVM binaries are built without runtime type info "-fno-rtti". Therefore, the out-of-source passes have to be built the same way otherwise opt will complain that symbol "_ZTIN4llvm12FunctionPassE" is undefined.

To solve this problem, LLVM must be compile with RTTI enabled. Add "-DLLVM_REQUIRES_RTTI=1" to cmake, or add "REQUIRES_RTTI=1" to make.

So I added SET(CMAKE_CXX_FLAGS "-Wall -fno-rtti") to CMakeLists.txt of my pass library and then it's working.

这篇关于使用cmake从llvm源目录开发llvm传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆