From a482ec7f05d2aeac29dc696cbd17e12693ad1393 Mon Sep 17 00:00:00 2001
From: Karol Herbst <kherbst@redhat.com>
Date: Sat, 7 Jun 2025 10:13:06 +0200
Subject: [PATCH] clc: fix DiagnosticOptions related build failure with llvm-21

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13257
Cc: mesa-stable
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35399>
---
 src/compiler/clc/clc_helpers.cpp | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git src/compiler/clc/clc_helpers.cpp src/compiler/clc/clc_helpers.cpp
index 2920f7325ed3..d3629ceccebd 100644
--- src/compiler/clc/clc_helpers.cpp
+++ src/compiler/clc/clc_helpers.cpp
@@ -804,11 +804,17 @@ clc_compile_to_llvm_module(LLVMContext &llvm_ctx,
       c->addDependencyCollector(dep);
    }
 
+#if LLVM_VERSION_MAJOR >= 21
+   auto diag_opts = c->getDiagnosticOpts();
+#else
+   auto diag_opts = &c->getDiagnosticOpts();
+#endif
+
    clang::DiagnosticsEngine diag {
       new clang::DiagnosticIDs,
-      new clang::DiagnosticOptions,
+      diag_opts,
       new clang::TextDiagnosticPrinter(diag_log_stream,
-                                       &c->getDiagnosticOpts())
+                                       diag_opts)
    };
 
 #if LLVM_VERSION_MAJOR >= 17
@@ -865,7 +871,7 @@ clc_compile_to_llvm_module(LLVMContext &llvm_ctx,
 #endif
                    new clang::TextDiagnosticPrinter(
                            diag_log_stream,
-                           &c->getDiagnosticOpts()));
+                           diag_opts));
 
    c->setTarget(clang::TargetInfo::CreateTargetInfo(
 #if LLVM_VERSION_MAJOR >= 21
-- 
GitLab

