From fb9efbb0b6366620a16bd7ddacb7d027e938c506 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Sat, 6 Feb 2021 12:19:46 -0800 Subject: bcc: Fix build with clang-12 bring-in needed patches from upstream Signed-off-by: Khem Raj --- ...mpilation-issues-with-latest-llvm12-trunk.patch | 89 ++++++++++++++++++++++ ...ompilation-error-with-latest-llvm12-trunk.patch | 60 +++++++++++++++ .../recipes-devtools/bcc/bcc_0.17.0.bb | 2 + 3 files changed, 151 insertions(+) create mode 100644 dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-fix-compilation-issues-with-latest-llvm12-trunk.patch create mode 100644 dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0002-fix-compilation-error-with-latest-llvm12-trunk.patch (limited to 'dynamic-layers') diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-fix-compilation-issues-with-latest-llvm12-trunk.patch b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-fix-compilation-issues-with-latest-llvm12-trunk.patch new file mode 100644 index 0000000..b1f56e6 --- /dev/null +++ b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-fix-compilation-issues-with-latest-llvm12-trunk.patch @@ -0,0 +1,89 @@ +From 675fca6a646812361c16884ccd2ff789f40c4ce8 Mon Sep 17 00:00:00 2001 +From: Yonghong Song +Date: Tue, 3 Nov 2020 22:11:57 -0800 +Subject: [PATCH 1/2] fix compilation issues with latest llvm12 trunk +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +With latest llvm12 trunk, we got two compilation bugs. + +Bug #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 #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 + https://github.com/llvm/llvm-project/commit/6154c4115cd4b78d0171892aac21e340e72e32bd + + It seems builder.setUseOrcMCJITReplacement() is not needed any more. So just remove it + from bcc. + +Signed-off-by: Yonghong Song +--- + src/cc/bpf_module.cc | 2 ++ + src/cc/bpf_module_rw_engine.cc | 2 ++ + src/cc/frontends/clang/b_frontend_action.cc | 4 ++++ + 3 files changed, 8 insertions(+) + +diff --git a/src/cc/bpf_module.cc b/src/cc/bpf_module.cc +index 8fba8d27..c194b815 100644 +--- a/src/cc/bpf_module.cc ++++ b/src/cc/bpf_module.cc +@@ -466,7 +466,9 @@ int BPFModule::finalize() { + builder.setErrorStr(&err); + builder.setMCJITMemoryManager(ebpf::make_unique(sections_p)); + builder.setMArch("bpf"); ++#if LLVM_MAJOR_VERSION <= 11 + builder.setUseOrcMCJITReplacement(false); ++#endif + engine_ = unique_ptr(builder.create()); + if (!engine_) { + fprintf(stderr, "Could not create ExecutionEngine: %s\n", err.c_str()); +diff --git a/src/cc/bpf_module_rw_engine.cc b/src/cc/bpf_module_rw_engine.cc +index d7e31a71..9890af69 100644 +--- a/src/cc/bpf_module_rw_engine.cc ++++ b/src/cc/bpf_module_rw_engine.cc +@@ -356,7 +356,9 @@ unique_ptr BPFModule::finalize_rw(unique_ptr m) { + string err; + EngineBuilder builder(move(m)); + builder.setErrorStr(&err); ++#if LLVM_MAJOR_VERSION <= 11 + builder.setUseOrcMCJITReplacement(false); ++#endif + auto engine = unique_ptr(builder.create()); + if (!engine) + fprintf(stderr, "Could not create ExecutionEngine: %s\n", err.c_str()); +diff --git a/src/cc/frontends/clang/b_frontend_action.cc b/src/cc/frontends/clang/b_frontend_action.cc +index 154a3794..80b03b9b 100644 +--- a/src/cc/frontends/clang/b_frontend_action.cc ++++ b/src/cc/frontends/clang/b_frontend_action.cc +@@ -1694,7 +1694,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 \n"); + } + +-- +2.30.0 + diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0002-fix-compilation-error-with-latest-llvm12-trunk.patch b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0002-fix-compilation-error-with-latest-llvm12-trunk.patch new file mode 100644 index 0000000..ded9f28 --- /dev/null +++ b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0002-fix-compilation-error-with-latest-llvm12-trunk.patch @@ -0,0 +1,60 @@ +From 35ff839b1b70b3cd7a9a025d0fd96173e7be566e Mon Sep 17 00:00:00 2001 +From: Yonghong Song +Date: Mon, 4 Jan 2021 19:09:20 -0800 +Subject: [PATCH 2/2] fix compilation error with latest llvm12 trunk +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +With latest llvm trunk (llvm12), I hit the following compilation +error: + ... + [ 17%] Building CXX object src/cc/frontends/b/CMakeFiles/b_frontend.dir/codegen_llvm.cc.o + /home/yhs/work/bcc/src/cc/frontends/b/codegen_llvm.cc: In member function + ‘virtual ebpf::StatusTuple ebpf::cc::CodegenLLVM::visit_table_decl_stmt_node(ebpf::cc::TableDeclStmtNode*)’: + /home/yhs/work/bcc/src/cc/frontends/b/codegen_llvm.cc:1122:37: + error: ‘class llvm::Module’ has no member named ‘getTypeB yName’; did you mean ‘getName’? + StructType *decl_struct = mod_->getTypeByName("_struct." + n->id_->name_); + ^~~~~~~~~~~~~ + getName + +This is due to llvm patch https://reviews.llvm.org/D78793 which +changed how to use getTypeByName(). This patch adjusted the usage +in bcc based on this patch. + +Signed-off-by: Yonghong Song +--- + src/cc/frontends/b/codegen_llvm.cc | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/src/cc/frontends/b/codegen_llvm.cc b/src/cc/frontends/b/codegen_llvm.cc +index d8c9470a..71c83b41 100644 +--- a/src/cc/frontends/b/codegen_llvm.cc ++++ b/src/cc/frontends/b/codegen_llvm.cc +@@ -1119,7 +1119,11 @@ StatusTuple CodegenLLVM::visit_table_decl_stmt_node(TableDeclStmtNode *n) { + StructType *key_stype, *leaf_stype; + TRY2(lookup_struct_type(n->key_type_, &key_stype)); + TRY2(lookup_struct_type(n->leaf_type_, &leaf_stype)); ++#if LLVM_MAJOR_VERSION >= 12 ++ StructType *decl_struct = StructType::getTypeByName(mod_->getContext(), "_struct." + n->id_->name_); ++#else + StructType *decl_struct = mod_->getTypeByName("_struct." + n->id_->name_); ++#endif + if (!decl_struct) + decl_struct = StructType::create(ctx(), "_struct." + n->id_->name_); + if (decl_struct->isOpaque()) +@@ -1182,7 +1186,11 @@ StatusTuple CodegenLLVM::visit_func_decl_stmt_node(FuncDeclStmtNode *n) { + StructType *stype; + //TRY2(lookup_struct_type(formal, &stype)); + auto var = (StructVariableDeclStmtNode *)formal; ++#if LLVM_MAJOR_VERSION >= 12 ++ stype = StructType::getTypeByName(mod_->getContext(), "_struct." + var->struct_id_->name_); ++#else + stype = mod_->getTypeByName("_struct." + var->struct_id_->name_); ++#endif + if (!stype) return mkstatus_(n, "could not find type %s", var->struct_id_->c_str()); + formals.push_back(PointerType::getUnqual(stype)); + } else { +-- +2.30.0 + diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc_0.17.0.bb b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc_0.17.0.bb index d6f70d3..03d3236 100644 --- a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc_0.17.0.bb +++ b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc_0.17.0.bb @@ -18,6 +18,8 @@ SRC_URI = "gitsm://github.com/iovisor/bcc \ file://0001-python-CMakeLists.txt-Remove-check-for-host-etc-debi.patch \ file://0001-tools-trace.py-Fix-failing-to-exit.patch \ file://0001-CMakeLists.txt-override-the-PY_CMD_ESCAPED.patch \ + file://0001-fix-compilation-issues-with-latest-llvm12-trunk.patch \ + file://0002-fix-compilation-error-with-latest-llvm12-trunk.patch \ " SRCREV = "ad5b82a5196b222ed2cdc738d8444e8c9546a77f" -- cgit v1.2.3-54-g00ecf