Rebuild for LLMV 16

Resolves: rhbz#2192953

Signed-off-by: Viktor Malik <vmalik@redhat.com>
This commit is contained in:
Viktor Malik 2023-05-15 08:31:25 +02:00
parent 2fbe8b0169
commit bde7b370c7
No known key found for this signature in database
GPG Key ID: AF7A2E1F6EE74FB3
4 changed files with 123 additions and 1 deletions

View File

@ -0,0 +1,44 @@
From 1632c1fb41d03730a5106696c4fed64cd4a86785 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 1/3] 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/src/ast/passes/codegen_llvm.cpp b/src/ast/passes/codegen_llvm.cpp
index 4e2a18e1..efeb4160 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);
--
2.40.1

View File

@ -0,0 +1,46 @@
From 6a1eb84833fd40e9aa49b610089c6ce11f38ba43 Mon Sep 17 00:00:00 2001
From: Viktor Malik <viktor.malik@gmail.com>
Date: Wed, 10 May 2023 13:30:59 +0200
Subject: [PATCH 1/2] Set cmake policy for CMP0057
Building with LLVM16 fails with the error:
CMake Warning (dev) at /usr/lib/llvm-16/lib/cmake/llvm/LLVM-Config.cmake:230 (if):
Policy CMP0057 is not set: Support new IN_LIST if() operator. Run "cmake
--help-policy CMP0057" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.
IN_LIST will be interpreted as an operator when the policy is set to NEW.
Since the policy is not set the OLD behavior will be used.
Call Stack (most recent call first):
cmake/clang_libs.cmake:32 (llvm_map_components_to_libnames)
src/cc/CMakeLists.txt:126 (include)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Error at /usr/lib/llvm-16/lib/cmake/llvm/LLVM-Config.cmake:230 (if):
if given arguments:
"engine" "IN_LIST" "link_components"
Unknown arguments specified
Set cmake policy for CMP0057 explicitly.
---
CMakeLists.txt | 2 ++
1 file changed, 2 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0a7914f5..045e9d97 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,8 @@
cmake_minimum_required(VERSION 3.13.0)
project(bpftrace)
+cmake_policy(SET CMP0057 NEW)
+
# bpftrace version number components.
set(bpftrace_VERSION_MAJOR 0)
set(bpftrace_VERSION_MINOR 17)
--
2.40.1

View File

@ -0,0 +1,26 @@
From 359a4067c96580cd6d11202ea1ea97a72b4db650 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Fri, 10 Mar 2023 00:08:27 -0800
Subject: [PATCH 2/2] cmake: Raise max llvm major version to 16
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 045e9d97..88867b5b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -167,7 +167,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}")
--
2.40.1

View File

@ -1,6 +1,6 @@
Name: bpftrace
Version: 0.17.0
Release: 1%{?dist}
Release: 2%{?dist}
Summary: High-level tracing language for Linux eBPF
License: ASL 2.0
@ -15,6 +15,9 @@ Source1: https://github.com/USCiLab/cereal/archive/v%{cereal_version}/cer
Patch0: %{name}-%{version}-0001-Parse-kernel-configuration.patch
Patch1: %{name}-%{version}-0002-arm64-define-the-KASAN_SHADOW_SCALE_SHIFT-macro.patch
Patch2: %{name}-%{version}-0003-ast-Use-std-optional-in-CodegenLLVM-CodegenLLVM-call.patch
Patch3: %{name}-%{version}-0004-Set-cmake-policy-for-CMP0057.patch
Patch4: %{name}-%{version}-0005-cmake-Raise-max-llvm-major-version-to-16.patch
Patch10: %{name}-%{version}-RHEL-aarch64-fixes-statsnoop-and-opensnoop.patch
@ -96,6 +99,9 @@ find %{buildroot}%{_datadir}/%{name}/tools -type f -exec \
%exclude %{_datadir}/%{name}/tools/old
%changelog
* Mon May 15 2023 Viktor Malik <vmalik@redhat.com> - 0.17.0-2
- Rebuild for LLVM 16 (rhbz#2192953)
* Tue Mar 14 2023 Viktor Malik <vmalik@redhat.com> - 0.17.0-1
- Rebase on bpftrace 0.17.0 (RHEL-286)
- Fix runqlat.bt, tcpdrop.bt, and undump.bt on aarch64 (rhbz#2170838)