community/bpftrace: use llvm16

This commit is contained in:
psykose 2023-05-06 10:37:47 +00:00
parent 9a92e7bae6
commit c6dff4216e
2 changed files with 61 additions and 2 deletions

View File

@ -2,12 +2,12 @@
# Maintainer: Adam Jensen <adam@acj.sh>
pkgname=bpftrace
pkgver=0.17.1
pkgrel=0
pkgrel=1
pkgdesc="High-level tracing language for Linux eBPF"
url="https://github.com/iovisor/bpftrace"
arch="aarch64 ppc64le x86_64"
license="Apache-2.0"
_llvmver=15
_llvmver=16
makedepends="
asciidoctor
bcc-dev
@ -27,6 +27,7 @@ makedepends="
"
source="$pkgname-$pkgver.tar.gz::https://github.com/iovisor/bpftrace/archive/v$pkgver.tar.gz
10-link-libbpf.patch
llvm16.patch
"
# Tests require root, network to download gmock and a few tests fail.
# Stripping is done ourselves to keep the BEGIN_trigger symbol required
@ -81,4 +82,5 @@ tools_doc() {
sha512sums="
57f00a0b209d745efe5ce39d0e8efb90a21b5c499b41385814378d828ef507dc2c6d9497f9d23dbb610fcff21f077cba9f7481e7a6a6465825065743289ef4ad bpftrace-0.17.1.tar.gz
1f884e75ee7df8d28e8f613eca64cc56f859806c5a8d0f491c07709b0000be3a29be62a3eab6dfb04fcf9aadd1a4c3fde26e212ea0c40e5a54e59a197f148ed4 10-link-libbpf.patch
a7aba13fb7f60ce90571ea4f2078d2a64fcbd5067e950e4cf0bd961d9c4b1cce645b72834bb6ee6d073542c32c7e3e5fb3ae8d9f38cc96330972649a484f62c3 llvm16.patch
"

View File

@ -0,0 +1,57 @@
Patch-Source: https://github.com/iovisor/bpftrace/commit/70ee22cb14e2eedc5df17e53965824d7381f8e6f
https://github.com/iovisor/bpftrace/pull/2528
--
From 70ee22cb14e2eedc5df17e53965824d7381f8e6f Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 13 Mar 2023 21:30:27 -0700
Subject: [PATCH] ast: Use std::optional in CodegenLLVM::CodegenLLVM call
Fixes build with clang-16
src/ast/passes/codegen_llvm.cpp:63:53: error: use of undeclared identifier 'Optional'; did you mean 'std::optional'?
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
src/ast/passes/codegen_llvm.cpp | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e1221eb..f31c16f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -165,7 +165,7 @@ else()
endif()
set(MIN_LLVM_MAJOR 6)
- set(MAX_LLVM_MAJOR 15)
+ set(MAX_LLVM_MAJOR 16)
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/src/ast/passes/codegen_llvm.cpp b/src/ast/passes/codegen_llvm.cpp
index 4e2a18e..efeb416 100644
--- a/src/ast/passes/codegen_llvm.cpp
+++ b/src/ast/passes/codegen_llvm.cpp
@@ -56,11 +56,17 @@ CodegenLLVM::CodegenLLVM(Node *root, BPFtrace &bpftrace)
throw std::runtime_error(
"Could not find bpf llvm target, does your llvm support it?");
- target_machine_.reset(target->createTargetMachine(LLVMTargetTriple,
- "generic",
- "",
- TargetOptions(),
- Optional<Reloc::Model>()));
+ target_machine_.reset(
+ target->createTargetMachine(LLVMTargetTriple,
+ "generic",
+ "",
+ TargetOptions(),
+#if LLVM_VERSION_MAJOR >= 16
+ std::optional<Reloc::Model>()
+#else
+ Optional<Reloc::Model>()
+#endif
+ ));
target_machine_->setOptLevel(llvm::CodeGenOpt::Aggressive);
module_->setTargetTriple(LLVMTargetTriple);