diff options
Diffstat (limited to 'dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc')
2 files changed, 149 insertions, 0 deletions
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 @@ | |||
1 | From 675fca6a646812361c16884ccd2ff789f40c4ce8 Mon Sep 17 00:00:00 2001 | ||
2 | From: Yonghong Song <yhs@fb.com> | ||
3 | Date: Tue, 3 Nov 2020 22:11:57 -0800 | ||
4 | Subject: [PATCH 1/2] fix compilation issues with latest llvm12 trunk | ||
5 | MIME-Version: 1.0 | ||
6 | Content-Type: text/plain; charset=UTF-8 | ||
7 | Content-Transfer-Encoding: 8bit | ||
8 | |||
9 | With latest llvm12 trunk, we got two compilation bugs. | ||
10 | |||
11 | Bug #1: | ||
12 | /home/yhs/work/bcc/src/cc/frontends/clang/b_frontend_action.cc: | ||
13 | In member function ‘void ebpf::BFrontendAction::DoMiscWorkAround()’: | ||
14 | /home/yhs/work/bcc/src/cc/frontends/clang/b_frontend_action.cc:1706:31: | ||
15 | error: ‘class clang::SourceManage’ has no member named ‘getBuffer’; did you mean ‘getBufferData’? | ||
16 | rewriter_->getSourceMgr().getBuffer(rewriter_->getSourceMgr().getMainFileID())->getBufferSize(), | ||
17 | ^~~~~~~~~ | ||
18 | getBufferData | ||
19 | |||
20 | This is due to upstream change https://reviews.llvm.org/D89394. | ||
21 | To fix, follow upstream examples in https://reviews.llvm.org/D89394. | ||
22 | |||
23 | Bug #2: | ||
24 | /home/yhs/work/bcc/src/cc/bpf_module.cc: In member function ‘int ebpf::BPFModule::finalize()’: | ||
25 | /home/yhs/work/bcc/src/cc/bpf_module.cc:470:11: | ||
26 | error: ‘class llvm::EngineBuilder’ has no member named ‘setUseOrcMCJITReplacement’ | ||
27 | builder.setUseOrcMCJITReplacement(false); | ||
28 | ^~~~~~~~~~~~~~~~~~~~~~~~~ | ||
29 | |||
30 | This is due to upstream | ||
31 | https://github.com/llvm/llvm-project/commit/6154c4115cd4b78d0171892aac21e340e72e32bd | ||
32 | |||
33 | It seems builder.setUseOrcMCJITReplacement() is not needed any more. So just remove it | ||
34 | from bcc. | ||
35 | |||
36 | Signed-off-by: Yonghong Song <yhs@fb.com> | ||
37 | --- | ||
38 | src/cc/bpf_module.cc | 2 ++ | ||
39 | src/cc/bpf_module_rw_engine.cc | 2 ++ | ||
40 | src/cc/frontends/clang/b_frontend_action.cc | 4 ++++ | ||
41 | 3 files changed, 8 insertions(+) | ||
42 | |||
43 | diff --git a/src/cc/bpf_module.cc b/src/cc/bpf_module.cc | ||
44 | index 8fba8d27..c194b815 100644 | ||
45 | --- a/src/cc/bpf_module.cc | ||
46 | +++ b/src/cc/bpf_module.cc | ||
47 | @@ -466,7 +466,9 @@ int BPFModule::finalize() { | ||
48 | builder.setErrorStr(&err); | ||
49 | builder.setMCJITMemoryManager(ebpf::make_unique<MyMemoryManager>(sections_p)); | ||
50 | builder.setMArch("bpf"); | ||
51 | +#if LLVM_MAJOR_VERSION <= 11 | ||
52 | builder.setUseOrcMCJITReplacement(false); | ||
53 | +#endif | ||
54 | engine_ = unique_ptr<ExecutionEngine>(builder.create()); | ||
55 | if (!engine_) { | ||
56 | fprintf(stderr, "Could not create ExecutionEngine: %s\n", err.c_str()); | ||
57 | diff --git a/src/cc/bpf_module_rw_engine.cc b/src/cc/bpf_module_rw_engine.cc | ||
58 | index d7e31a71..9890af69 100644 | ||
59 | --- a/src/cc/bpf_module_rw_engine.cc | ||
60 | +++ b/src/cc/bpf_module_rw_engine.cc | ||
61 | @@ -356,7 +356,9 @@ unique_ptr<ExecutionEngine> BPFModule::finalize_rw(unique_ptr<Module> m) { | ||
62 | string err; | ||
63 | EngineBuilder builder(move(m)); | ||
64 | builder.setErrorStr(&err); | ||
65 | +#if LLVM_MAJOR_VERSION <= 11 | ||
66 | builder.setUseOrcMCJITReplacement(false); | ||
67 | +#endif | ||
68 | auto engine = unique_ptr<ExecutionEngine>(builder.create()); | ||
69 | if (!engine) | ||
70 | fprintf(stderr, "Could not create ExecutionEngine: %s\n", err.c_str()); | ||
71 | diff --git a/src/cc/frontends/clang/b_frontend_action.cc b/src/cc/frontends/clang/b_frontend_action.cc | ||
72 | index 154a3794..80b03b9b 100644 | ||
73 | --- a/src/cc/frontends/clang/b_frontend_action.cc | ||
74 | +++ b/src/cc/frontends/clang/b_frontend_action.cc | ||
75 | @@ -1694,7 +1694,11 @@ void BFrontendAction::DoMiscWorkAround() { | ||
76 | false); | ||
77 | |||
78 | rewriter_->getEditBuffer(rewriter_->getSourceMgr().getMainFileID()).InsertTextAfter( | ||
79 | +#if LLVM_MAJOR_VERSION >= 12 | ||
80 | + rewriter_->getSourceMgr().getBufferOrFake(rewriter_->getSourceMgr().getMainFileID()).getBufferSize(), | ||
81 | +#else | ||
82 | rewriter_->getSourceMgr().getBuffer(rewriter_->getSourceMgr().getMainFileID())->getBufferSize(), | ||
83 | +#endif | ||
84 | "\n#include <bcc/footer.h>\n"); | ||
85 | } | ||
86 | |||
87 | -- | ||
88 | 2.30.0 | ||
89 | |||
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 @@ | |||
1 | From 35ff839b1b70b3cd7a9a025d0fd96173e7be566e Mon Sep 17 00:00:00 2001 | ||
2 | From: Yonghong Song <yhs@fb.com> | ||
3 | Date: Mon, 4 Jan 2021 19:09:20 -0800 | ||
4 | Subject: [PATCH 2/2] fix compilation error with latest llvm12 trunk | ||
5 | MIME-Version: 1.0 | ||
6 | Content-Type: text/plain; charset=UTF-8 | ||
7 | Content-Transfer-Encoding: 8bit | ||
8 | |||
9 | With latest llvm trunk (llvm12), I hit the following compilation | ||
10 | error: | ||
11 | ... | ||
12 | [ 17%] Building CXX object src/cc/frontends/b/CMakeFiles/b_frontend.dir/codegen_llvm.cc.o | ||
13 | /home/yhs/work/bcc/src/cc/frontends/b/codegen_llvm.cc: In member function | ||
14 | ‘virtual ebpf::StatusTuple ebpf::cc::CodegenLLVM::visit_table_decl_stmt_node(ebpf::cc::TableDeclStmtNode*)’: | ||
15 | /home/yhs/work/bcc/src/cc/frontends/b/codegen_llvm.cc:1122:37: | ||
16 | error: ‘class llvm::Module’ has no member named ‘getTypeB yName’; did you mean ‘getName’? | ||
17 | StructType *decl_struct = mod_->getTypeByName("_struct." + n->id_->name_); | ||
18 | ^~~~~~~~~~~~~ | ||
19 | getName | ||
20 | |||
21 | This is due to llvm patch https://reviews.llvm.org/D78793 which | ||
22 | changed how to use getTypeByName(). This patch adjusted the usage | ||
23 | in bcc based on this patch. | ||
24 | |||
25 | Signed-off-by: Yonghong Song <yhs@fb.com> | ||
26 | --- | ||
27 | src/cc/frontends/b/codegen_llvm.cc | 8 ++++++++ | ||
28 | 1 file changed, 8 insertions(+) | ||
29 | |||
30 | diff --git a/src/cc/frontends/b/codegen_llvm.cc b/src/cc/frontends/b/codegen_llvm.cc | ||
31 | index d8c9470a..71c83b41 100644 | ||
32 | --- a/src/cc/frontends/b/codegen_llvm.cc | ||
33 | +++ b/src/cc/frontends/b/codegen_llvm.cc | ||
34 | @@ -1119,7 +1119,11 @@ StatusTuple CodegenLLVM::visit_table_decl_stmt_node(TableDeclStmtNode *n) { | ||
35 | StructType *key_stype, *leaf_stype; | ||
36 | TRY2(lookup_struct_type(n->key_type_, &key_stype)); | ||
37 | TRY2(lookup_struct_type(n->leaf_type_, &leaf_stype)); | ||
38 | +#if LLVM_MAJOR_VERSION >= 12 | ||
39 | + StructType *decl_struct = StructType::getTypeByName(mod_->getContext(), "_struct." + n->id_->name_); | ||
40 | +#else | ||
41 | StructType *decl_struct = mod_->getTypeByName("_struct." + n->id_->name_); | ||
42 | +#endif | ||
43 | if (!decl_struct) | ||
44 | decl_struct = StructType::create(ctx(), "_struct." + n->id_->name_); | ||
45 | if (decl_struct->isOpaque()) | ||
46 | @@ -1182,7 +1186,11 @@ StatusTuple CodegenLLVM::visit_func_decl_stmt_node(FuncDeclStmtNode *n) { | ||
47 | StructType *stype; | ||
48 | //TRY2(lookup_struct_type(formal, &stype)); | ||
49 | auto var = (StructVariableDeclStmtNode *)formal; | ||
50 | +#if LLVM_MAJOR_VERSION >= 12 | ||
51 | + stype = StructType::getTypeByName(mod_->getContext(), "_struct." + var->struct_id_->name_); | ||
52 | +#else | ||
53 | stype = mod_->getTypeByName("_struct." + var->struct_id_->name_); | ||
54 | +#endif | ||
55 | if (!stype) return mkstatus_(n, "could not find type %s", var->struct_id_->c_str()); | ||
56 | formals.push_back(PointerType::getUnqual(stype)); | ||
57 | } else { | ||
58 | -- | ||
59 | 2.30.0 | ||
60 | |||