summaryrefslogtreecommitdiffstats
path: root/dynamic-layers/meta-python
diff options
context:
space:
mode:
authorArchana Polampalli <archana.polampalli@windriver.com>2025-06-06 11:21:28 +0530
committerKhem Raj <raj.khem@gmail.com>2025-06-20 13:00:12 -0700
commit525625cb266c8a6ea9a4ddedabf935c825d38510 (patch)
treedda3815e4a9da62eb2b84fd693c813005c20f7a4 /dynamic-layers/meta-python
parenteaa08939eaec9f620b14742ff3ac568553683034 (diff)
downloadmeta-clang-525625cb266c8a6ea9a4ddedabf935c825d38510.tar.gz
bpftrace: move from dynamic-layers/openembedded-layer to dynamic-layers/meta-python
* bpftrace itself doesn't depend on meta-python, but bpftrace from dynamic-layers/openembedded-layer depends on bcc from dynamic-layers/meta-python so better to move it there. This way both bcc and bpftrace are either both available at the same time or neither of them. * fixes https://github.com/kraj/meta-clang/issues/985 ERROR: Nothing PROVIDES 'bcc' (but /mnt/secondary/poky/meta-clang/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.20.1.bb DEPENDS on or otherwise requires it). Close matches: bc byacc NOTE: Runtime target 'bpftrace' is unbuildable, removing... Missing or unbuildable dependency chain was: ['bpftrace', 'bcc'] ERROR: Required build target 'core-image-minimal' has no buildable providers. Missing or unbuildable dependency chain was: ['core-image-minimal', 'bpftrace', 'bcc'] when only openembedded-layer (meta-oe) is in BBLAYERS and meta-python isn't. Signed-off-by: Martin Jansa <martin.jansa@gmail.com> Signed-off-by: Archana Polampalli <archana.polampalli@windriver.com>
Diffstat (limited to 'dynamic-layers/meta-python')
-rw-r--r--dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/0001-replace-python-with-python3-in-the-test.patch53
-rw-r--r--dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/0001-use-64bit-alignment-for-map-counter-atomic-add.patch49
-rw-r--r--dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/0002-ast-Repace-getInt8PtrTy-with-getPtrTy.patch338
-rw-r--r--dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/0003-ast-Adjust-to-enum-changes-in-llvm-18.patch41
-rw-r--r--dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/0004-cmake-Bump-max-LLVM-version-to-18.patch27
-rw-r--r--dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/run-ptest51
-rw-r--r--dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace_0.20.1.bb65
7 files changed, 624 insertions, 0 deletions
diff --git a/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/0001-replace-python-with-python3-in-the-test.patch b/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/0001-replace-python-with-python3-in-the-test.patch
new file mode 100644
index 0000000..4438716
--- /dev/null
+++ b/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/0001-replace-python-with-python3-in-the-test.patch
@@ -0,0 +1,53 @@
1From 62319459e7ef14a37293bc10830b52edf89daabe Mon Sep 17 00:00:00 2001
2From: Wentao Zhang <wentao.zhang@windriver.com>
3Date: Tue, 15 Aug 2023 11:18:36 +0800
4Subject: [PATCH 1/4] replace python with python3 in the test
5
6"runtime:call" in ptest gets the following FAILED:
7python: No such file or directory
8replace python with python3 in the test scripts.
9
10$export BPFTRACE_RUNTIME_TEST_EXECUTABLE=/usr/bin
11$cd /usr/lib/bpftrace/ptest/tests
12$python3 runtime/engine/main.py --filter="call.*"
13***
14[ RUN ] call.strftime_microsecond_extension_rollover
15[ FAILED ] call.strftime_microsecond_extension_rollover
16 Command: /usr/bin/bpftrace -e 'BEGIN { printf("%s - %s\n", strftime
17 ("1%f", 1000000123000), strftime("1%f", 0)); exit(); }' | tail -n
18 +2 | xargs -I{} python -c "print({})"
19 Unclean exit code: 127
20 Output: __BPFTRACE_NOTIFY_PROBES_ATTACHED\nxargs: python: No such
21 file or directory\n
22***
23
24Upstream-Status: Submitted [https://github.com/bpftrace/bpftrace/pull/3009]
25
26Signed-off-by: Wentao Zhang <wentao.zhang@windriver.com>
27---
28 tests/runtime/call | 4 ++--
29 1 file changed, 2 insertions(+), 2 deletions(-)
30
31diff --git a/tests/runtime/call b/tests/runtime/call
32index 7f7cce6d..174bce95 100644
33--- a/tests/runtime/call
34+++ b/tests/runtime/call
35@@ -371,13 +371,13 @@ TIMEOUT 5
36 #
37 # Note we add a `1` before the timestamp b/c leading zeros (eg `0123`) is invalid integer in python.
38 NAME strftime_microsecond_extension
39-RUN {{BPFTRACE}} -e 'BEGIN { printf("%s - %s\n", strftime("1%f", 1000123000), strftime("1%f", 0)); exit(); }' | tail -n +2 | xargs -I{} python -c "print({})"
40+RUN {{BPFTRACE}} -e 'BEGIN { printf("%s - %s\n", strftime("1%f", 1000123000), strftime("1%f", 0)); exit(); }' | tail -n +2 | xargs -I{} python3 -c "print({})"
41 EXPECT 123
42 TIMEOUT 1
43
44 # Similar to above test but test that rolling over past 1s works as expected
45 NAME strftime_microsecond_extension_rollover
46-RUN {{BPFTRACE}} -e 'BEGIN { printf("%s - %s\n", strftime("1%f", 1000000123000), strftime("1%f", 0)); exit(); }' | tail -n +2 | xargs -I{} python -c "print({})"
47+RUN {{BPFTRACE}} -e 'BEGIN { printf("%s - %s\n", strftime("1%f", 1000000123000), strftime("1%f", 0)); exit(); }' | tail -n +2 | xargs -I{} python3 -c "print({})"
48 EXPECT 123
49 TIMEOUT 1
50
51--
522.43.2
53
diff --git a/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/0001-use-64bit-alignment-for-map-counter-atomic-add.patch b/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/0001-use-64bit-alignment-for-map-counter-atomic-add.patch
new file mode 100644
index 0000000..49938a1
--- /dev/null
+++ b/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/0001-use-64bit-alignment-for-map-counter-atomic-add.patch
@@ -0,0 +1,49 @@
1From 76538f80d3c56430c3105b6a3a7614313b01ddc5 Mon Sep 17 00:00:00 2001
2From: Frank van der Linden <fvdl@google.com>
3Date: Mon, 11 Mar 2024 15:35:32 +0000
4Subject: [PATCH] use 64bit alignment for map counter atomic add
5
6For an atomic inc of a map counter (ringbuf loss counter), generate
7IR with 64bit alignment. This is more correct, and will avoid problems
8with upcoming LLVM versions, as they will emit a function call for
9a potentially unaligned atomicrmw. This will lead to an error like this:
10
11error: <unknown>:0:0: in function BEGIN i64 (ptr): t15: i64 = GlobalAddress<ptr @__atomic_compare_exchange> 0 too many arguments
12
13Upstream-Status: Backport [https://github.com/bpftrace/bpftrace/pull/3045/commits/3878a437ca946ab69cc92bcd2cb3c2369625b3dc]
14
15Signed-off-by: Wentao Zhang <wentao.zhang@windriver.com>
16---
17 CHANGELOG.md | 2 ++
18 src/ast/irbuilderbpf.cpp | 2 +-
19 2 files changed, 3 insertions(+), 1 deletion(-)
20
21diff --git a/CHANGELOG.md b/CHANGELOG.md
22index 4fa3b673..81b6e0e2 100644
23--- a/CHANGELOG.md
24+++ b/CHANGELOG.md
25@@ -19,6 +19,8 @@ and this project adheres to
26 #### Fixed
27 - Fix field resolution on structs with anon union as first field
28 - [#2964](https://github.com/bpftrace/bpftrace/pull/2964)
29+- Fix alignment of atomic map counter update
30+ - [#3045](https://github.com/bpftrace/bpftrace/pull/3045)
31 #### Docs
32 #### Tools
33
34diff --git a/src/ast/irbuilderbpf.cpp b/src/ast/irbuilderbpf.cpp
35index 2ff3c0ce..98c4b0d5 100644
36--- a/src/ast/irbuilderbpf.cpp
37+++ b/src/ast/irbuilderbpf.cpp
38@@ -1474,7 +1474,7 @@ void IRBuilderBPF::CreateAtomicIncCounter(const std::string &map_name,
39 CREATE_ATOMIC_RMW(AtomicRMWInst::BinOp::Add,
40 val,
41 getInt64(1),
42- 1,
43+ 8,
44 AtomicOrdering::SequentiallyConsistent);
45 CreateBr(lookup_merge_block);
46
47--
482.35.5
49
diff --git a/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/0002-ast-Repace-getInt8PtrTy-with-getPtrTy.patch b/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/0002-ast-Repace-getInt8PtrTy-with-getPtrTy.patch
new file mode 100644
index 0000000..9167963
--- /dev/null
+++ b/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/0002-ast-Repace-getInt8PtrTy-with-getPtrTy.patch
@@ -0,0 +1,338 @@
1From 441f38a0fa9711a08ca8d904b542559593bffb16 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 16 Feb 2024 10:32:27 -0800
4Subject: [PATCH 2/4] ast: Repace getInt8PtrTy with getPtrTy
5
6getPtrTy is added in LLVM-15 and is to be used instead of getInt8PtrTy
7which is gone in LLVM-18 onwards
8
9https://github.com/llvm/llvm-project/commit/7e0802aeb5b90
10
11Upstream-Status: Submitted [https://github.com/bpftrace/bpftrace/pull/3009]
12Signed-off-by: Khem Raj <raj.khem@gmail.com>
13---
14 src/ast/irbuilderbpf.cpp | 58 ++++++++++++++++-----------------
15 src/ast/passes/codegen_llvm.cpp | 22 ++++++-------
16 2 files changed, 40 insertions(+), 40 deletions(-)
17
18diff --git a/src/ast/irbuilderbpf.cpp b/src/ast/irbuilderbpf.cpp
19index 670a9e98..2ff3c0ce 100644
20--- a/src/ast/irbuilderbpf.cpp
21+++ b/src/ast/irbuilderbpf.cpp
22@@ -301,7 +301,7 @@ CallInst *IRBuilderBPF::createMapLookup(const std::string &map_name,
23 Value *key,
24 const std::string &name)
25 {
26- return createMapLookup(map_name, key, getInt8PtrTy(), name);
27+ return createMapLookup(map_name, key, getPtrTy(), name);
28 }
29
30 CallInst *IRBuilderBPF::createMapLookup(const std::string &map_name,
31@@ -329,7 +329,7 @@ CallInst *IRBuilderBPF::CreateGetJoinMap(BasicBlock *failure_callback,
32 {
33 return createGetScratchMap(to_string(MapManager::Type::Join),
34 "join",
35- getInt8PtrTy(),
36+ getPtrTy(),
37 loc,
38 failure_callback);
39 }
40@@ -358,8 +358,8 @@ CallInst *IRBuilderBPF::createGetScratchMap(const std::string &map_name,
41 BasicBlock *lookup_merge_block = BasicBlock::Create(
42 module_.getContext(), "lookup_" + name + "_merge", parent);
43 Value *condition = CreateICmpNE(
44- CreateIntCast(call, getInt8PtrTy(), true),
45- ConstantExpr::getCast(Instruction::IntToPtr, getInt64(0), getInt8PtrTy()),
46+ CreateIntCast(call, getPtrTy(), true),
47+ ConstantExpr::getCast(Instruction::IntToPtr, getInt64(0), getPtrTy()),
48 "lookup_" + name + "_cond");
49 CreateCondBr(condition, lookup_merge_block, lookup_failure_block);
50
51@@ -379,7 +379,7 @@ Value *IRBuilderBPF::CreateMapLookupElem(Value *ctx,
52 Value *key,
53 const location &loc)
54 {
55- assert(ctx && ctx->getType() == getInt8PtrTy());
56+ assert(ctx && ctx->getType() == getPtrTy());
57 return CreateMapLookupElem(ctx, map.ident, key, map.type, loc);
58 }
59
60@@ -389,7 +389,7 @@ Value *IRBuilderBPF::CreateMapLookupElem(Value *ctx,
61 SizedType &type,
62 const location &loc)
63 {
64- assert(ctx && ctx->getType() == getInt8PtrTy());
65+ assert(ctx && ctx->getType() == getPtrTy());
66 CallInst *call = createMapLookup(map_name, key);
67
68 // Check if result == 0
69@@ -406,8 +406,8 @@ Value *IRBuilderBPF::CreateMapLookupElem(Value *ctx,
70
71 AllocaInst *value = CreateAllocaBPF(type, "lookup_elem_val");
72 Value *condition = CreateICmpNE(
73- CreateIntCast(call, getInt8PtrTy(), true),
74- ConstantExpr::getCast(Instruction::IntToPtr, getInt64(0), getInt8PtrTy()),
75+ CreateIntCast(call, getPtrTy(), true),
76+ ConstantExpr::getCast(Instruction::IntToPtr, getInt64(0), getPtrTy()),
77 "map_lookup_cond");
78 CreateCondBr(condition, lookup_success_block, lookup_failure_block);
79
80@@ -449,7 +449,7 @@ void IRBuilderBPF::CreateMapUpdateElem(Value *ctx,
81 {
82 Value *map_ptr = GetMapVar(map.ident);
83
84- assert(ctx && ctx->getType() == getInt8PtrTy());
85+ assert(ctx && ctx->getType() == getPtrTy());
86 assert(key->getType()->isPointerTy());
87 assert(val->getType()->isPointerTy());
88
89@@ -478,7 +478,7 @@ void IRBuilderBPF::CreateMapDeleteElem(Value *ctx,
90 Value *key,
91 const location &loc)
92 {
93- assert(ctx && ctx->getType() == getInt8PtrTy());
94+ assert(ctx && ctx->getType() == getPtrTy());
95 assert(key->getType()->isPointerTy());
96 Value *map_ptr = GetMapVar(map.ident);
97
98@@ -541,7 +541,7 @@ void IRBuilderBPF::CreateProbeRead(Value *ctx,
99 AddrSpace as,
100 const location &loc)
101 {
102- assert(ctx && ctx->getType() == getInt8PtrTy());
103+ assert(ctx && ctx->getType() == getPtrTy());
104 assert(size && size->getType()->getIntegerBitWidth() <= 32);
105 size = CreateIntCast(size, getInt32Ty(), false);
106
107@@ -581,7 +581,7 @@ CallInst *IRBuilderBPF::CreateProbeReadStr(Value *ctx,
108 AddrSpace as,
109 const location &loc)
110 {
111- assert(ctx && ctx->getType() == getInt8PtrTy());
112+ assert(ctx && ctx->getType() == getPtrTy());
113 assert(size && size->getType()->isIntegerTy());
114 if ([[maybe_unused]] auto *dst_alloca = dyn_cast<AllocaInst>(dst)) {
115 assert(dst_alloca->getAllocatedType()->isArrayTy() &&
116@@ -615,7 +615,7 @@ Value *IRBuilderBPF::CreateUSDTReadArgument(Value *ctx,
117 AddrSpace as,
118 const location &loc)
119 {
120- assert(ctx && ctx->getType() == getInt8PtrTy());
121+ assert(ctx && ctx->getType() == getPtrTy());
122 // Argument size must be 1, 2, 4, or 8. See
123 // https://sourceware.org/systemtap/wiki/UserSpaceProbeImplementation
124 int abs_size = std::abs(argument->size);
125@@ -711,7 +711,7 @@ Value *IRBuilderBPF::CreateUSDTReadArgument(Value *ctx,
126 AddrSpace as,
127 const location &loc)
128 {
129- assert(ctx && ctx->getType() == getInt8PtrTy());
130+ assert(ctx && ctx->getType() == getPtrTy());
131 struct bcc_usdt_argument argument;
132
133 void *usdt;
134@@ -1337,7 +1337,7 @@ CallInst *IRBuilderBPF::CreateGetStackId(Value *ctx,
135 StackType stack_type,
136 const location &loc)
137 {
138- assert(ctx && ctx->getType() == getInt8PtrTy());
139+ assert(ctx && ctx->getType() == getPtrTy());
140
141 Value *map_ptr = GetMapVar(stack_type.name());
142
143@@ -1350,7 +1350,7 @@ CallInst *IRBuilderBPF::CreateGetStackId(Value *ctx,
144 // Return: >= 0 stackid on success or negative error
145 FunctionType *getstackid_func_type = FunctionType::get(
146 getInt64Ty(),
147- { getInt8PtrTy(), map_ptr->getType(), getInt64Ty() },
148+ { getPtrTy(), map_ptr->getType(), getInt64Ty() },
149 false);
150 CallInst *call = CreateHelperCall(libbpf::BPF_FUNC_get_stackid,
151 getstackid_func_type,
152@@ -1399,7 +1399,7 @@ void IRBuilderBPF::CreateOutput(Value *ctx,
153 size_t size,
154 const location *loc)
155 {
156- assert(ctx && ctx->getType() == getInt8PtrTy());
157+ assert(ctx && ctx->getType() == getPtrTy());
158 assert(data && data->getType()->isPointerTy());
159
160 if (bpftrace_.feature_->has_map_ringbuf()) {
161@@ -1464,8 +1464,8 @@ void IRBuilderBPF::CreateAtomicIncCounter(const std::string &map_name,
162 parent);
163
164 Value *condition = CreateICmpNE(
165- CreateIntCast(call, getInt8PtrTy(), true),
166- ConstantExpr::getCast(Instruction::IntToPtr, getInt64(0), getInt8PtrTy()),
167+ CreateIntCast(call, getPtrTy(), true),
168+ ConstantExpr::getCast(Instruction::IntToPtr, getInt64(0), getPtrTy()),
169 "map_lookup_cond");
170 CreateCondBr(condition, lookup_success_block, lookup_failure_block);
171
172@@ -1521,8 +1521,8 @@ void IRBuilderBPF::CreateMapElemAdd(Value *ctx,
173
174 AllocaInst *value = CreateAllocaBPF(type, "lookup_elem_val");
175 Value *condition = CreateICmpNE(
176- CreateIntCast(call, getInt8PtrTy(), true),
177- ConstantExpr::getCast(Instruction::IntToPtr, getInt64(0), getInt8PtrTy()),
178+ CreateIntCast(call, getPtrTy(), true),
179+ ConstantExpr::getCast(Instruction::IntToPtr, getInt64(0), getPtrTy()),
180 "map_lookup_cond");
181 CreateCondBr(condition, lookup_success_block, lookup_failure_block);
182
183@@ -1557,7 +1557,7 @@ void IRBuilderBPF::CreatePerfEventOutput(Value *ctx,
184 // long bpf_perf_event_output(struct pt_regs *ctx, struct bpf_map *map,
185 // u64 flags, void *data, u64 size)
186 FunctionType *perfoutput_func_type = FunctionType::get(getInt64Ty(),
187- { getInt8PtrTy(),
188+ { getPtrTy(),
189 map_ptr->getType(),
190 getInt64Ty(),
191 data->getType(),
192@@ -1600,7 +1600,7 @@ void IRBuilderBPF::CreateTracePrintk(Value *fmt_ptr,
193
194 // long bpf_trace_printk(const char *fmt, u32 fmt_size, ...)
195 FunctionType *traceprintk_func_type = FunctionType::get(
196- getInt64Ty(), { getInt8PtrTy(), getInt32Ty() }, true);
197+ getInt64Ty(), { getPtrTy(), getInt32Ty() }, true);
198
199 CreateHelperCall(libbpf::BPF_FUNC_trace_printk,
200 traceprintk_func_type,
201@@ -1630,7 +1630,7 @@ void IRBuilderBPF::CreateOverrideReturn(Value *ctx, Value *rc)
202 // long bpf_override_return(struct pt_regs *regs, u64 rc)
203 // Return: 0
204 FunctionType *override_func_type = FunctionType::get(
205- getInt64Ty(), { getInt8PtrTy(), getInt64Ty() }, false);
206+ getInt64Ty(), { getPtrTy(), getInt64Ty() }, false);
207 PointerType *override_func_ptr_type = PointerType::get(override_func_type, 0);
208 Constant *override_func = ConstantExpr::getCast(
209 Instruction::IntToPtr,
210@@ -1807,7 +1807,7 @@ void IRBuilderBPF::CreateHelperError(Value *ctx,
211 libbpf::bpf_func_id func_id,
212 const location &loc)
213 {
214- assert(ctx && ctx->getType() == getInt8PtrTy());
215+ assert(ctx && ctx->getType() == getPtrTy());
216 assert(return_value && return_value->getType() == getInt32Ty());
217
218 if (bpftrace_.helper_check_level_ == 0 ||
219@@ -1847,7 +1847,7 @@ void IRBuilderBPF::CreateHelperErrorCond(Value *ctx,
220 const location &loc,
221 bool compare_zero)
222 {
223- assert(ctx && ctx->getType() == getInt8PtrTy());
224+ assert(ctx && ctx->getType() == getPtrTy());
225 if (bpftrace_.helper_check_level_ == 0 ||
226 (bpftrace_.helper_check_level_ == 1 && return_zero_if_err(func_id)))
227 return;
228@@ -1883,7 +1883,7 @@ void IRBuilderBPF::CreatePath(Value *ctx,
229 // int bpf_d_path(struct path *path, char *buf, u32 sz)
230 // Return: 0 or error
231 FunctionType *d_path_func_type = FunctionType::get(
232- getInt64Ty(), { getInt8PtrTy(), buf->getType(), getInt32Ty() }, false);
233+ getInt64Ty(), { getPtrTy(), buf->getType(), getInt32Ty() }, false);
234 CallInst *call = CreateHelperCall(
235 libbpf::bpf_func_id::BPF_FUNC_d_path,
236 d_path_func_type,
237@@ -1905,9 +1905,9 @@ void IRBuilderBPF::CreateSeqPrintf(Value *ctx,
238 // Return: 0 or error
239 FunctionType *seq_printf_func_type = FunctionType::get(getInt64Ty(),
240 { getInt64Ty(),
241- getInt8PtrTy(),
242+ getPtrTy(),
243 getInt32Ty(),
244- getInt8PtrTy(),
245+ getPtrTy(),
246 getInt32Ty() },
247 false);
248 PointerType *seq_printf_func_ptr_type = PointerType::get(seq_printf_func_type,
249diff --git a/src/ast/passes/codegen_llvm.cpp b/src/ast/passes/codegen_llvm.cpp
250index 073d48ae..258b0b0b 100644
251--- a/src/ast/passes/codegen_llvm.cpp
252+++ b/src/ast/passes/codegen_llvm.cpp
253@@ -380,10 +380,10 @@ void CodegenLLVM::visit(Call &call)
254
255 AllocaInst *value = b_.CreateAllocaBPF(type, "lookup_elem_val");
256 Value *condition = b_.CreateICmpNE(
257- b_.CreateIntCast(lookup, b_.getInt8PtrTy(), true),
258+ b_.CreateIntCast(lookup, b_.getPtrTy(), true),
259 ConstantExpr::getCast(Instruction::IntToPtr,
260 b_.getInt64(0),
261- b_.getInt8PtrTy()),
262+ b_.getPtrTy()),
263 "map_lookup_cond");
264 b_.CreateCondBr(condition, lookup_success_block, lookup_failure_block);
265
266@@ -437,10 +437,10 @@ void CodegenLLVM::visit(Call &call)
267
268 AllocaInst *value = b_.CreateAllocaBPF(type, "lookup_elem_val");
269 Value *condition = b_.CreateICmpNE(
270- b_.CreateIntCast(lookup, b_.getInt8PtrTy(), true),
271+ b_.CreateIntCast(lookup, b_.getPtrTy(), true),
272 ConstantExpr::getCast(Instruction::IntToPtr,
273 b_.getInt64(0),
274- b_.getInt8PtrTy()),
275+ b_.getPtrTy()),
276 "map_lookup_cond");
277 b_.CreateCondBr(condition, lookup_success_block, lookup_failure_block);
278
279@@ -687,7 +687,7 @@ void CodegenLLVM::visit(Call &call)
280 ? Instruction::BitCast
281 : Instruction::IntToPtr,
282 expr_,
283- b_.getInt8PtrTy()),
284+ b_.getPtrTy()),
285 call.loc);
286 expr_ = buf;
287 expr_deleter_ = [this, buf]() { b_.CreateLifetimeEnd(buf); };
288@@ -919,9 +919,9 @@ void CodegenLLVM::visit(Call &call)
289
290 // and finally the seq_printf call
291 b_.CreateSeqPrintf(ctx_,
292- b_.CreateIntToPtr(fmt, b_.getInt8PtrTy()),
293+ b_.CreateIntToPtr(fmt, b_.getPtrTy()),
294 b_.getInt32(size),
295- b_.CreatePointerCast(data, b_.getInt8PtrTy()),
296+ b_.CreatePointerCast(data, b_.getPtrTy()),
297 b_.getInt32(data_size),
298 call.loc);
299
300@@ -950,7 +950,7 @@ void CodegenLLVM::visit(Call &call)
301 values.push_back(expr_);
302 }
303
304- b_.CreateTracePrintk(b_.CreateIntToPtr(fmt, b_.getInt8PtrTy()),
305+ b_.CreateTracePrintk(b_.CreateIntToPtr(fmt, b_.getPtrTy()),
306 b_.getInt32(size),
307 values,
308 call.loc);
309@@ -1878,7 +1878,7 @@ void CodegenLLVM::visit(FieldAccess &acc)
310 // `is_data_loc` should only be set if field access is on `args` which
311 // has to be a ctx access
312 assert(type.IsCtxAccess());
313- assert(ctx_->getType() == b_.getInt8PtrTy());
314+ assert(ctx_->getType() == b_.getPtrTy());
315 // Parser needs to have rewritten field to be a u64
316 assert(field.type.IsIntTy());
317 assert(field.type.GetIntBitWidth() == 64);
318@@ -2416,7 +2416,7 @@ void CodegenLLVM::createRet(Value *value)
319 void CodegenLLVM::visit(Probe &probe)
320 {
321 FunctionType *func_type = FunctionType::get(b_.getInt64Ty(),
322- { b_.getInt8PtrTy() }, // struct
323+ { b_.getPtrTy() }, // struct
324 // pt_regs
325 // *ctx
326 false);
327@@ -3773,7 +3773,7 @@ Function *CodegenLLVM::createMapLenCallback()
328 auto saved_ip = b_.saveIP();
329
330 std::array<llvm::Type *, 4> args = {
331- b_.getInt8PtrTy(), b_.getInt8PtrTy(), b_.getInt8PtrTy(), b_.getInt8PtrTy()
332+ b_.getPtrTy(), b_.getPtrTy(), b_.getPtrTy(), b_.getPtrTy()
333 };
334
335 FunctionType *callback_type = FunctionType::get(b_.getInt64Ty(), args, false);
336--
3372.43.2
338
diff --git a/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/0003-ast-Adjust-to-enum-changes-in-llvm-18.patch b/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/0003-ast-Adjust-to-enum-changes-in-llvm-18.patch
new file mode 100644
index 0000000..35f442f
--- /dev/null
+++ b/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/0003-ast-Adjust-to-enum-changes-in-llvm-18.patch
@@ -0,0 +1,41 @@
1From 71618b5eae717c491e11b770dff14ba79306f0c8 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 16 Feb 2024 10:40:21 -0800
4Subject: [PATCH 3/4] ast: Adjust to enum changes in llvm 18
5
6llvm 18 has change CodeGenOpt::Level/CodeGenFileType into enum classes via
7https://github.com/llvm/llvm-project/commit/0a1aa6cda2758b0926a95f87d39ffefb1cb90200
8
9Upstream-Status: Submitted [https://github.com/bpftrace/bpftrace/pull/3009]
10Signed-off-by: Khem Raj <raj.khem@gmail.com>
11---
12 src/ast/passes/codegen_llvm.cpp | 6 ++++--
13 1 file changed, 4 insertions(+), 2 deletions(-)
14
15diff --git a/src/ast/passes/codegen_llvm.cpp b/src/ast/passes/codegen_llvm.cpp
16index 258b0b0b..ceab4bc4 100644
17--- a/src/ast/passes/codegen_llvm.cpp
18+++ b/src/ast/passes/codegen_llvm.cpp
19@@ -73,7 +73,7 @@ CodegenLLVM::CodegenLLVM(Node *root, BPFtrace &bpftrace)
20 Optional<Reloc::Model>()
21 #endif
22 ));
23- target_machine_->setOptLevel(llvm::CodeGenOpt::Aggressive);
24+ target_machine_->setOptLevel(llvm::CodeGenOptLevel::Aggressive);
25
26 module_->setTargetTriple(LLVMTargetTriple);
27 module_->setDataLayout(target_machine_->createDataLayout());
28@@ -3530,7 +3530,9 @@ void CodegenLLVM::emit(raw_pwrite_stream &stream)
29 {
30 legacy::PassManager PM;
31
32-#if LLVM_VERSION_MAJOR >= 10
33+#if LLVM_VERSION_MAJOR >= 18
34+ auto type = CodeGenFileType::ObjectFile;
35+#elif LLVM_VERSION_MAJOR >= 10
36 auto type = llvm::CGFT_ObjectFile;
37 #else
38 auto type = llvm::TargetMachine::CGFT_ObjectFile;
39--
402.43.2
41
diff --git a/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/0004-cmake-Bump-max-LLVM-version-to-18.patch b/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/0004-cmake-Bump-max-LLVM-version-to-18.patch
new file mode 100644
index 0000000..8a5dbf2
--- /dev/null
+++ b/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/0004-cmake-Bump-max-LLVM-version-to-18.patch
@@ -0,0 +1,27 @@
1From 16186113346c268a0bb45424ba1c41768b7e94cf Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 16 Feb 2024 10:14:41 -0800
4Subject: [PATCH 4/4] cmake: Bump max LLVM version to 18+
5
6Upstream-Status: Submitted [https://github.com/bpftrace/bpftrace/pull/3009]
7Signed-off-by: Khem Raj <raj.khem@gmail.com>
8---
9 CMakeLists.txt | 2 +-
10 1 file changed, 1 insertion(+), 1 deletion(-)
11
12diff --git a/CMakeLists.txt b/CMakeLists.txt
13index 7983ee17..7d0433de 100644
14--- a/CMakeLists.txt
15+++ b/CMakeLists.txt
16@@ -139,7 +139,7 @@ else()
17 endif()
18
19 set(MIN_LLVM_MAJOR 6)
20-set(MAX_LLVM_MAJOR 17)
21+set(MAX_LLVM_MAJOR 18)
22
23 if((${LLVM_VERSION_MAJOR} VERSION_LESS ${MIN_LLVM_MAJOR}) OR (${LLVM_VERSION_MAJOR} VERSION_GREATER ${MAX_LLVM_MAJOR}))
24 message(SEND_ERROR "Unsupported LLVM version found via ${LLVM_INCLUDE_DIRS}: ${LLVM_VERSION_MAJOR}")
25--
262.43.2
27
diff --git a/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/run-ptest b/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/run-ptest
new file mode 100644
index 0000000..63d65e2
--- /dev/null
+++ b/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/run-ptest
@@ -0,0 +1,51 @@
1#!/bin/sh
2
3# The whole test suite may take up to 40 minutes to run, so setting -t 2400
4# parameter in ptest-runner is necessary to not kill it before completion
5
6cd tests || exit 1
7export BPFTRACE_RUNTIME_TEST_EXECUTABLE=/usr/bin/bpftrace
8export BPFTRACE_AOT_RUNTIME_TEST_EXECUTABLE=/usr/bin/bpftrace-aotrt
9
10PASS_CNT=0
11FAIL_CNT=0
12SKIP_CNT=0
13FAILED=""
14
15print_test_result() {
16 if [ $? -eq 0 ]; then
17 echo "PASS: $1"
18 PASS_CNT=$((PASS_CNT + 1))
19 else
20 echo "FAIL: $1"
21 FAIL_CNT=$((FAIL_CNT + 1))
22 FAILED="${FAILED:+$FAILED }$1;"
23 fi
24 }
25
26IFS=$(printf '\n\t')
27# Start unit tests
28for test_name in $(./bpftrace_test --gtest_list_tests | grep -v "^ "); do
29 ./bpftrace_test --gtest_filter="${test_name}*" > /dev/null 2>&1
30 print_test_result "unit:$test_name"
31done
32
33# Start runtime tests
34for test_name in $(ls runtime); do
35 # Ignore test cases that hang the suite forever (bpftrace v0.16.0)
36 if [ "$test_name" = "signals" ] || [ "$test_name" = "watchpoint" ]; then
37 echo "SKIP: runtime:$test_name"
38 SKIP_CNT=$((SKIP_CNT + 1))
39 continue
40 fi
41 python3 runtime/engine/main.py --filter="${test_name}.*" > /dev/null 2>&1
42 print_test_result "runtime:$test_name"
43done
44unset IFS
45
46echo "#### bpftrace tests summary ####"
47echo "# TOTAL: $((PASS_CNT + FAIL_CNT + SKIP_CNT))"
48echo "# PASS: $PASS_CNT"
49echo "# FAIL: $FAIL_CNT ($FAILED)"
50echo "# SKIP: $SKIP_CNT"
51echo "################################"
diff --git a/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace_0.20.1.bb b/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace_0.20.1.bb
new file mode 100644
index 0000000..355f427
--- /dev/null
+++ b/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace_0.20.1.bb
@@ -0,0 +1,65 @@
1SUMMARY = "bpftrace"
2HOMEPAGE = "https://github.com/iovisor/bpftrace"
3LICENSE = "Apache-2.0"
4LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57"
5
6DEPENDS += "bison-native \
7 flex-native \
8 gzip-native \
9 elfutils \
10 bcc \
11 systemtap \
12 libcereal \
13 libbpf \
14 "
15DEPENDS += "${@bb.utils.contains('PTEST_ENABLED', '1', 'pahole-native llvm-native', '', d)}"
16
17RDEPENDS:${PN} += "bash python3 xz"
18
19PV .= "+git"
20
21SRC_URI = "git://github.com/iovisor/bpftrace;branch=master;protocol=https \
22 file://0001-replace-python-with-python3-in-the-test.patch \
23 file://0002-ast-Repace-getInt8PtrTy-with-getPtrTy.patch \
24 file://0003-ast-Adjust-to-enum-changes-in-llvm-18.patch \
25 file://0004-cmake-Bump-max-LLVM-version-to-18.patch \
26 file://0001-use-64bit-alignment-for-map-counter-atomic-add.patch \
27 file://run-ptest \
28"
29SRCREV = "fe6362b4e2c1b9d0833c7d3f308c1d4006b54723"
30
31S = "${WORKDIR}/git"
32
33inherit cmake ptest
34
35PACKAGECONFIG ?= "${@bb.utils.contains('PTEST_ENABLED', '1', 'tests', '', d)}"
36
37PACKAGECONFIG[tests] = "-DBUILD_TESTING=ON,-DBUILD_TESTING=OFF,gtest xxd-native"
38
39do_install_ptest() {
40 if [ -e ${B}/tests/bpftrace_test ]; then
41 install -Dm 755 ${B}/tests/bpftrace_test ${D}${PTEST_PATH}/tests/bpftrace_test
42 cp -rf ${B}/tests/runtime ${D}${PTEST_PATH}/tests
43 cp -rf ${B}/tests/test* ${D}${PTEST_PATH}/tests
44 fi
45}
46
47def llvm_major_version(d):
48 pvsplit = d.getVar('LLVMVERSION').split('.')
49 return pvsplit[0]
50
51LLVM_MAJOR_VERSION = "${@llvm_major_version(d)}"
52
53EXTRA_OECMAKE = " \
54 -DCMAKE_ENABLE_EXPORTS=1 \
55 -DCMAKE_BUILD_TYPE=Release \
56 -DUSE_SYSTEM_BPF_BCC=ON \
57 -DENABLE_MAN=OFF \
58"
59
60COMPATIBLE_HOST = "(x86_64.*|aarch64.*|powerpc64.*|riscv64.*)-linux"
61COMPATIBLE_HOST:libc-musl = "null"
62
63INHIBIT_PACKAGE_STRIP_FILES += "\
64 ${PKGD}${PTEST_PATH}/tests/testprogs/uprobe_test \
65"