aports/community/bpftrace/llvm16.patch
2023-05-06 12:37:47 +02:00

58 lines
2.3 KiB
Diff

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);