解决llvm-9.0开启JIT EVENT后的编译错误'undefined reference to llvm::createLowerSwitchPass()'

解决llvm-9.0开启JIT EVENT后的编译错误’undefined reference to llvm::createLowerSwitchPass()’

开启JIT EVENT需要在cmake命令中增加-DLLVM_USE_OPROFILE=ON-DLLVM_USE_INTEL_JITEVENTS=ON-DLLVM_USE_PERF=ON三个选项,但是不幸的是,在llvm-9.0版本,会在编译时报错,错误信息如下图:

根据编译器报错信息提示,找到文件’llvm/lib/ExecutionEngine/OProfileJIT/OProfileJITEventListener.cpp’, 然后如下修改:

104     uint64_t Addr = *AddrOrErr;
105 +++                                                                         
106 +++                                                                         
107 +++ //---------------FIX COMPILE ERROR                                      
108 +++ auto SecOrErr = Sym.getSection();                                       
109 +++ if (!SecOrErr) {                                                        
110 +++     // TODO: Actually report errors helpfully.                          
111 +++     consumeError(SecOrErr.takeError());                                 
112 +++     continue;                                                           
113 +++ }                                                                       
114 +++ object::section_iterator Sec = *SecOrErr;                               
115 +++ if (Sec == Obj.section_end())                                           
116 +++     continue;                                                           
117 +++ uint64_t Index = Sec->getIndex();                                       
118 +++ //---------------FIX COMPILE ERROR                                      
119 +++                                                                         
120 +++                                                                         
121     uint64_t Size = P.second;
122 
123     if (Wrapper->op_write_native_code(Name.data(), Addr, (void *)Addr, Size)
124         -1) {
125       LLVM_DEBUG(dbgs() << "Failed to tell OProfile about native function "
126                         << Name << " at [" << (void *)Addr << "-"
127                         << ((char *)Addr + Size) << "]\n");
128       continue;
129     }
130 
131 +++ DILineInfoTable Lines = Context->getLineInfoForAddressRange({Addr,Index}, Size);
115 --- DILineInfoTable Lines = Context->getLineInfoForAddressRange(Addr, Size);

重新编译,即可解决编译的报错的问题

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值