summaryrefslogtreecommitdiffstats
path: root/meta/recipes-graphics/mesa/files/0001-clover-Don-t-include-libclc-headers.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-graphics/mesa/files/0001-clover-Don-t-include-libclc-headers.patch')
-rw-r--r--meta/recipes-graphics/mesa/files/0001-clover-Don-t-include-libclc-headers.patch143
1 files changed, 0 insertions, 143 deletions
diff --git a/meta/recipes-graphics/mesa/files/0001-clover-Don-t-include-libclc-headers.patch b/meta/recipes-graphics/mesa/files/0001-clover-Don-t-include-libclc-headers.patch
deleted file mode 100644
index 0f9a01d823..0000000000
--- a/meta/recipes-graphics/mesa/files/0001-clover-Don-t-include-libclc-headers.patch
+++ /dev/null
@@ -1,143 +0,0 @@
1From e94da9ccbc099468df752227716880efef66411b Mon Sep 17 00:00:00 2001
2From: Nikita Popov <npopov@redhat.com>
3Date: Thu, 27 Feb 2025 15:44:27 +0100
4Subject: [PATCH] clover: Don't include libclc headers
5
6Per https://github.com/llvm/llvm-project/issues/119967 these
7headers are internal implementation details of libclc and were
8never supposed to be installed. They are not available anymore
9since LLVM 20. Instead opencl-c.h should be used.
10
11There already ise a code path for including opencl-c.h, so always
12use it.
13
14This didn't work for me out of the box, because the build system
15currently hardcodes the clang resource directory, which is incorrect
16for Fedora at least. Fix this by using GetResourcePath +
17CLANG_RESOURCE_DIR provided by clang instead. This is basically
18the same as what is done in clc_helper.c
19
20I've still retained the old behavior as a fallback just in case
21(e.g. if clang is linked statically?)
22
23Upstream-Status: Submitted [https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33805/]
24Reviewed-by: Karol Herbst <kherbst@redhat.com>
25Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33805>
26Signed-off-by: Khem Raj <raj.khem@gmail.com>
27---
28 .../frontends/clover/llvm/invocation.cpp | 53 +++++++++++++------
29 src/gallium/frontends/clover/meson.build | 5 +-
30 2 files changed, 39 insertions(+), 19 deletions(-)
31
32diff --git a/src/gallium/frontends/clover/llvm/invocation.cpp b/src/gallium/frontends/clover/llvm/invocation.cpp
33index 3cbb05b..ca030b4 100644
34--- a/src/gallium/frontends/clover/llvm/invocation.cpp
35+++ b/src/gallium/frontends/clover/llvm/invocation.cpp
36@@ -24,6 +24,8 @@
37 // OTHER DEALINGS IN THE SOFTWARE.
38 //
39
40+#include <dlfcn.h>
41+
42 #include <llvm/IR/DiagnosticPrinter.h>
43 #include <llvm/IR/DiagnosticInfo.h>
44 #include <llvm/IR/LLVMContext.h>
45@@ -39,6 +41,8 @@
46 #include <clang/Frontend/TextDiagnosticBuffer.h>
47 #include <clang/Frontend/TextDiagnosticPrinter.h>
48 #include <clang/Basic/TargetInfo.h>
49+#include <clang/Config/config.h>
50+#include <clang/Driver/Driver.h>
51
52 #if LLVM_VERSION_MAJOR >= 20
53 #include <llvm/Support/VirtualFileSystem.h>
54@@ -323,6 +327,30 @@ namespace {
55 return c;
56 }
57
58+ std::string getResourceDirectory() {
59+ Dl_info info;
60+ if (dladdr((void *)clang::CompilerInvocation::CreateFromArgs, &info) == 0) {
61+ return FALLBACK_CLANG_RESOURCE_DIR;
62+ }
63+
64+ char *libclang_path = realpath(info.dli_fname, NULL);
65+ if (libclang_path == nullptr) {
66+ return FALLBACK_CLANG_RESOURCE_DIR;
67+ }
68+
69+ // GetResourcePath is a way to retrieve the actual libclang resource dir based on a given
70+ // binary or library.
71+ std::string clang_resource_dir =
72+#if LLVM_VERSION_MAJOR >= 20
73+ clang::driver::Driver::GetResourcesPath(std::string(libclang_path));
74+#else
75+ clang::driver::Driver::GetResourcesPath(std::string(libclang_path), CLANG_RESOURCE_DIR);
76+#endif
77+ free(libclang_path);
78+
79+ return clang_resource_dir;
80+ }
81+
82 std::unique_ptr<Module>
83 compile(LLVMContext &ctx, clang::CompilerInstance &c,
84 const std::string &name, const std::string &source,
85@@ -331,25 +359,18 @@ namespace {
86 c.getFrontendOpts().ProgramAction = clang::frontend::EmitLLVMOnly;
87 c.getHeaderSearchOpts().UseBuiltinIncludes = true;
88 c.getHeaderSearchOpts().UseStandardSystemIncludes = true;
89- c.getHeaderSearchOpts().ResourceDir = CLANG_RESOURCE_DIR;
90
91- if (use_libclc) {
92- // Add libclc generic search path
93- c.getHeaderSearchOpts().AddPath(LIBCLC_INCLUDEDIR,
94- clang::frontend::Angled,
95- false, false);
96+ std::string clang_resource_dir = getResourceDirectory();
97+ c.getHeaderSearchOpts().ResourceDir = clang_resource_dir;
98
99- // Add libclc include
100- c.getPreprocessorOpts().Includes.push_back("clc/clc.h");
101- } else {
102- // Add opencl-c generic search path
103- c.getHeaderSearchOpts().AddPath(CLANG_RESOURCE_DIR,
104- clang::frontend::Angled,
105- false, false);
106+ // Add opencl-c generic search path
107+ std::string clang_include_path = clang_resource_dir + "/include";
108+ c.getHeaderSearchOpts().AddPath(clang_include_path,
109+ clang::frontend::Angled,
110+ false, false);
111
112- // Add opencl include
113- c.getPreprocessorOpts().Includes.push_back("opencl-c.h");
114- }
115+ // Add opencl include
116+ c.getPreprocessorOpts().Includes.push_back("opencl-c.h");
117
118 // Add definition for the OpenCL version
119 const auto dev_version = dev.device_version();
120diff --git a/src/gallium/frontends/clover/meson.build b/src/gallium/frontends/clover/meson.build
121index e569b86..56a9894 100644
122--- a/src/gallium/frontends/clover/meson.build
123+++ b/src/gallium/frontends/clover/meson.build
124@@ -10,7 +10,6 @@ clover_opencl_cpp_args = [
125 '-DCL_USE_DEPRECATED_OPENCL_2_0_APIS',
126 '-DCL_USE_DEPRECATED_OPENCL_2_1_APIS',
127 '-DCL_USE_DEPRECATED_OPENCL_2_2_APIS',
128- '-DLIBCLC_INCLUDEDIR="@0@/"'.format(dep_clc.get_variable(pkgconfig : 'includedir')),
129 '-DLIBCLC_LIBEXECDIR="@0@/"'.format(dep_clc.get_variable(pkgconfig : 'libexecdir'))
130 ]
131 clover_incs = [inc_include, inc_src, inc_gallium, inc_gallium_aux]
132@@ -43,9 +42,9 @@ libclllvm = static_library(
133 cpp_args : [
134 clover_cpp_args,
135 clover_opencl_cpp_args,
136- '-DCLANG_RESOURCE_DIR="@0@"'.format(join_paths(
137+ '-DFALLBACK_CLANG_RESOURCE_DIR="@0@"'.format(join_paths(
138 dep_llvm.get_variable(cmake : 'LLVM_LIBRARY_DIR', configtool: 'libdir'), 'clang',
139- dep_llvm.version(), 'include',
140+ dep_llvm.version()
141 )),
142 ],
143 gnu_symbol_visibility : 'hidden',