From 57e06fb428e50e349e2e7af26c537047164ab7de Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Fri, 16 Feb 2024 10:51:09 -0800 Subject: bpftrace: Upgrade to 0.20+ and fix with llvm 18 Signed-off-by: Khem Raj --- .../0001-Adjust-to-build-with-llvm-17.patch | 58 ---- ...-cmake-Raise-max-llvm-major-version-to-16.patch | 22 -- ...1-replace-python-with-python3-in-the-test.patch | 12 +- ...002-ast-Repace-getInt8PtrTy-with-getPtrTy.patch | 338 +++++++++++++++++++++ ...003-ast-Adjust-to-enum-changes-in-llvm-18.patch | 41 +++ .../0004-cmake-Bump-max-LLVM-version-to-18.patch | 27 ++ .../recipes-devtools/bpftrace/bpftrace_0.18.0.bb | 63 ---- .../recipes-devtools/bpftrace/bpftrace_0.20.1.bb | 64 ++++ 8 files changed, 476 insertions(+), 149 deletions(-) delete mode 100644 dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-Adjust-to-build-with-llvm-17.patch delete mode 100644 dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-cmake-Raise-max-llvm-major-version-to-16.patch create mode 100644 dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0002-ast-Repace-getInt8PtrTy-with-getPtrTy.patch create mode 100644 dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0003-ast-Adjust-to-enum-changes-in-llvm-18.patch create mode 100644 dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0004-cmake-Bump-max-LLVM-version-to-18.patch delete mode 100644 dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.18.0.bb create mode 100644 dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.20.1.bb (limited to 'dynamic-layers') 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 @@ -From 3aa0c5caadb03b1c30d0ac366dbc7b592076dc43 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Thu, 6 Jul 2023 08:59:41 -0700 -Subject: [PATCH] Adjust to build with llvm 17 - -PassManagerBuilder has been removed in llvm 17 -itaniumDemangle() API signature has changed too - -Upstream-Status: Submitted [https://github.com/iovisor/bpftrace/pull/2667] -Signed-off-by: Khem Raj ---- - src/ast/passes/codegen_llvm.cpp | 4 ++++ - src/cxxdemangler/cxxdemangler_llvm.cpp | 4 ++++ - 2 files changed, 8 insertions(+) - -diff --git a/src/ast/passes/codegen_llvm.cpp b/src/ast/passes/codegen_llvm.cpp -index 1af2a23e..49ab8c9d 100644 ---- a/src/ast/passes/codegen_llvm.cpp -+++ b/src/ast/passes/codegen_llvm.cpp -@@ -7,7 +7,9 @@ - #include - #include - -+#if LLVM_VERSION_MAJOR <= 16 - #include -+#endif - #include - #include - #include -@@ -17,7 +19,9 @@ - #include - #endif - #include -+#if LLVM_VERSION_MAJOR <= 16 - #include -+#endif - #if LLVM_VERSION_MAJOR >= 14 - #include - #else -diff --git a/src/cxxdemangler/cxxdemangler_llvm.cpp b/src/cxxdemangler/cxxdemangler_llvm.cpp -index e9a9db24..1b0bf7ea 100644 ---- a/src/cxxdemangler/cxxdemangler_llvm.cpp -+++ b/src/cxxdemangler/cxxdemangler_llvm.cpp -@@ -6,7 +6,11 @@ namespace bpftrace { - - char* cxxdemangle(const char* mangled) - { -+#if LLVM_VERSION_MAJOR <= 16 - return llvm::itaniumDemangle(mangled, nullptr, nullptr, nullptr); -+#else -+ return llvm::itaniumDemangle(mangled); -+#endif - } - - } // namespace bpftrace --- -2.41.0 - 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 @@ -From 85ec062020e4cddf249dd21707752655229e2187 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 10 Mar 2023 00:08:27 -0800 -Subject: [PATCH] cmake: Raise max llvm major version to 16 - -Upstream-Status: Submitted [https://github.com/iovisor/bpftrace/pull/2528] -Signed-off-by: Khem Raj ---- - CMakeLists.txt | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -165,7 +165,7 @@ else() - endif() - - set(MIN_LLVM_MAJOR 6) -- set(MAX_LLVM_MAJOR 16) -+ set(MAX_LLVM_MAJOR 17) - - if((${LLVM_VERSION_MAJOR} VERSION_LESS ${MIN_LLVM_MAJOR}) OR (${LLVM_VERSION_MAJOR} VERSION_GREATER ${MAX_LLVM_MAJOR})) - 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 @@ -From f2a61d19d8432a220184c4eed7c39eb042d0dfff Mon Sep 17 00:00:00 2001 +From 62319459e7ef14a37293bc10830b52edf89daabe Mon Sep 17 00:00:00 2001 From: Wentao Zhang Date: Tue, 15 Aug 2023 11:18:36 +0800 -Subject: [PATCH] replace python with python3 in the test +Subject: [PATCH 1/4] replace python with python3 in the test "runtime:call" in ptest gets the following FAILED: python: No such file or directory @@ -21,7 +21,7 @@ $python3 runtime/engine/main.py --filter="call.*" file or directory\n *** -Upstream-Status: Inappropriate [oe specific] +Upstream-Status: Submitted [https://github.com/bpftrace/bpftrace/pull/3009] Signed-off-by: Wentao Zhang --- @@ -29,10 +29,10 @@ Signed-off-by: Wentao Zhang 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/runtime/call b/tests/runtime/call -index 36f5d9af..3a938f49 100644 +index 7f7cce6d..174bce95 100644 --- a/tests/runtime/call +++ b/tests/runtime/call -@@ -294,13 +294,13 @@ TIMEOUT 5 +@@ -371,13 +371,13 @@ TIMEOUT 5 # # Note we add a `1` before the timestamp b/c leading zeros (eg `0123`) is invalid integer in python. NAME strftime_microsecond_extension @@ -49,5 +49,5 @@ index 36f5d9af..3a938f49 100644 TIMEOUT 1 -- -2.25.1 +2.43.2 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 @@ +From 441f38a0fa9711a08ca8d904b542559593bffb16 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Fri, 16 Feb 2024 10:32:27 -0800 +Subject: [PATCH 2/4] ast: Repace getInt8PtrTy with getPtrTy + +getPtrTy is added in LLVM-15 and is to be used instead of getInt8PtrTy +which is gone in LLVM-18 onwards + +https://github.com/llvm/llvm-project/commit/7e0802aeb5b90 + +Upstream-Status: Submitted [https://github.com/bpftrace/bpftrace/pull/3009] +Signed-off-by: Khem Raj +--- + src/ast/irbuilderbpf.cpp | 58 ++++++++++++++++----------------- + src/ast/passes/codegen_llvm.cpp | 22 ++++++------- + 2 files changed, 40 insertions(+), 40 deletions(-) + +diff --git a/src/ast/irbuilderbpf.cpp b/src/ast/irbuilderbpf.cpp +index 670a9e98..2ff3c0ce 100644 +--- a/src/ast/irbuilderbpf.cpp ++++ b/src/ast/irbuilderbpf.cpp +@@ -301,7 +301,7 @@ CallInst *IRBuilderBPF::createMapLookup(const std::string &map_name, + Value *key, + const std::string &name) + { +- return createMapLookup(map_name, key, getInt8PtrTy(), name); ++ return createMapLookup(map_name, key, getPtrTy(), name); + } + + CallInst *IRBuilderBPF::createMapLookup(const std::string &map_name, +@@ -329,7 +329,7 @@ CallInst *IRBuilderBPF::CreateGetJoinMap(BasicBlock *failure_callback, + { + return createGetScratchMap(to_string(MapManager::Type::Join), + "join", +- getInt8PtrTy(), ++ getPtrTy(), + loc, + failure_callback); + } +@@ -358,8 +358,8 @@ CallInst *IRBuilderBPF::createGetScratchMap(const std::string &map_name, + BasicBlock *lookup_merge_block = BasicBlock::Create( + module_.getContext(), "lookup_" + name + "_merge", parent); + Value *condition = CreateICmpNE( +- CreateIntCast(call, getInt8PtrTy(), true), +- ConstantExpr::getCast(Instruction::IntToPtr, getInt64(0), getInt8PtrTy()), ++ CreateIntCast(call, getPtrTy(), true), ++ ConstantExpr::getCast(Instruction::IntToPtr, getInt64(0), getPtrTy()), + "lookup_" + name + "_cond"); + CreateCondBr(condition, lookup_merge_block, lookup_failure_block); + +@@ -379,7 +379,7 @@ Value *IRBuilderBPF::CreateMapLookupElem(Value *ctx, + Value *key, + const location &loc) + { +- assert(ctx && ctx->getType() == getInt8PtrTy()); ++ assert(ctx && ctx->getType() == getPtrTy()); + return CreateMapLookupElem(ctx, map.ident, key, map.type, loc); + } + +@@ -389,7 +389,7 @@ Value *IRBuilderBPF::CreateMapLookupElem(Value *ctx, + SizedType &type, + const location &loc) + { +- assert(ctx && ctx->getType() == getInt8PtrTy()); ++ assert(ctx && ctx->getType() == getPtrTy()); + CallInst *call = createMapLookup(map_name, key); + + // Check if result == 0 +@@ -406,8 +406,8 @@ Value *IRBuilderBPF::CreateMapLookupElem(Value *ctx, + + AllocaInst *value = CreateAllocaBPF(type, "lookup_elem_val"); + Value *condition = CreateICmpNE( +- CreateIntCast(call, getInt8PtrTy(), true), +- ConstantExpr::getCast(Instruction::IntToPtr, getInt64(0), getInt8PtrTy()), ++ CreateIntCast(call, getPtrTy(), true), ++ ConstantExpr::getCast(Instruction::IntToPtr, getInt64(0), getPtrTy()), + "map_lookup_cond"); + CreateCondBr(condition, lookup_success_block, lookup_failure_block); + +@@ -449,7 +449,7 @@ void IRBuilderBPF::CreateMapUpdateElem(Value *ctx, + { + Value *map_ptr = GetMapVar(map.ident); + +- assert(ctx && ctx->getType() == getInt8PtrTy()); ++ assert(ctx && ctx->getType() == getPtrTy()); + assert(key->getType()->isPointerTy()); + assert(val->getType()->isPointerTy()); + +@@ -478,7 +478,7 @@ void IRBuilderBPF::CreateMapDeleteElem(Value *ctx, + Value *key, + const location &loc) + { +- assert(ctx && ctx->getType() == getInt8PtrTy()); ++ assert(ctx && ctx->getType() == getPtrTy()); + assert(key->getType()->isPointerTy()); + Value *map_ptr = GetMapVar(map.ident); + +@@ -541,7 +541,7 @@ void IRBuilderBPF::CreateProbeRead(Value *ctx, + AddrSpace as, + const location &loc) + { +- assert(ctx && ctx->getType() == getInt8PtrTy()); ++ assert(ctx && ctx->getType() == getPtrTy()); + assert(size && size->getType()->getIntegerBitWidth() <= 32); + size = CreateIntCast(size, getInt32Ty(), false); + +@@ -581,7 +581,7 @@ CallInst *IRBuilderBPF::CreateProbeReadStr(Value *ctx, + AddrSpace as, + const location &loc) + { +- assert(ctx && ctx->getType() == getInt8PtrTy()); ++ assert(ctx && ctx->getType() == getPtrTy()); + assert(size && size->getType()->isIntegerTy()); + if ([[maybe_unused]] auto *dst_alloca = dyn_cast(dst)) { + assert(dst_alloca->getAllocatedType()->isArrayTy() && +@@ -615,7 +615,7 @@ Value *IRBuilderBPF::CreateUSDTReadArgument(Value *ctx, + AddrSpace as, + const location &loc) + { +- assert(ctx && ctx->getType() == getInt8PtrTy()); ++ assert(ctx && ctx->getType() == getPtrTy()); + // Argument size must be 1, 2, 4, or 8. See + // https://sourceware.org/systemtap/wiki/UserSpaceProbeImplementation + int abs_size = std::abs(argument->size); +@@ -711,7 +711,7 @@ Value *IRBuilderBPF::CreateUSDTReadArgument(Value *ctx, + AddrSpace as, + const location &loc) + { +- assert(ctx && ctx->getType() == getInt8PtrTy()); ++ assert(ctx && ctx->getType() == getPtrTy()); + struct bcc_usdt_argument argument; + + void *usdt; +@@ -1337,7 +1337,7 @@ CallInst *IRBuilderBPF::CreateGetStackId(Value *ctx, + StackType stack_type, + const location &loc) + { +- assert(ctx && ctx->getType() == getInt8PtrTy()); ++ assert(ctx && ctx->getType() == getPtrTy()); + + Value *map_ptr = GetMapVar(stack_type.name()); + +@@ -1350,7 +1350,7 @@ CallInst *IRBuilderBPF::CreateGetStackId(Value *ctx, + // Return: >= 0 stackid on success or negative error + FunctionType *getstackid_func_type = FunctionType::get( + getInt64Ty(), +- { getInt8PtrTy(), map_ptr->getType(), getInt64Ty() }, ++ { getPtrTy(), map_ptr->getType(), getInt64Ty() }, + false); + CallInst *call = CreateHelperCall(libbpf::BPF_FUNC_get_stackid, + getstackid_func_type, +@@ -1399,7 +1399,7 @@ void IRBuilderBPF::CreateOutput(Value *ctx, + size_t size, + const location *loc) + { +- assert(ctx && ctx->getType() == getInt8PtrTy()); ++ assert(ctx && ctx->getType() == getPtrTy()); + assert(data && data->getType()->isPointerTy()); + + if (bpftrace_.feature_->has_map_ringbuf()) { +@@ -1464,8 +1464,8 @@ void IRBuilderBPF::CreateAtomicIncCounter(const std::string &map_name, + parent); + + Value *condition = CreateICmpNE( +- CreateIntCast(call, getInt8PtrTy(), true), +- ConstantExpr::getCast(Instruction::IntToPtr, getInt64(0), getInt8PtrTy()), ++ CreateIntCast(call, getPtrTy(), true), ++ ConstantExpr::getCast(Instruction::IntToPtr, getInt64(0), getPtrTy()), + "map_lookup_cond"); + CreateCondBr(condition, lookup_success_block, lookup_failure_block); + +@@ -1521,8 +1521,8 @@ void IRBuilderBPF::CreateMapElemAdd(Value *ctx, + + AllocaInst *value = CreateAllocaBPF(type, "lookup_elem_val"); + Value *condition = CreateICmpNE( +- CreateIntCast(call, getInt8PtrTy(), true), +- ConstantExpr::getCast(Instruction::IntToPtr, getInt64(0), getInt8PtrTy()), ++ CreateIntCast(call, getPtrTy(), true), ++ ConstantExpr::getCast(Instruction::IntToPtr, getInt64(0), getPtrTy()), + "map_lookup_cond"); + CreateCondBr(condition, lookup_success_block, lookup_failure_block); + +@@ -1557,7 +1557,7 @@ void IRBuilderBPF::CreatePerfEventOutput(Value *ctx, + // long bpf_perf_event_output(struct pt_regs *ctx, struct bpf_map *map, + // u64 flags, void *data, u64 size) + FunctionType *perfoutput_func_type = FunctionType::get(getInt64Ty(), +- { getInt8PtrTy(), ++ { getPtrTy(), + map_ptr->getType(), + getInt64Ty(), + data->getType(), +@@ -1600,7 +1600,7 @@ void IRBuilderBPF::CreateTracePrintk(Value *fmt_ptr, + + // long bpf_trace_printk(const char *fmt, u32 fmt_size, ...) + FunctionType *traceprintk_func_type = FunctionType::get( +- getInt64Ty(), { getInt8PtrTy(), getInt32Ty() }, true); ++ getInt64Ty(), { getPtrTy(), getInt32Ty() }, true); + + CreateHelperCall(libbpf::BPF_FUNC_trace_printk, + traceprintk_func_type, +@@ -1630,7 +1630,7 @@ void IRBuilderBPF::CreateOverrideReturn(Value *ctx, Value *rc) + // long bpf_override_return(struct pt_regs *regs, u64 rc) + // Return: 0 + FunctionType *override_func_type = FunctionType::get( +- getInt64Ty(), { getInt8PtrTy(), getInt64Ty() }, false); ++ getInt64Ty(), { getPtrTy(), getInt64Ty() }, false); + PointerType *override_func_ptr_type = PointerType::get(override_func_type, 0); + Constant *override_func = ConstantExpr::getCast( + Instruction::IntToPtr, +@@ -1807,7 +1807,7 @@ void IRBuilderBPF::CreateHelperError(Value *ctx, + libbpf::bpf_func_id func_id, + const location &loc) + { +- assert(ctx && ctx->getType() == getInt8PtrTy()); ++ assert(ctx && ctx->getType() == getPtrTy()); + assert(return_value && return_value->getType() == getInt32Ty()); + + if (bpftrace_.helper_check_level_ == 0 || +@@ -1847,7 +1847,7 @@ void IRBuilderBPF::CreateHelperErrorCond(Value *ctx, + const location &loc, + bool compare_zero) + { +- assert(ctx && ctx->getType() == getInt8PtrTy()); ++ assert(ctx && ctx->getType() == getPtrTy()); + if (bpftrace_.helper_check_level_ == 0 || + (bpftrace_.helper_check_level_ == 1 && return_zero_if_err(func_id))) + return; +@@ -1883,7 +1883,7 @@ void IRBuilderBPF::CreatePath(Value *ctx, + // int bpf_d_path(struct path *path, char *buf, u32 sz) + // Return: 0 or error + FunctionType *d_path_func_type = FunctionType::get( +- getInt64Ty(), { getInt8PtrTy(), buf->getType(), getInt32Ty() }, false); ++ getInt64Ty(), { getPtrTy(), buf->getType(), getInt32Ty() }, false); + CallInst *call = CreateHelperCall( + libbpf::bpf_func_id::BPF_FUNC_d_path, + d_path_func_type, +@@ -1905,9 +1905,9 @@ void IRBuilderBPF::CreateSeqPrintf(Value *ctx, + // Return: 0 or error + FunctionType *seq_printf_func_type = FunctionType::get(getInt64Ty(), + { getInt64Ty(), +- getInt8PtrTy(), ++ getPtrTy(), + getInt32Ty(), +- getInt8PtrTy(), ++ getPtrTy(), + getInt32Ty() }, + false); + PointerType *seq_printf_func_ptr_type = PointerType::get(seq_printf_func_type, +diff --git a/src/ast/passes/codegen_llvm.cpp b/src/ast/passes/codegen_llvm.cpp +index 073d48ae..258b0b0b 100644 +--- a/src/ast/passes/codegen_llvm.cpp ++++ b/src/ast/passes/codegen_llvm.cpp +@@ -380,10 +380,10 @@ void CodegenLLVM::visit(Call &call) + + AllocaInst *value = b_.CreateAllocaBPF(type, "lookup_elem_val"); + Value *condition = b_.CreateICmpNE( +- b_.CreateIntCast(lookup, b_.getInt8PtrTy(), true), ++ b_.CreateIntCast(lookup, b_.getPtrTy(), true), + ConstantExpr::getCast(Instruction::IntToPtr, + b_.getInt64(0), +- b_.getInt8PtrTy()), ++ b_.getPtrTy()), + "map_lookup_cond"); + b_.CreateCondBr(condition, lookup_success_block, lookup_failure_block); + +@@ -437,10 +437,10 @@ void CodegenLLVM::visit(Call &call) + + AllocaInst *value = b_.CreateAllocaBPF(type, "lookup_elem_val"); + Value *condition = b_.CreateICmpNE( +- b_.CreateIntCast(lookup, b_.getInt8PtrTy(), true), ++ b_.CreateIntCast(lookup, b_.getPtrTy(), true), + ConstantExpr::getCast(Instruction::IntToPtr, + b_.getInt64(0), +- b_.getInt8PtrTy()), ++ b_.getPtrTy()), + "map_lookup_cond"); + b_.CreateCondBr(condition, lookup_success_block, lookup_failure_block); + +@@ -687,7 +687,7 @@ void CodegenLLVM::visit(Call &call) + ? Instruction::BitCast + : Instruction::IntToPtr, + expr_, +- b_.getInt8PtrTy()), ++ b_.getPtrTy()), + call.loc); + expr_ = buf; + expr_deleter_ = [this, buf]() { b_.CreateLifetimeEnd(buf); }; +@@ -919,9 +919,9 @@ void CodegenLLVM::visit(Call &call) + + // and finally the seq_printf call + b_.CreateSeqPrintf(ctx_, +- b_.CreateIntToPtr(fmt, b_.getInt8PtrTy()), ++ b_.CreateIntToPtr(fmt, b_.getPtrTy()), + b_.getInt32(size), +- b_.CreatePointerCast(data, b_.getInt8PtrTy()), ++ b_.CreatePointerCast(data, b_.getPtrTy()), + b_.getInt32(data_size), + call.loc); + +@@ -950,7 +950,7 @@ void CodegenLLVM::visit(Call &call) + values.push_back(expr_); + } + +- b_.CreateTracePrintk(b_.CreateIntToPtr(fmt, b_.getInt8PtrTy()), ++ b_.CreateTracePrintk(b_.CreateIntToPtr(fmt, b_.getPtrTy()), + b_.getInt32(size), + values, + call.loc); +@@ -1878,7 +1878,7 @@ void CodegenLLVM::visit(FieldAccess &acc) + // `is_data_loc` should only be set if field access is on `args` which + // has to be a ctx access + assert(type.IsCtxAccess()); +- assert(ctx_->getType() == b_.getInt8PtrTy()); ++ assert(ctx_->getType() == b_.getPtrTy()); + // Parser needs to have rewritten field to be a u64 + assert(field.type.IsIntTy()); + assert(field.type.GetIntBitWidth() == 64); +@@ -2416,7 +2416,7 @@ void CodegenLLVM::createRet(Value *value) + void CodegenLLVM::visit(Probe &probe) + { + FunctionType *func_type = FunctionType::get(b_.getInt64Ty(), +- { b_.getInt8PtrTy() }, // struct ++ { b_.getPtrTy() }, // struct + // pt_regs + // *ctx + false); +@@ -3773,7 +3773,7 @@ Function *CodegenLLVM::createMapLenCallback() + auto saved_ip = b_.saveIP(); + + std::array args = { +- b_.getInt8PtrTy(), b_.getInt8PtrTy(), b_.getInt8PtrTy(), b_.getInt8PtrTy() ++ b_.getPtrTy(), b_.getPtrTy(), b_.getPtrTy(), b_.getPtrTy() + }; + + FunctionType *callback_type = FunctionType::get(b_.getInt64Ty(), args, false); +-- +2.43.2 + 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 @@ +From 71618b5eae717c491e11b770dff14ba79306f0c8 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Fri, 16 Feb 2024 10:40:21 -0800 +Subject: [PATCH 3/4] ast: Adjust to enum changes in llvm 18 + +llvm 18 has change CodeGenOpt::Level/CodeGenFileType into enum classes via +https://github.com/llvm/llvm-project/commit/0a1aa6cda2758b0926a95f87d39ffefb1cb90200 + +Upstream-Status: Submitted [https://github.com/bpftrace/bpftrace/pull/3009] +Signed-off-by: Khem Raj +--- + src/ast/passes/codegen_llvm.cpp | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/src/ast/passes/codegen_llvm.cpp b/src/ast/passes/codegen_llvm.cpp +index 258b0b0b..ceab4bc4 100644 +--- a/src/ast/passes/codegen_llvm.cpp ++++ b/src/ast/passes/codegen_llvm.cpp +@@ -73,7 +73,7 @@ CodegenLLVM::CodegenLLVM(Node *root, BPFtrace &bpftrace) + Optional() + #endif + )); +- target_machine_->setOptLevel(llvm::CodeGenOpt::Aggressive); ++ target_machine_->setOptLevel(llvm::CodeGenOptLevel::Aggressive); + + module_->setTargetTriple(LLVMTargetTriple); + module_->setDataLayout(target_machine_->createDataLayout()); +@@ -3530,7 +3530,9 @@ void CodegenLLVM::emit(raw_pwrite_stream &stream) + { + legacy::PassManager PM; + +-#if LLVM_VERSION_MAJOR >= 10 ++#if LLVM_VERSION_MAJOR >= 18 ++ auto type = CodeGenFileType::ObjectFile; ++#elif LLVM_VERSION_MAJOR >= 10 + auto type = llvm::CGFT_ObjectFile; + #else + auto type = llvm::TargetMachine::CGFT_ObjectFile; +-- +2.43.2 + 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 @@ +From 16186113346c268a0bb45424ba1c41768b7e94cf Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Fri, 16 Feb 2024 10:14:41 -0800 +Subject: [PATCH 4/4] cmake: Bump max LLVM version to 18+ + +Upstream-Status: Submitted [https://github.com/bpftrace/bpftrace/pull/3009] +Signed-off-by: Khem Raj +--- + CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 7983ee17..7d0433de 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -139,7 +139,7 @@ else() + endif() + + set(MIN_LLVM_MAJOR 6) +-set(MAX_LLVM_MAJOR 17) ++set(MAX_LLVM_MAJOR 18) + + if((${LLVM_VERSION_MAJOR} VERSION_LESS ${MIN_LLVM_MAJOR}) OR (${LLVM_VERSION_MAJOR} VERSION_GREATER ${MAX_LLVM_MAJOR})) + message(SEND_ERROR "Unsupported LLVM version found via ${LLVM_INCLUDE_DIRS}: ${LLVM_VERSION_MAJOR}") +-- +2.43.2 + 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.18.0.bb deleted file mode 100644 index 8aa8a29..0000000 --- a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.18.0.bb +++ /dev/null @@ -1,63 +0,0 @@ -SUMMARY = "bpftrace" -HOMEPAGE = "https://github.com/iovisor/bpftrace" -LICENSE = "Apache-2.0" -LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57" - -DEPENDS += "bison-native \ - flex-native \ - gzip-native \ - elfutils \ - bcc \ - systemtap \ - libcereal \ - libbpf \ - " -DEPENDS += "${@bb.utils.contains('PTEST_ENABLED', '1', 'pahole-native llvm-native', '', d)}" - -PV .= "+git${SRCREV}" -RDEPENDS:${PN} += "bash python3 xz" - -SRC_URI = "git://github.com/iovisor/bpftrace;branch=master;protocol=https \ - file://0001-cmake-Raise-max-llvm-major-version-to-16.patch \ - file://0001-Adjust-to-build-with-llvm-17.patch \ - file://0001-replace-python-with-python3-in-the-test.patch \ - file://run-ptest \ -" -SRCREV = "e199c7e73da84bff9fe744d1e3402c2b505aa5a2" - -S = "${WORKDIR}/git" - -inherit cmake ptest - -PACKAGECONFIG ?= "${@bb.utils.contains('PTEST_ENABLED', '1', 'tests', '', d)}" - -PACKAGECONFIG[tests] = "-DBUILD_TESTING=ON,-DBUILD_TESTING=OFF,gtest xxd-native" - -do_install_ptest() { - if [ -e ${B}/tests/bpftrace_test ]; then - install -Dm 755 ${B}/tests/bpftrace_test ${D}${PTEST_PATH}/tests/bpftrace_test - cp -rf ${B}/tests/runtime ${D}${PTEST_PATH}/tests - cp -rf ${B}/tests/test* ${D}${PTEST_PATH}/tests - fi -} - -def llvm_major_version(d): - pvsplit = d.getVar('LLVMVERSION').split('.') - return pvsplit[0] - -LLVM_MAJOR_VERSION = "${@llvm_major_version(d)}" - -EXTRA_OECMAKE = " \ - -DCMAKE_ENABLE_EXPORTS=1 \ - -DCMAKE_BUILD_TYPE=Release \ - -DLLVM_REQUESTED_VERSION=${LLVM_MAJOR_VERSION} \ - -DUSE_SYSTEM_BPF_BCC=ON \ - -DENABLE_MAN=OFF \ -" - -COMPATIBLE_HOST = "(x86_64.*|aarch64.*|powerpc64.*|riscv64.*)-linux" -COMPATIBLE_HOST:libc-musl = "null" - -INHIBIT_PACKAGE_STRIP_FILES += "\ - ${PKGD}${PTEST_PATH}/tests/testprogs/uprobe_test \ -" diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.20.1.bb b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.20.1.bb new file mode 100644 index 0000000..bc39afa --- /dev/null +++ b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.20.1.bb @@ -0,0 +1,64 @@ +SUMMARY = "bpftrace" +HOMEPAGE = "https://github.com/iovisor/bpftrace" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57" + +DEPENDS += "bison-native \ + flex-native \ + gzip-native \ + elfutils \ + bcc \ + systemtap \ + libcereal \ + libbpf \ + " +DEPENDS += "${@bb.utils.contains('PTEST_ENABLED', '1', 'pahole-native llvm-native', '', d)}" + +RDEPENDS:${PN} += "bash python3 xz" + +PV .= "+git" + +SRC_URI = "git://github.com/iovisor/bpftrace;branch=master;protocol=https \ + file://0001-replace-python-with-python3-in-the-test.patch \ + file://0002-ast-Repace-getInt8PtrTy-with-getPtrTy.patch \ + file://0003-ast-Adjust-to-enum-changes-in-llvm-18.patch \ + file://0004-cmake-Bump-max-LLVM-version-to-18.patch \ + file://run-ptest \ +" +SRCREV = "fe6362b4e2c1b9d0833c7d3f308c1d4006b54723" + +S = "${WORKDIR}/git" + +inherit cmake ptest + +PACKAGECONFIG ?= "${@bb.utils.contains('PTEST_ENABLED', '1', 'tests', '', d)}" + +PACKAGECONFIG[tests] = "-DBUILD_TESTING=ON,-DBUILD_TESTING=OFF,gtest xxd-native" + +do_install_ptest() { + if [ -e ${B}/tests/bpftrace_test ]; then + install -Dm 755 ${B}/tests/bpftrace_test ${D}${PTEST_PATH}/tests/bpftrace_test + cp -rf ${B}/tests/runtime ${D}${PTEST_PATH}/tests + cp -rf ${B}/tests/test* ${D}${PTEST_PATH}/tests + fi +} + +def llvm_major_version(d): + pvsplit = d.getVar('LLVMVERSION').split('.') + return pvsplit[0] + +LLVM_MAJOR_VERSION = "${@llvm_major_version(d)}" + +EXTRA_OECMAKE = " \ + -DCMAKE_ENABLE_EXPORTS=1 \ + -DCMAKE_BUILD_TYPE=Release \ + -DUSE_SYSTEM_BPF_BCC=ON \ + -DENABLE_MAN=OFF \ +" + +COMPATIBLE_HOST = "(x86_64.*|aarch64.*|powerpc64.*|riscv64.*)-linux" +COMPATIBLE_HOST:libc-musl = "null" + +INHIBIT_PACKAGE_STRIP_FILES += "\ + ${PKGD}${PTEST_PATH}/tests/testprogs/uprobe_test \ +" -- cgit v1.2.3-54-g00ecf