I tested the upstream patch with clang 19, and it worked just fine
here.  I pushed the patch to salsa.

diff --git a/debian/patches/0002-clang-21.patch 
b/debian/patches/0002-clang-21.patch
new file mode 100644
index 00000000..f8e7eb04
--- /dev/null
+++ b/debian/patches/0002-clang-21.patch
@@ -0,0 +1,46 @@
+commit 8c5c96ad3beeed2fa827017f451a952306826974
+Author: yonghong-song <[email protected]>
+Date:   Mon Jul 14 20:21:59 2025 -0700
+Origin: 
https://github.com/iovisor/bcc/commit/8c5c96ad3beeed2fa827017f451a952306826974
+Bug-Debian: https://bugs.debian.org/1122606
+Forwarded: not-needed
+Last-Update: 2025-12-20
+
+    Fix a build failure with clang21 (#5369)
+    
+    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.
+
+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
+ 
diff --git a/debian/patches/series b/debian/patches/series
index 21b3c377..6a302de5 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -3,3 +3,4 @@ fix-install-path.patch
 2002_fix_netqtop.c_path.patch
 2003-libbpf-tools-debian.patch
 0001-Cleanup-existing-temporary-kernel-headers-path.patch
+0002-clang-21.patch

-- 
Happy hacking
Petter Reinholdtsen

Reply via email to