summaryrefslogtreecommitdiffstats
path: root/dynamic-layers
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2021-02-06 12:19:46 -0800
committerKhem Raj <raj.khem@gmail.com>2021-02-14 00:10:36 -0800
commitfb9efbb0b6366620a16bd7ddacb7d027e938c506 (patch)
tree80e842f5c4568d1818506a40b0d0699b580b67da /dynamic-layers
parent941be6fe7537e78a491b79909292ff7295a8e6f1 (diff)
downloadmeta-clang-fb9efbb0b6366620a16bd7ddacb7d027e938c506.tar.gz
bcc: Fix build with clang-12
bring-in needed patches from upstream Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'dynamic-layers')
-rw-r--r--dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-fix-compilation-issues-with-latest-llvm12-trunk.patch89
-rw-r--r--dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0002-fix-compilation-error-with-latest-llvm12-trunk.patch60
-rw-r--r--dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc_0.17.0.bb2
3 files changed, 151 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 @@
1From 675fca6a646812361c16884ccd2ff789f40c4ce8 Mon Sep 17 00:00:00 2001
2From: Yonghong Song <yhs@fb.com>
3Date: Tue, 3 Nov 2020 22:11:57 -0800
4Subject: [PATCH 1/2] fix compilation issues with latest llvm12 trunk
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9With latest llvm12 trunk, we got two compilation bugs.
10
11Bug #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
23Bug #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
36Signed-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
43diff --git a/src/cc/bpf_module.cc b/src/cc/bpf_module.cc
44index 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());
57diff --git a/src/cc/bpf_module_rw_engine.cc b/src/cc/bpf_module_rw_engine.cc
58index 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());
71diff --git a/src/cc/frontends/clang/b_frontend_action.cc b/src/cc/frontends/clang/b_frontend_action.cc
72index 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--
882.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 @@
1From 35ff839b1b70b3cd7a9a025d0fd96173e7be566e Mon Sep 17 00:00:00 2001
2From: Yonghong Song <yhs@fb.com>
3Date: Mon, 4 Jan 2021 19:09:20 -0800
4Subject: [PATCH 2/2] fix compilation error with latest llvm12 trunk
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9With latest llvm trunk (llvm12), I hit the following compilation
10error:
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
21This is due to llvm patch https://reviews.llvm.org/D78793 which
22changed how to use getTypeByName(). This patch adjusted the usage
23in bcc based on this patch.
24
25Signed-off-by: Yonghong Song <yhs@fb.com>
26---
27 src/cc/frontends/b/codegen_llvm.cc | 8 ++++++++
28 1 file changed, 8 insertions(+)
29
30diff --git a/src/cc/frontends/b/codegen_llvm.cc b/src/cc/frontends/b/codegen_llvm.cc
31index 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--
592.30.0
60
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 \
18 file://0001-python-CMakeLists.txt-Remove-check-for-host-etc-debi.patch \ 18 file://0001-python-CMakeLists.txt-Remove-check-for-host-etc-debi.patch \
19 file://0001-tools-trace.py-Fix-failing-to-exit.patch \ 19 file://0001-tools-trace.py-Fix-failing-to-exit.patch \
20 file://0001-CMakeLists.txt-override-the-PY_CMD_ESCAPED.patch \ 20 file://0001-CMakeLists.txt-override-the-PY_CMD_ESCAPED.patch \
21 file://0001-fix-compilation-issues-with-latest-llvm12-trunk.patch \
22 file://0002-fix-compilation-error-with-latest-llvm12-trunk.patch \
21 " 23 "
22 24
23SRCREV = "ad5b82a5196b222ed2cdc738d8444e8c9546a77f" 25SRCREV = "ad5b82a5196b222ed2cdc738d8444e8c9546a77f"