diff options
author | Ovidiu Panait <ovidiu.panait@windriver.com> | 2020-08-06 12:35:35 +0300 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2020-08-06 10:21:32 -0700 |
commit | edd7e22b0db5bf24ccbdf79557907a66cb615ee0 (patch) | |
tree | d63115daaa77ed13b3e9944f803721dcc049c2cf | |
parent | 0cce4d348dcdd3408e18885a6c32e6f3ac84f7a9 (diff) | |
download | meta-clang-edd7e22b0db5bf24ccbdf79557907a66cb615ee0.tar.gz |
bpftrace: upgrade 0.9.4 -> 0.11.0
Uprev bpftrace to v0.11.0:
* Add patch to fix compilation with LLVM 11
* Add cmake option CMAKE_ENABLE_EXPORTS=1 to prevent stripping, in order to fix
the following error:
root@qemux86-64:~# bpftrace /usr/share/bpftrace/tools/biosnoop.bt
Attaching 4 probes...
Could not resolve symbol: /proc/self/exe:BEGIN_trigger
Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
-rw-r--r-- | dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-bpftrace-Fix-compilation-with-LLVM-11.patch | 276 | ||||
-rw-r--r-- | dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.11.0.bb (renamed from dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.9.4.bb) | 4 |
2 files changed, 279 insertions, 1 deletions
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-bpftrace-Fix-compilation-with-LLVM-11.patch b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-bpftrace-Fix-compilation-with-LLVM-11.patch new file mode 100644 index 0000000..44aac98 --- /dev/null +++ b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-bpftrace-Fix-compilation-with-LLVM-11.patch | |||
@@ -0,0 +1,276 @@ | |||
1 | From 7c9ee9b7054413b6e5f73db6c0ca56e6a7c0504b Mon Sep 17 00:00:00 2001 | ||
2 | From: Ovidiu Panait <ovidiu.panait@windriver.com> | ||
3 | Date: Thu, 6 Aug 2020 10:34:23 +0300 | ||
4 | Subject: [PATCH] irbuilderbpf.cpp, bpforc.h: Fix compilation with LLVM 11 | ||
5 | |||
6 | Fixes: #1384 | ||
7 | |||
8 | Fix the following build errors when compiling with LLVM 11: | ||
9 | |||
10 | #1 | ||
11 | ---- | ||
12 | /llvm/include/llvm/ExecutionEngine/Orc/Legacy.h:118:35: error: no match for call to ‘(bpftrace::BpfOrc::BpfOrc(llvm::TargetMachine*)::<lambda(const string&)>) (llvm::StringRef)’ | ||
13 | 118 | if (JITSymbol Sym = FindSymbol(*S)) { | ||
14 | | ~~~~~~~~~~^~~~ | ||
15 | /llvm/include/llvm/ExecutionEngine/Orc/Legacy.h:118:35: note: candidate: ‘llvm::JITSymbol (*)(const string&)’ {aka ‘llvm::JITSymbol (*)(const std::__cxx11::basic_string<char>&)’} <conversion> | ||
16 | /llvm/include/llvm/ExecutionEngine/Orc/Legacy.h:118:35: note: candidate expects 2 arguments, 2 provided | ||
17 | In file included from /work/src/github.com/iovisor/bpftrace/src/ast/codegen_llvm.cpp:5: | ||
18 | /work/src/github.com/iovisor/bpftrace/src/bpforc.h:99:13: note: candidate: ‘bpftrace::BpfOrc::BpfOrc(llvm::TargetMachine*)::<lambda(const string&)>’ | ||
19 | 99 | [](const std::string &Name __attribute__((unused))) -> JITSymbol { | ||
20 | | ^ | ||
21 | /work/src/github.com/iovisor/bpftrace/src/bpforc.h:99:13: note: no known conversion for argument 1 from ‘llvm::StringRef’ to ‘const string&’ {aka ‘const std::__cxx11::basic_string<char>&’} | ||
22 | In file included from /llvm/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h:23, | ||
23 | |||
24 | #2 | ||
25 | ---- | ||
26 | | /src/ast/irbuilderbpf.cpp: In member function 'llvm::CallInst* bpftrace::ast::IRBuilderBPF::createMapLookup(int, llvm::AllocaInst*)': | ||
27 | | /src/ast/irbuilderbpf.cpp:230:65: error: no matching function for call to 'bpftrace::ast::IRBuilderBPF::CreateCall(llvm::Constant*&, <brace-enclosed initializer list>, const char [12])' | ||
28 | | 230 | return CreateCall(lookup_func, { map_ptr, key }, "lookup_elem"); | ||
29 | | | ^ | ||
30 | | In file included from /src/ast/irbuilderbpf.h:9, | ||
31 | | from /src/ast/async_event_types.h:3, | ||
32 | | from /src/ast/irbuilderbpf.cpp:5: | ||
33 | | /usr/include/llvm/IR/IRBuilder.h:2324:13: note: candidate: 'llvm::CallInst* llvm::IRBuilderBase::CreateCall(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, const llvm::Twine&, llvm::MDNode*)' | ||
34 | | 2324 | CallInst *CreateCall(FunctionType *FTy, Value *Callee, | ||
35 | | | ^~~~~~~~~~ | ||
36 | | /usr/include/llvm/IR/IRBuilder.h:2324:38: note: no known conversion for argument 1 from 'llvm::Constant*' to 'llvm::FunctionType*' | ||
37 | | 2324 | CallInst *CreateCall(FunctionType *FTy, Value *Callee, | ||
38 | | | ~~~~~~~~~~~~~~^~~ | ||
39 | |||
40 | |||
41 | The CreateCall part is based on the llvm 11 fix from bcc: | ||
42 | https://github.com/iovisor/bcc/commit/45e63f2b316cdce2d8cc925f6f14a8726ade9ff6 | ||
43 | |||
44 | Upstream-Status: Submitted [https://github.com/iovisor/bpftrace/pull/1456] | ||
45 | |||
46 | Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com> | ||
47 | --- | ||
48 | src/ast/irbuilderbpf.cpp | 49 ++++++++++++++++++++++++---------------- | ||
49 | src/ast/irbuilderbpf.h | 1 + | ||
50 | src/bpforc.h | 6 +++++ | ||
51 | 3 files changed, 37 insertions(+), 19 deletions(-) | ||
52 | |||
53 | diff --git a/src/ast/irbuilderbpf.cpp b/src/ast/irbuilderbpf.cpp | ||
54 | index 8ae055e6..108c80e4 100644 | ||
55 | --- a/src/ast/irbuilderbpf.cpp | ||
56 | +++ b/src/ast/irbuilderbpf.cpp | ||
57 | @@ -201,10 +201,21 @@ llvm::Type *IRBuilderBPF::GetType(const SizedType &stype) | ||
58 | return ty; | ||
59 | } | ||
60 | |||
61 | +CallInst *IRBuilderBPF::createCall(Value *callee, ArrayRef<Value *> args, const Twine &Name) | ||
62 | +{ | ||
63 | +#if LLVM_VERSION_MAJOR >= 11 | ||
64 | + auto *calleePtrType = cast<PointerType>(callee->getType()); | ||
65 | + auto *calleeType = cast<FunctionType>(calleePtrType->getElementType()); | ||
66 | + return CreateCall(calleeType, callee, args, Name); | ||
67 | +#else | ||
68 | + return CreateCall(callee, args, Name); | ||
69 | +#endif | ||
70 | +} | ||
71 | + | ||
72 | CallInst *IRBuilderBPF::CreateBpfPseudoCall(int mapfd) | ||
73 | { | ||
74 | Function *pseudo_func = module_.getFunction("llvm.bpf.pseudo"); | ||
75 | - return CreateCall(pseudo_func, {getInt64(BPF_PSEUDO_MAP_FD), getInt64(mapfd)}, "pseudo"); | ||
76 | + return createCall(pseudo_func, {getInt64(BPF_PSEUDO_MAP_FD), getInt64(mapfd)}, "pseudo"); | ||
77 | } | ||
78 | |||
79 | CallInst *IRBuilderBPF::CreateBpfPseudoCall(Map &map) | ||
80 | @@ -227,7 +238,7 @@ CallInst *IRBuilderBPF::createMapLookup(int mapfd, AllocaInst *key) | ||
81 | Instruction::IntToPtr, | ||
82 | getInt64(libbpf::BPF_FUNC_map_lookup_elem), | ||
83 | lookup_func_ptr_type); | ||
84 | - return CreateCall(lookup_func, { map_ptr, key }, "lookup_elem"); | ||
85 | + return createCall(lookup_func, { map_ptr, key }, "lookup_elem"); | ||
86 | } | ||
87 | |||
88 | CallInst *IRBuilderBPF::CreateGetJoinMap(Value *ctx, const location &loc) | ||
89 | @@ -325,7 +336,7 @@ void IRBuilderBPF::CreateMapUpdateElem(Value *ctx, | ||
90 | Instruction::IntToPtr, | ||
91 | getInt64(libbpf::BPF_FUNC_map_update_elem), | ||
92 | update_func_ptr_type); | ||
93 | - CallInst *call = CreateCall(update_func, | ||
94 | + CallInst *call = createCall(update_func, | ||
95 | { map_ptr, key, val, flags }, | ||
96 | "update_elem"); | ||
97 | CreateHelperErrorCond(ctx, call, libbpf::BPF_FUNC_map_update_elem, loc); | ||
98 | @@ -349,7 +360,7 @@ void IRBuilderBPF::CreateMapDeleteElem(Value *ctx, | ||
99 | Instruction::IntToPtr, | ||
100 | getInt64(libbpf::BPF_FUNC_map_delete_elem), | ||
101 | delete_func_ptr_type); | ||
102 | - CallInst *call = CreateCall(delete_func, { map_ptr, key }, "delete_elem"); | ||
103 | + CallInst *call = createCall(delete_func, { map_ptr, key }, "delete_elem"); | ||
104 | CreateHelperErrorCond(ctx, call, libbpf::BPF_FUNC_map_delete_elem, loc); | ||
105 | } | ||
106 | |||
107 | @@ -378,7 +389,7 @@ void IRBuilderBPF::CreateProbeRead(Value *ctx, | ||
108 | Instruction::IntToPtr, | ||
109 | getInt64(libbpf::BPF_FUNC_probe_read), | ||
110 | proberead_func_ptr_type); | ||
111 | - CallInst *call = CreateCall(proberead_func, { dst, size, src }, "probe_read"); | ||
112 | + CallInst *call = createCall(proberead_func, { dst, size, src }, "probe_read"); | ||
113 | CreateHelperErrorCond(ctx, call, libbpf::BPF_FUNC_probe_read, loc); | ||
114 | } | ||
115 | |||
116 | @@ -413,7 +424,7 @@ CallInst *IRBuilderBPF::CreateProbeReadStr(Value *ctx, | ||
117 | { | ||
118 | assert(ctx && ctx->getType() == getInt8PtrTy()); | ||
119 | Constant *fn = createProbeReadStrFn(dst->getType(), src->getType()); | ||
120 | - CallInst *call = CreateCall(fn, | ||
121 | + CallInst *call = createCall(fn, | ||
122 | { dst, getInt32(size), src }, | ||
123 | "probe_read_str"); | ||
124 | CreateHelperErrorCond(ctx, call, libbpf::BPF_FUNC_probe_read_str, loc); | ||
125 | @@ -434,7 +445,7 @@ CallInst *IRBuilderBPF::CreateProbeReadStr(Value *ctx, | ||
126 | auto *size_i32 = CreateIntCast(size, getInt32Ty(), false); | ||
127 | |||
128 | Constant *fn = createProbeReadStrFn(dst->getType(), src->getType()); | ||
129 | - CallInst *call = CreateCall(fn, { dst, size_i32, src }, "probe_read_str"); | ||
130 | + CallInst *call = createCall(fn, { dst, size_i32, src }, "probe_read_str"); | ||
131 | CreateHelperErrorCond(ctx, call, libbpf::BPF_FUNC_probe_read_str, loc); | ||
132 | return call; | ||
133 | } | ||
134 | @@ -717,7 +728,7 @@ CallInst *IRBuilderBPF::CreateGetNs() | ||
135 | Instruction::IntToPtr, | ||
136 | getInt64(libbpf::BPF_FUNC_ktime_get_ns), | ||
137 | gettime_func_ptr_type); | ||
138 | - return CreateCall(gettime_func, {}, "get_ns"); | ||
139 | + return createCall(gettime_func, {}, "get_ns"); | ||
140 | } | ||
141 | |||
142 | CallInst *IRBuilderBPF::CreateGetPidTgid() | ||
143 | @@ -730,7 +741,7 @@ CallInst *IRBuilderBPF::CreateGetPidTgid() | ||
144 | Instruction::IntToPtr, | ||
145 | getInt64(libbpf::BPF_FUNC_get_current_pid_tgid), | ||
146 | getpidtgid_func_ptr_type); | ||
147 | - return CreateCall(getpidtgid_func, {}, "get_pid_tgid"); | ||
148 | + return createCall(getpidtgid_func, {}, "get_pid_tgid"); | ||
149 | } | ||
150 | |||
151 | CallInst *IRBuilderBPF::CreateGetCurrentCgroupId() | ||
152 | @@ -744,7 +755,7 @@ CallInst *IRBuilderBPF::CreateGetCurrentCgroupId() | ||
153 | Instruction::IntToPtr, | ||
154 | getInt64(libbpf::BPF_FUNC_get_current_cgroup_id), | ||
155 | getcgroupid_func_ptr_type); | ||
156 | - return CreateCall(getcgroupid_func, {}, "get_cgroup_id"); | ||
157 | + return createCall(getcgroupid_func, {}, "get_cgroup_id"); | ||
158 | } | ||
159 | |||
160 | CallInst *IRBuilderBPF::CreateGetUidGid() | ||
161 | @@ -757,7 +768,7 @@ CallInst *IRBuilderBPF::CreateGetUidGid() | ||
162 | Instruction::IntToPtr, | ||
163 | getInt64(libbpf::BPF_FUNC_get_current_uid_gid), | ||
164 | getuidgid_func_ptr_type); | ||
165 | - return CreateCall(getuidgid_func, {}, "get_uid_gid"); | ||
166 | + return createCall(getuidgid_func, {}, "get_uid_gid"); | ||
167 | } | ||
168 | |||
169 | CallInst *IRBuilderBPF::CreateGetCpuId() | ||
170 | @@ -770,7 +781,7 @@ CallInst *IRBuilderBPF::CreateGetCpuId() | ||
171 | Instruction::IntToPtr, | ||
172 | getInt64(libbpf::BPF_FUNC_get_smp_processor_id), | ||
173 | getcpuid_func_ptr_type); | ||
174 | - return CreateCall(getcpuid_func, {}, "get_cpu_id"); | ||
175 | + return createCall(getcpuid_func, {}, "get_cpu_id"); | ||
176 | } | ||
177 | |||
178 | CallInst *IRBuilderBPF::CreateGetCurrentTask() | ||
179 | @@ -783,7 +794,7 @@ CallInst *IRBuilderBPF::CreateGetCurrentTask() | ||
180 | Instruction::IntToPtr, | ||
181 | getInt64(libbpf::BPF_FUNC_get_current_task), | ||
182 | getcurtask_func_ptr_type); | ||
183 | - return CreateCall(getcurtask_func, {}, "get_cur_task"); | ||
184 | + return createCall(getcurtask_func, {}, "get_cur_task"); | ||
185 | } | ||
186 | |||
187 | CallInst *IRBuilderBPF::CreateGetRandom() | ||
188 | @@ -796,7 +807,7 @@ CallInst *IRBuilderBPF::CreateGetRandom() | ||
189 | Instruction::IntToPtr, | ||
190 | getInt64(libbpf::BPF_FUNC_get_prandom_u32), | ||
191 | getrandom_func_ptr_type); | ||
192 | - return CreateCall(getrandom_func, {}, "get_random"); | ||
193 | + return createCall(getrandom_func, {}, "get_random"); | ||
194 | } | ||
195 | |||
196 | CallInst *IRBuilderBPF::CreateGetStackId(Value *ctx, | ||
197 | @@ -826,7 +837,7 @@ CallInst *IRBuilderBPF::CreateGetStackId(Value *ctx, | ||
198 | Instruction::IntToPtr, | ||
199 | getInt64(libbpf::BPF_FUNC_get_stackid), | ||
200 | getstackid_func_ptr_type); | ||
201 | - CallInst *call = CreateCall(getstackid_func, | ||
202 | + CallInst *call = createCall(getstackid_func, | ||
203 | { ctx, map_ptr, flags_val }, | ||
204 | "get_stackid"); | ||
205 | CreateHelperErrorCond(ctx, call, libbpf::BPF_FUNC_get_stackid, loc); | ||
206 | @@ -852,7 +863,7 @@ void IRBuilderBPF::CreateGetCurrentComm(Value *ctx, | ||
207 | Instruction::IntToPtr, | ||
208 | getInt64(libbpf::BPF_FUNC_get_current_comm), | ||
209 | getcomm_func_ptr_type); | ||
210 | - CallInst *call = CreateCall(getcomm_func, | ||
211 | + CallInst *call = createCall(getcomm_func, | ||
212 | { buf, getInt64(size) }, | ||
213 | "get_comm"); | ||
214 | CreateHelperErrorCond(ctx, call, libbpf::BPF_FUNC_get_current_comm, loc); | ||
215 | @@ -883,7 +894,7 @@ void IRBuilderBPF::CreatePerfEventOutput(Value *ctx, Value *data, size_t size) | ||
216 | Instruction::IntToPtr, | ||
217 | getInt64(libbpf::BPF_FUNC_perf_event_output), | ||
218 | perfoutput_func_ptr_type); | ||
219 | - CreateCall(perfoutput_func, {ctx, map_ptr, flags_val, data, size_val}, "perf_event_output"); | ||
220 | + createCall(perfoutput_func, {ctx, map_ptr, flags_val, data, size_val}, "perf_event_output"); | ||
221 | } | ||
222 | |||
223 | void IRBuilderBPF::CreateSignal(Value *ctx, Value *sig, const location &loc) | ||
224 | @@ -899,7 +910,7 @@ void IRBuilderBPF::CreateSignal(Value *ctx, Value *sig, const location &loc) | ||
225 | Instruction::IntToPtr, | ||
226 | getInt64(libbpf::BPF_FUNC_send_signal), | ||
227 | signal_func_ptr_type); | ||
228 | - CallInst *call = CreateCall(signal_func, { sig }, "signal"); | ||
229 | + CallInst *call = createCall(signal_func, { sig }, "signal"); | ||
230 | CreateHelperErrorCond(ctx, call, libbpf::BPF_FUNC_send_signal, loc); | ||
231 | } | ||
232 | |||
233 | @@ -913,7 +924,7 @@ void IRBuilderBPF::CreateOverrideReturn(Value *ctx, Value *rc) | ||
234 | Constant *override_func = ConstantExpr::getCast(Instruction::IntToPtr, | ||
235 | getInt64(libbpf::BPF_FUNC_override_return), | ||
236 | override_func_ptr_type); | ||
237 | - CreateCall(override_func, { ctx, rc }, "override"); | ||
238 | + createCall(override_func, { ctx, rc }, "override"); | ||
239 | } | ||
240 | |||
241 | Value *IRBuilderBPF::CreatKFuncArg(Value *ctx, | ||
242 | diff --git a/src/ast/irbuilderbpf.h b/src/ast/irbuilderbpf.h | ||
243 | index d4361a8f..31115079 100644 | ||
244 | --- a/src/ast/irbuilderbpf.h | ||
245 | +++ b/src/ast/irbuilderbpf.h | ||
246 | @@ -80,6 +80,7 @@ public: | ||
247 | CallInst *CreateGetRandom(); | ||
248 | CallInst *CreateGetStackId(Value *ctx, bool ustack, StackType stack_type, const location& loc); | ||
249 | CallInst *CreateGetJoinMap(Value *ctx, const location& loc); | ||
250 | + CallInst *createCall(Value *callee, ArrayRef<Value *> args, const Twine &Name); | ||
251 | void CreateGetCurrentComm(Value *ctx, AllocaInst *buf, size_t size, const location& loc); | ||
252 | void CreatePerfEventOutput(Value *ctx, Value *data, size_t size); | ||
253 | void CreateSignal(Value *ctx, Value *sig, const location &loc); | ||
254 | diff --git a/src/bpforc.h b/src/bpforc.h | ||
255 | index a42e031a..d75f984f 100644 | ||
256 | --- a/src/bpforc.h | ||
257 | +++ b/src/bpforc.h | ||
258 | @@ -96,9 +96,15 @@ public: | ||
259 | : TM(TM_), | ||
260 | Resolver(createLegacyLookupResolver( | ||
261 | ES, | ||
262 | +#if LLVM_VERSION_MAJOR >= 11 | ||
263 | + [](llvm::StringRef Name __attribute__((unused))) -> JITSymbol { | ||
264 | + return nullptr; | ||
265 | + }, | ||
266 | +#else | ||
267 | [](const std::string &Name __attribute__((unused))) -> JITSymbol { | ||
268 | return nullptr; | ||
269 | }, | ||
270 | +#endif | ||
271 | [](Error Err) { cantFail(std::move(Err), "lookup failed"); })), | ||
272 | #if LLVM_VERSION_MAJOR > 8 | ||
273 | ObjectLayer(AcknowledgeORCv1Deprecation, | ||
274 | -- | ||
275 | 2.17.1 | ||
276 | |||
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.9.4.bb b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.11.0.bb index ad044fd..0365f05 100644 --- a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.9.4.bb +++ b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.11.0.bb | |||
@@ -13,14 +13,16 @@ DEPENDS += "bison-native \ | |||
13 | RDEPENDS_${PN} += "bash python3 xz" | 13 | RDEPENDS_${PN} += "bash python3 xz" |
14 | 14 | ||
15 | SRC_URI = "git://github.com/iovisor/bpftrace \ | 15 | SRC_URI = "git://github.com/iovisor/bpftrace \ |
16 | file://0001-bpftrace-Fix-compilation-with-LLVM-11.patch \ | ||
16 | " | 17 | " |
17 | SRCREV = "b1200771b61fd77ed7c5b326e7960d24514dd961" | 18 | SRCREV = "a9ba414ea8212e825cd48ac536aba66af76c0cfc" |
18 | 19 | ||
19 | S = "${WORKDIR}/git" | 20 | S = "${WORKDIR}/git" |
20 | 21 | ||
21 | inherit cmake | 22 | inherit cmake |
22 | 23 | ||
23 | EXTRA_OECMAKE = " \ | 24 | EXTRA_OECMAKE = " \ |
25 | -DCMAKE_ENABLE_EXPORTS=1 \ | ||
24 | -DCMAKE_BUILD_TYPE=Release \ | 26 | -DCMAKE_BUILD_TYPE=Release \ |
25 | -DBUILD_TESTING=OFF \ | 27 | -DBUILD_TESTING=OFF \ |
26 | " | 28 | " |