bcc: Fix build with LLVM/Clang 21

Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Khem Raj 2025-08-29 16:16:43 -07:00
parent 59f2556edd
commit ec3c60bd9f
No known key found for this signature in database
GPG Key ID: BB053355919D3314
2 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1,50 @@
From 2e3997121af597f3a54d97505a38b7fdb9febae3 Mon Sep 17 00:00:00 2001
From: yonghong-song <ys114321@gmail.com>
Date: Mon, 14 Jul 2025 20:21:59 -0700
Subject: [PATCH] Fix a build failure with clang21 (#5369)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The build error message:
src/cc/frontends/clang/loader.cc:400:73: error: no matching function for
call to clang::TextDiagnosticPrinter::TextDiagnosticPrinter(
llvm::raw_fd_ostream&, clang::DiagnosticOptions*)
400 | auto diag_client = new TextDiagnosticPrinter(llvm::errs(), &*diag_opts);
| ^
The llvm commit
https://github.com/llvm/llvm-project/pull/139584
caused the build failure.
Adjust the code properly and the error is fixed.
Upstream-Status: Backport [https://github.com/iovisor/bcc/commit/8c5c96ad3beeed2fa827017f451a952306826974]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
src/cc/frontends/clang/loader.cc | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/cc/frontends/clang/loader.cc b/src/cc/frontends/clang/loader.cc
index 07dc9d6a..6f8387aa 100644
--- a/src/cc/frontends/clang/loader.cc
+++ b/src/cc/frontends/clang/loader.cc
@@ -396,11 +396,19 @@ int ClangLoader::do_compile(
flags_cstr_rem.end());
// set up the error reporting class
+#if LLVM_VERSION_MAJOR >= 21
+ DiagnosticOptions diag_opts;
+ auto diag_client = new TextDiagnosticPrinter(llvm::errs(), diag_opts);
+
+ IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
+ DiagnosticsEngine diags(DiagID, diag_opts, diag_client);
+#else
IntrusiveRefCntPtr<DiagnosticOptions> diag_opts(new DiagnosticOptions());
auto diag_client = new TextDiagnosticPrinter(llvm::errs(), &*diag_opts);
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
DiagnosticsEngine diags(DiagID, &*diag_opts, diag_client);
+#endif
// set up the command line argument wrapper

View File

@ -21,6 +21,7 @@ RDEPENDS:${PN}-ptest = "kernel-devsrc packagegroup-core-buildessential cmake bas
SRC_URI = "gitsm://github.com/iovisor/bcc;branch=master;protocol=https;tag=v${PV} \
file://0001-CMakeLists.txt-override-the-PY_CMD_ESCAPED.patch \
file://0001-Vendor-just-enough-extra-headers-to-allow-libbpf-to-.patch \
file://0001-Fix-a-build-failure-with-clang21-5369.patch \
file://run-ptest \
file://ptest_wrapper.sh \
file://fix_for_memleak.patch \