Skip to content

Commit

Permalink
fix compilation issues with latest llvm12 trunk
Browse files Browse the repository at this point in the history
With latest llvm12 trunk, we got two compilation bugs.

Bug iovisor#1:
  /home/yhs/work/bcc/src/cc/frontends/clang/b_frontend_action.cc:
     In member function ‘void ebpf::BFrontendAction::DoMiscWorkAround()’:
  /home/yhs/work/bcc/src/cc/frontends/clang/b_frontend_action.cc:1706:31:
     error: ‘class clang::SourceManage’ has no member named ‘getBuffer’; did you mean ‘getBufferData’?
     rewriter_->getSourceMgr().getBuffer(rewriter_->getSourceMgr().getMainFileID())->getBufferSize(),
                               ^~~~~~~~~
                               getBufferData

  This is due to upstream change https://reviews.llvm.org/D89394.
  To fix, follow upstream examples in https://reviews.llvm.org/D89394.

Bug iovisor#2:
  /home/yhs/work/bcc/src/cc/bpf_module.cc: In member function ‘int ebpf::BPFModule::finalize()’:
  /home/yhs/work/bcc/src/cc/bpf_module.cc:470:11:
    error: ‘class llvm::EngineBuilder’ has no member named ‘setUseOrcMCJITReplacement’
   builder.setUseOrcMCJITReplacement(false);
           ^~~~~~~~~~~~~~~~~~~~~~~~~

  This is due to upstream
    llvm/llvm-project@6154c41

  It seems builder.setUseOrcMCJITReplacement() is not needed any more. So just remove it
  from bcc.

Signed-off-by: Yonghong Song <[email protected]>
  • Loading branch information
yonghong-song committed Nov 4, 2020
1 parent 12107c6 commit 8e807dc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/cc/bpf_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,9 @@ int BPFModule::finalize() {
builder.setErrorStr(&err);
builder.setMCJITMemoryManager(ebpf::make_unique<MyMemoryManager>(sections_p));
builder.setMArch("bpf");
#if LLVM_MAJOR_VERSION <= 11
builder.setUseOrcMCJITReplacement(false);
#endif
engine_ = unique_ptr<ExecutionEngine>(builder.create());
if (!engine_) {
fprintf(stderr, "Could not create ExecutionEngine: %s\n", err.c_str());
Expand Down
2 changes: 2 additions & 0 deletions src/cc/bpf_module_rw_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,9 @@ unique_ptr<ExecutionEngine> BPFModule::finalize_rw(unique_ptr<Module> m) {
string err;
EngineBuilder builder(move(m));
builder.setErrorStr(&err);
#if LLVM_MAJOR_VERSION <= 11
builder.setUseOrcMCJITReplacement(false);
#endif
auto engine = unique_ptr<ExecutionEngine>(builder.create());
if (!engine)
fprintf(stderr, "Could not create ExecutionEngine: %s\n", err.c_str());
Expand Down
4 changes: 4 additions & 0 deletions src/cc/frontends/clang/b_frontend_action.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1700,7 +1700,11 @@ void BFrontendAction::DoMiscWorkAround() {
false);

rewriter_->getEditBuffer(rewriter_->getSourceMgr().getMainFileID()).InsertTextAfter(
#if LLVM_MAJOR_VERSION >= 12
rewriter_->getSourceMgr().getBufferOrFake(rewriter_->getSourceMgr().getMainFileID()).getBufferSize(),
#else
rewriter_->getSourceMgr().getBuffer(rewriter_->getSourceMgr().getMainFileID())->getBufferSize(),
#endif
"\n#include <bcc/footer.h>\n");
}

Expand Down

0 comments on commit 8e807dc

Please sign in to comment.