LLVM 添加传递 - 链接错误
我已将我的通行证写入 llvm/lib/Transforms
中,其名称为 createABCDPass
。我在我的 pass 中添加了以下代码:
namespace llvm { FunctionPass *createABCDPass(); }
FunctionPass *llvm::createABCDPass() { return new AbcRemoval(); }
其中 AbcRemoval
是 pass 的类。
之后,我在 lib/CodeGen/LLVMTargetMachine.cpp 中进行了前向声明,以便识别我的通行证:
namespace llvm { FunctionPass *createABCDPass(); }
PM.add(createABCDPass());
但是,当我在 llvm 上运行 make 时,出现以下错误:
llvm[2]: Linking Release executable llc (without symbols)
Undefined symbols:
"llvm::createABCDPass()", referenced from:
llvm::LLVMTargetMachine::addCommonCodeGenPasses(llvm::PassManagerBase&, llvm::CodeGenOpt::Level, bool, llvm::MCContext*&)in libLLVMCodeGen.a(LLVMTargetMachine.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[2]: *** [/Users/.../llvm/Release/bin/llc] Error 1
make[1]: *** [llc/.makeall] Error 2
make: *** [all] Error 1
有人知道为什么吗我收到这个错误吗?谢谢!
I have written my pass in llvm/lib/Transforms
, and its called createABCDPass
. I have added the following code in my pass:
namespace llvm { FunctionPass *createABCDPass(); }
FunctionPass *llvm::createABCDPass() { return new AbcRemoval(); }
where AbcRemoval
is the class of the pass.
After that, I have done a forward declaration in lib/CodeGen/LLVMTargetMachine.cpp
in order to recognize my pass:
namespace llvm { FunctionPass *createABCDPass(); }
PM.add(createABCDPass());
However, when I run make on llvm, i get the following error:
llvm[2]: Linking Release executable llc (without symbols)
Undefined symbols:
"llvm::createABCDPass()", referenced from:
llvm::LLVMTargetMachine::addCommonCodeGenPasses(llvm::PassManagerBase&, llvm::CodeGenOpt::Level, bool, llvm::MCContext*&)in libLLVMCodeGen.a(LLVMTargetMachine.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[2]: *** [/Users/.../llvm/Release/bin/llc] Error 1
make[1]: *** [llc/.makeall] Error 2
make: *** [all] Error 1
Does anybody know why am I getting this error? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
啊,我最终通过将 pass 模块重命名为 -libLLVM_xxx 来修复它。显然你必须将其命名为 libLLVM_"something" 才能使其与 LLVM 中的所有其他通道一起动态运行。不知道为什么,但它有效!
Ah, I fixed it in the end by renaming the pass module to -libLLVM_xxx. Apparently you got to name it libLLVM_"something" in order for it to run with all the other passes in LLVM dynamically. Not sure why, but it works!
您必须将您的通行证链接到 llc。默认情况下,llc 几乎不会从
lib/Transforms
中提取任何内容,因此您的通行证不会链接到 llc。You have to link your pass to llc. By default llc pulls almost nothing from
lib/Transforms
, so your pass won't be linked in to llc.