1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
From 675fca6a646812361c16884ccd2ff789f40c4ce8 Mon Sep 17 00:00:00 2001
From: Yonghong Song <yhs@fb.com>
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 <yhs@fb.com>
---
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<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());
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<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());
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 <bcc/footer.h>\n");
}
--
2.30.0
|