diff options
author | Khem Raj <raj.khem@gmail.com> | 2024-02-16 10:51:09 -0800 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2024-03-06 19:18:22 -0800 |
commit | 57e06fb428e50e349e2e7af26c537047164ab7de (patch) | |
tree | e65ae90af5cf9f2628424cb861e18500b6a7a95c /dynamic-layers/openembedded-layer | |
parent | 22235606aa2d61bbbc0c4bcc684cb665c5657053 (diff) | |
download | meta-clang-57e06fb428e50e349e2e7af26c537047164ab7de.tar.gz |
bpftrace: Upgrade to 0.20+ and fix with llvm 18
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'dynamic-layers/openembedded-layer')
7 files changed, 418 insertions, 91 deletions
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-Adjust-to-build-with-llvm-17.patch b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-Adjust-to-build-with-llvm-17.patch deleted file mode 100644 index 6720ea0..0000000 --- a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-Adjust-to-build-with-llvm-17.patch +++ /dev/null | |||
@@ -1,58 +0,0 @@ | |||
1 | From 3aa0c5caadb03b1c30d0ac366dbc7b592076dc43 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Thu, 6 Jul 2023 08:59:41 -0700 | ||
4 | Subject: [PATCH] Adjust to build with llvm 17 | ||
5 | |||
6 | PassManagerBuilder has been removed in llvm 17 | ||
7 | itaniumDemangle() API signature has changed too | ||
8 | |||
9 | Upstream-Status: Submitted [https://github.com/iovisor/bpftrace/pull/2667] | ||
10 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
11 | --- | ||
12 | src/ast/passes/codegen_llvm.cpp | 4 ++++ | ||
13 | src/cxxdemangler/cxxdemangler_llvm.cpp | 4 ++++ | ||
14 | 2 files changed, 8 insertions(+) | ||
15 | |||
16 | diff --git a/src/ast/passes/codegen_llvm.cpp b/src/ast/passes/codegen_llvm.cpp | ||
17 | index 1af2a23e..49ab8c9d 100644 | ||
18 | --- a/src/ast/passes/codegen_llvm.cpp | ||
19 | +++ b/src/ast/passes/codegen_llvm.cpp | ||
20 | @@ -7,7 +7,9 @@ | ||
21 | #include <ctime> | ||
22 | #include <fstream> | ||
23 | |||
24 | +#if LLVM_VERSION_MAJOR <= 16 | ||
25 | #include <llvm-c/Transforms/IPO.h> | ||
26 | +#endif | ||
27 | #include <llvm/IR/Constants.h> | ||
28 | #include <llvm/IR/LLVMContext.h> | ||
29 | #include <llvm/IR/LegacyPassManager.h> | ||
30 | @@ -17,7 +19,9 @@ | ||
31 | #include <llvm/Passes/PassBuilder.h> | ||
32 | #endif | ||
33 | #include <llvm/Transforms/IPO.h> | ||
34 | +#if LLVM_VERSION_MAJOR <= 16 | ||
35 | #include <llvm/Transforms/IPO/PassManagerBuilder.h> | ||
36 | +#endif | ||
37 | #if LLVM_VERSION_MAJOR >= 14 | ||
38 | #include <llvm/MC/TargetRegistry.h> | ||
39 | #else | ||
40 | diff --git a/src/cxxdemangler/cxxdemangler_llvm.cpp b/src/cxxdemangler/cxxdemangler_llvm.cpp | ||
41 | index e9a9db24..1b0bf7ea 100644 | ||
42 | --- a/src/cxxdemangler/cxxdemangler_llvm.cpp | ||
43 | +++ b/src/cxxdemangler/cxxdemangler_llvm.cpp | ||
44 | @@ -6,7 +6,11 @@ namespace bpftrace { | ||
45 | |||
46 | char* cxxdemangle(const char* mangled) | ||
47 | { | ||
48 | +#if LLVM_VERSION_MAJOR <= 16 | ||
49 | return llvm::itaniumDemangle(mangled, nullptr, nullptr, nullptr); | ||
50 | +#else | ||
51 | + return llvm::itaniumDemangle(mangled); | ||
52 | +#endif | ||
53 | } | ||
54 | |||
55 | } // namespace bpftrace | ||
56 | -- | ||
57 | 2.41.0 | ||
58 | |||
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-cmake-Raise-max-llvm-major-version-to-16.patch b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-cmake-Raise-max-llvm-major-version-to-16.patch deleted file mode 100644 index 1806fde..0000000 --- a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-cmake-Raise-max-llvm-major-version-to-16.patch +++ /dev/null | |||
@@ -1,22 +0,0 @@ | |||
1 | From 85ec062020e4cddf249dd21707752655229e2187 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Fri, 10 Mar 2023 00:08:27 -0800 | ||
4 | Subject: [PATCH] cmake: Raise max llvm major version to 16 | ||
5 | |||
6 | Upstream-Status: Submitted [https://github.com/iovisor/bpftrace/pull/2528] | ||
7 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
8 | --- | ||
9 | CMakeLists.txt | 2 +- | ||
10 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
11 | |||
12 | --- a/CMakeLists.txt | ||
13 | +++ b/CMakeLists.txt | ||
14 | @@ -165,7 +165,7 @@ else() | ||
15 | endif() | ||
16 | |||
17 | set(MIN_LLVM_MAJOR 6) | ||
18 | - set(MAX_LLVM_MAJOR 16) | ||
19 | + set(MAX_LLVM_MAJOR 17) | ||
20 | |||
21 | if((${LLVM_VERSION_MAJOR} VERSION_LESS ${MIN_LLVM_MAJOR}) OR (${LLVM_VERSION_MAJOR} VERSION_GREATER ${MAX_LLVM_MAJOR})) | ||
22 | message(SEND_ERROR "Unsupported LLVM version found via ${LLVM_INCLUDE_DIRS}: ${LLVM_VERSION_MAJOR}") | ||
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-replace-python-with-python3-in-the-test.patch b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-replace-python-with-python3-in-the-test.patch index 6a82a1f..4438716 100644 --- a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-replace-python-with-python3-in-the-test.patch +++ b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-replace-python-with-python3-in-the-test.patch | |||
@@ -1,7 +1,7 @@ | |||
1 | From f2a61d19d8432a220184c4eed7c39eb042d0dfff Mon Sep 17 00:00:00 2001 | 1 | From 62319459e7ef14a37293bc10830b52edf89daabe Mon Sep 17 00:00:00 2001 |
2 | From: Wentao Zhang <wentao.zhang@windriver.com> | 2 | From: Wentao Zhang <wentao.zhang@windriver.com> |
3 | Date: Tue, 15 Aug 2023 11:18:36 +0800 | 3 | Date: Tue, 15 Aug 2023 11:18:36 +0800 |
4 | Subject: [PATCH] replace python with python3 in the test | 4 | Subject: [PATCH 1/4] replace python with python3 in the test |
5 | 5 | ||
6 | "runtime:call" in ptest gets the following FAILED: | 6 | "runtime:call" in ptest gets the following FAILED: |
7 | python: No such file or directory | 7 | python: No such file or directory |
@@ -21,7 +21,7 @@ $python3 runtime/engine/main.py --filter="call.*" | |||
21 | file or directory\n | 21 | file or directory\n |
22 | *** | 22 | *** |
23 | 23 | ||
24 | Upstream-Status: Inappropriate [oe specific] | 24 | Upstream-Status: Submitted [https://github.com/bpftrace/bpftrace/pull/3009] |
25 | 25 | ||
26 | Signed-off-by: Wentao Zhang <wentao.zhang@windriver.com> | 26 | Signed-off-by: Wentao Zhang <wentao.zhang@windriver.com> |
27 | --- | 27 | --- |
@@ -29,10 +29,10 @@ Signed-off-by: Wentao Zhang <wentao.zhang@windriver.com> | |||
29 | 1 file changed, 2 insertions(+), 2 deletions(-) | 29 | 1 file changed, 2 insertions(+), 2 deletions(-) |
30 | 30 | ||
31 | diff --git a/tests/runtime/call b/tests/runtime/call | 31 | diff --git a/tests/runtime/call b/tests/runtime/call |
32 | index 36f5d9af..3a938f49 100644 | 32 | index 7f7cce6d..174bce95 100644 |
33 | --- a/tests/runtime/call | 33 | --- a/tests/runtime/call |
34 | +++ b/tests/runtime/call | 34 | +++ b/tests/runtime/call |
35 | @@ -294,13 +294,13 @@ TIMEOUT 5 | 35 | @@ -371,13 +371,13 @@ TIMEOUT 5 |
36 | # | 36 | # |
37 | # Note we add a `1` before the timestamp b/c leading zeros (eg `0123`) is invalid integer in python. | 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 | 38 | NAME strftime_microsecond_extension |
@@ -49,5 +49,5 @@ index 36f5d9af..3a938f49 100644 | |||
49 | TIMEOUT 1 | 49 | TIMEOUT 1 |
50 | 50 | ||
51 | -- | 51 | -- |
52 | 2.25.1 | 52 | 2.43.2 |
53 | 53 | ||
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0002-ast-Repace-getInt8PtrTy-with-getPtrTy.patch b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0002-ast-Repace-getInt8PtrTy-with-getPtrTy.patch new file mode 100644 index 0000000..9167963 --- /dev/null +++ b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0002-ast-Repace-getInt8PtrTy-with-getPtrTy.patch | |||
@@ -0,0 +1,338 @@ | |||
1 | From 441f38a0fa9711a08ca8d904b542559593bffb16 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Fri, 16 Feb 2024 10:32:27 -0800 | ||
4 | Subject: [PATCH 2/4] ast: Repace getInt8PtrTy with getPtrTy | ||
5 | |||
6 | getPtrTy is added in LLVM-15 and is to be used instead of getInt8PtrTy | ||
7 | which is gone in LLVM-18 onwards | ||
8 | |||
9 | https://github.com/llvm/llvm-project/commit/7e0802aeb5b90 | ||
10 | |||
11 | Upstream-Status: Submitted [https://github.com/bpftrace/bpftrace/pull/3009] | ||
12 | Signed-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 | |||
18 | diff --git a/src/ast/irbuilderbpf.cpp b/src/ast/irbuilderbpf.cpp | ||
19 | index 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, | ||
249 | diff --git a/src/ast/passes/codegen_llvm.cpp b/src/ast/passes/codegen_llvm.cpp | ||
250 | index 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 | -- | ||
337 | 2.43.2 | ||
338 | |||
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0003-ast-Adjust-to-enum-changes-in-llvm-18.patch b/dynamic-layers/openembedded-layer/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/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0003-ast-Adjust-to-enum-changes-in-llvm-18.patch | |||
@@ -0,0 +1,41 @@ | |||
1 | From 71618b5eae717c491e11b770dff14ba79306f0c8 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Fri, 16 Feb 2024 10:40:21 -0800 | ||
4 | Subject: [PATCH 3/4] ast: Adjust to enum changes in llvm 18 | ||
5 | |||
6 | llvm 18 has change CodeGenOpt::Level/CodeGenFileType into enum classes via | ||
7 | https://github.com/llvm/llvm-project/commit/0a1aa6cda2758b0926a95f87d39ffefb1cb90200 | ||
8 | |||
9 | Upstream-Status: Submitted [https://github.com/bpftrace/bpftrace/pull/3009] | ||
10 | Signed-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 | |||
15 | diff --git a/src/ast/passes/codegen_llvm.cpp b/src/ast/passes/codegen_llvm.cpp | ||
16 | index 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 | -- | ||
40 | 2.43.2 | ||
41 | |||
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0004-cmake-Bump-max-LLVM-version-to-18.patch b/dynamic-layers/openembedded-layer/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/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0004-cmake-Bump-max-LLVM-version-to-18.patch | |||
@@ -0,0 +1,27 @@ | |||
1 | From 16186113346c268a0bb45424ba1c41768b7e94cf Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Fri, 16 Feb 2024 10:14:41 -0800 | ||
4 | Subject: [PATCH 4/4] cmake: Bump max LLVM version to 18+ | ||
5 | |||
6 | Upstream-Status: Submitted [https://github.com/bpftrace/bpftrace/pull/3009] | ||
7 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
8 | --- | ||
9 | CMakeLists.txt | 2 +- | ||
10 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
11 | |||
12 | diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
13 | index 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 | -- | ||
26 | 2.43.2 | ||
27 | |||
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.18.0.bb b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.20.1.bb index 8aa8a29..bc39afa 100644 --- a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.18.0.bb +++ b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.20.1.bb | |||
@@ -14,16 +14,18 @@ DEPENDS += "bison-native \ | |||
14 | " | 14 | " |
15 | DEPENDS += "${@bb.utils.contains('PTEST_ENABLED', '1', 'pahole-native llvm-native', '', d)}" | 15 | DEPENDS += "${@bb.utils.contains('PTEST_ENABLED', '1', 'pahole-native llvm-native', '', d)}" |
16 | 16 | ||
17 | PV .= "+git${SRCREV}" | ||
18 | RDEPENDS:${PN} += "bash python3 xz" | 17 | RDEPENDS:${PN} += "bash python3 xz" |
19 | 18 | ||
19 | PV .= "+git" | ||
20 | |||
20 | SRC_URI = "git://github.com/iovisor/bpftrace;branch=master;protocol=https \ | 21 | SRC_URI = "git://github.com/iovisor/bpftrace;branch=master;protocol=https \ |
21 | file://0001-cmake-Raise-max-llvm-major-version-to-16.patch \ | ||
22 | file://0001-Adjust-to-build-with-llvm-17.patch \ | ||
23 | file://0001-replace-python-with-python3-in-the-test.patch \ | 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 \ | ||
24 | file://run-ptest \ | 26 | file://run-ptest \ |
25 | " | 27 | " |
26 | SRCREV = "e199c7e73da84bff9fe744d1e3402c2b505aa5a2" | 28 | SRCREV = "fe6362b4e2c1b9d0833c7d3f308c1d4006b54723" |
27 | 29 | ||
28 | S = "${WORKDIR}/git" | 30 | S = "${WORKDIR}/git" |
29 | 31 | ||
@@ -50,7 +52,6 @@ LLVM_MAJOR_VERSION = "${@llvm_major_version(d)}" | |||
50 | EXTRA_OECMAKE = " \ | 52 | EXTRA_OECMAKE = " \ |
51 | -DCMAKE_ENABLE_EXPORTS=1 \ | 53 | -DCMAKE_ENABLE_EXPORTS=1 \ |
52 | -DCMAKE_BUILD_TYPE=Release \ | 54 | -DCMAKE_BUILD_TYPE=Release \ |
53 | -DLLVM_REQUESTED_VERSION=${LLVM_MAJOR_VERSION} \ | ||
54 | -DUSE_SYSTEM_BPF_BCC=ON \ | 55 | -DUSE_SYSTEM_BPF_BCC=ON \ |
55 | -DENABLE_MAN=OFF \ | 56 | -DENABLE_MAN=OFF \ |
56 | " | 57 | " |