diff options
5 files changed, 33 insertions, 240 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 @@ | |||
1 | From e94da9ccbc099468df752227716880efef66411b Mon Sep 17 00:00:00 2001 | ||
2 | From: Nikita Popov <npopov@redhat.com> | ||
3 | Date: Thu, 27 Feb 2025 15:44:27 +0100 | ||
4 | Subject: [PATCH] clover: Don't include libclc headers | ||
5 | |||
6 | Per https://github.com/llvm/llvm-project/issues/119967 these | ||
7 | headers are internal implementation details of libclc and were | ||
8 | never supposed to be installed. They are not available anymore | ||
9 | since LLVM 20. Instead opencl-c.h should be used. | ||
10 | |||
11 | There already ise a code path for including opencl-c.h, so always | ||
12 | use it. | ||
13 | |||
14 | This didn't work for me out of the box, because the build system | ||
15 | currently hardcodes the clang resource directory, which is incorrect | ||
16 | for Fedora at least. Fix this by using GetResourcePath + | ||
17 | CLANG_RESOURCE_DIR provided by clang instead. This is basically | ||
18 | the same as what is done in clc_helper.c | ||
19 | |||
20 | I've still retained the old behavior as a fallback just in case | ||
21 | (e.g. if clang is linked statically?) | ||
22 | |||
23 | Upstream-Status: Submitted [https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33805/] | ||
24 | Reviewed-by: Karol Herbst <kherbst@redhat.com> | ||
25 | Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33805> | ||
26 | Signed-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 | |||
32 | diff --git a/src/gallium/frontends/clover/llvm/invocation.cpp b/src/gallium/frontends/clover/llvm/invocation.cpp | ||
33 | index 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(); | ||
120 | diff --git a/src/gallium/frontends/clover/meson.build b/src/gallium/frontends/clover/meson.build | ||
121 | index 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', | ||
diff --git a/meta/recipes-graphics/mesa/files/0001-dont-build-clover-frontend.patch b/meta/recipes-graphics/mesa/files/0001-dont-build-clover-frontend.patch new file mode 100644 index 0000000000..5f45f94fea --- /dev/null +++ b/meta/recipes-graphics/mesa/files/0001-dont-build-clover-frontend.patch | |||
@@ -0,0 +1,29 @@ | |||
1 | From: Markus Volk <f_l_k@t-online.de> | ||
2 | Date: Sun, 19 Mai 2025 15:34:46 +0100 | ||
3 | Subject: [PATCH] dont build clover frontend | ||
4 | |||
5 | The clover frontend is deprecated and is always built with opencl, even if | ||
6 | using rusticl. Additionally it adds a reproducibility issue. | ||
7 | |||
8 | Upstream-Status: Inappropriate [oe-specific] | ||
9 | Signed-off-by: Markus Volk <f_l_k@t-online.de> | ||
10 | |||
11 | --- a/src/gallium/meson.build 2025-05-07 18:35:10.000000000 +0200 | ||
12 | +++ b/src/gallium/meson.build 2025-05-18 17:05:23.677694272 +0200 | ||
13 | @@ -195,15 +195,11 @@ | ||
14 | else | ||
15 | driver_d3d12 = declare_dependency() | ||
16 | endif | ||
17 | -if with_gallium_clover or with_tests | ||
18 | +if with_tests | ||
19 | # At the moment, clover and gallium/tests are the only two consumers | ||
20 | # for pipe-loader | ||
21 | subdir('targets/pipe-loader') | ||
22 | endif | ||
23 | -if with_gallium_clover | ||
24 | - subdir('frontends/clover') | ||
25 | - subdir('targets/opencl') | ||
26 | -endif | ||
27 | if with_gallium_rusticl | ||
28 | subdir('frontends/rusticl') | ||
29 | subdir('targets/rusticl') | ||
diff --git a/meta/recipes-graphics/mesa/files/0001-gallium-clover-Do-not-use-LLVM_LIBRARY_DIR-for-FALLB.patch b/meta/recipes-graphics/mesa/files/0001-gallium-clover-Do-not-use-LLVM_LIBRARY_DIR-for-FALLB.patch deleted file mode 100644 index 8b2ce2f63b..0000000000 --- a/meta/recipes-graphics/mesa/files/0001-gallium-clover-Do-not-use-LLVM_LIBRARY_DIR-for-FALLB.patch +++ /dev/null | |||
@@ -1,34 +0,0 @@ | |||
1 | From 5ea5c5d48e049d7b10b7ffb814e84e3ddef7fff9 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Fri, 25 Apr 2025 19:00:14 -0700 | ||
4 | Subject: [PATCH] gallium/clover: Do not use LLVM_LIBRARY_DIR for | ||
5 | FALLBACK_CLANG_RESOURCE_DIR | ||
6 | |||
7 | This option -DFALLBACK_CLANG_RESOURCE_DIR is synthesized by meson from | ||
8 | LLVM_LIBRARY_DIR which is resolved to absolute path under <recipe_sysroot> | ||
9 | and its used in clover front-end as string in .c files, which encodes it | ||
10 | into binary as string and shows up in yocto QA error. | ||
11 | |||
12 | ERROR: mesa-2_25.0.2-r0 do_package_qa: QA Issue: File /usr/lib/libMesaOpenCL.so.1.0.0 in package libopencl-mesa contains reference to TMPDIR [buildpaths] | ||
13 | ERROR: mesa-2_25.0.2-r0 do_package_qa: Fatal QA errors were found, failing task. | ||
14 | ERROR: Logfile of failure stored in: /mnt/b/yoe/master/sources/poky/build/tmp/work/cortexa57-poky-linux/mesa/25.0.2/temp/log.do_package_qa.974870 | ||
15 | |||
16 | Upstream-Status: Inappropriate [OE-Specific] | ||
17 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
18 | --- | ||
19 | src/gallium/frontends/clover/meson.build | 2 +- | ||
20 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
21 | |||
22 | diff --git a/src/gallium/frontends/clover/meson.build b/src/gallium/frontends/clover/meson.build | ||
23 | index 56a9894..32c21d6 100644 | ||
24 | --- a/src/gallium/frontends/clover/meson.build | ||
25 | +++ b/src/gallium/frontends/clover/meson.build | ||
26 | @@ -43,7 +43,7 @@ libclllvm = static_library( | ||
27 | clover_cpp_args, | ||
28 | clover_opencl_cpp_args, | ||
29 | '-DFALLBACK_CLANG_RESOURCE_DIR="@0@"'.format(join_paths( | ||
30 | - dep_llvm.get_variable(cmake : 'LLVM_LIBRARY_DIR', configtool: 'libdir'), 'clang', | ||
31 | + '/usr/lib/clang', | ||
32 | dep_llvm.version() | ||
33 | )), | ||
34 | ], | ||
diff --git a/meta/recipes-graphics/mesa/files/0001-mesa-clc-add-an-option-to-force-inclusion-of-OpenCL-.patch b/meta/recipes-graphics/mesa/files/0001-mesa-clc-add-an-option-to-force-inclusion-of-OpenCL-.patch deleted file mode 100644 index d65ba574d2..0000000000 --- a/meta/recipes-graphics/mesa/files/0001-mesa-clc-add-an-option-to-force-inclusion-of-OpenCL-.patch +++ /dev/null | |||
@@ -1,57 +0,0 @@ | |||
1 | From f9b6175e7c446a82c568ff1a214885d707c95f49 Mon Sep 17 00:00:00 2001 | ||
2 | From: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> | ||
3 | Date: Wed, 16 Apr 2025 14:35:37 +0300 | ||
4 | Subject: [PATCH] mesa-clc: add an option to force inclusion of OpenCL headers | ||
5 | |||
6 | Currently mesa-clc bundles OpenCL headers from Clang only if the static | ||
7 | LLVM is used (which means Clang / LLVM are not present on the target | ||
8 | system). In some cases (e.g. when building in OpenEmbedded environemnt) | ||
9 | it is desirable to have shared LLVM library, but skip installing the | ||
10 | whole Clang runtime just to compile shaders. Add an option that forces | ||
11 | OpenCL headers to be bundled with the mesa-clc binary. | ||
12 | |||
13 | Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> | ||
14 | Upstream-Status: Submitted [https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34551] | ||
15 | --- | ||
16 | meson_options.txt | 10 ++++++++++ | ||
17 | src/compiler/clc/meson.build | 3 ++- | ||
18 | 2 files changed, 12 insertions(+), 1 deletion(-) | ||
19 | |||
20 | diff --git a/meson_options.txt b/meson_options.txt | ||
21 | index 18da31eff507..addd274ecef7 100644 | ||
22 | --- a/meson_options.txt | ||
23 | +++ b/meson_options.txt | ||
24 | @@ -797,6 +797,16 @@ option( | ||
25 | description : 'Install the mesa-clc compiler (if needed for cross builds).' | ||
26 | ) | ||
27 | |||
28 | +option( | ||
29 | + 'mesa-clc-bundle-headers', | ||
30 | + type : 'combo', | ||
31 | + value : 'auto', | ||
32 | + choices : [ | ||
33 | + 'enabled', 'auto' | ||
34 | + ], | ||
35 | + description : 'Bundle the OpenCL headers into the mesa-clc binary (default to bundle if static LLVM is used). Note, it might require rebuilding mesa-clc if opencl-c.h or opencl-c-base.h are changed (e.g. on Clang upgrades).' | ||
36 | +) | ||
37 | + | ||
38 | option( | ||
39 | 'precomp-compiler', | ||
40 | type : 'combo', | ||
41 | diff --git a/src/compiler/clc/meson.build b/src/compiler/clc/meson.build | ||
42 | index 263eba527191..9ff61440f0da 100644 | ||
43 | --- a/src/compiler/clc/meson.build | ||
44 | +++ b/src/compiler/clc/meson.build | ||
45 | @@ -11,7 +11,8 @@ _libmesaclc_c_args = [] | ||
46 | _libmesaclc_cpp_args = ['-DLLVM_LIB_DIR="@0@"'.format(llvm_libdir)] | ||
47 | _libmesaclc_sources = [] | ||
48 | |||
49 | -if not _shared_llvm | ||
50 | +if not _shared_llvm or \ | ||
51 | + get_option('mesa-clc-bundle-headers') == 'enabled' | ||
52 | # LLVM 16 moved clang header path from using full version to only major version | ||
53 | if dep_llvm.version().version_compare('< 16') | ||
54 | # Prior to LLVM 16, this path used a full version | ||
55 | -- | ||
56 | 2.47.2 | ||
57 | |||
diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-graphics/mesa/mesa.inc index 288027bbb9..47edf0d512 100644 --- a/meta/recipes-graphics/mesa/mesa.inc +++ b/meta/recipes-graphics/mesa/mesa.inc | |||
@@ -17,13 +17,11 @@ PE = "2" | |||
17 | SRC_URI = "https://archive.mesa3d.org/mesa-${PV}.tar.xz \ | 17 | SRC_URI = "https://archive.mesa3d.org/mesa-${PV}.tar.xz \ |
18 | file://0001-meson-misdetects-64bit-atomics-on-mips-clang.patch \ | 18 | file://0001-meson-misdetects-64bit-atomics-on-mips-clang.patch \ |
19 | file://0001-freedreno-don-t-encode-build-path-into-binaries.patch \ | 19 | file://0001-freedreno-don-t-encode-build-path-into-binaries.patch \ |
20 | file://0001-mesa-clc-add-an-option-to-force-inclusion-of-OpenCL-.patch \ | 20 | file://0001-dont-build-clover-frontend.patch \ |
21 | file://0001-clover-Don-t-include-libclc-headers.patch \ | ||
22 | file://0001-gallium-clover-Do-not-use-LLVM_LIBRARY_DIR-for-FALLB.patch \ | ||
23 | " | 21 | " |
24 | 22 | ||
25 | SRC_URI[sha256sum] = "c0d245dea0aa4b49f74b3d474b16542e4a8799791cd33d676c69f650ad4378d0" | 23 | SRC_URI[sha256sum] = "b1c45888969ee5df997e2542654f735ab1b772924b442f3016d2293414c99c14" |
26 | PV = "25.0.5" | 24 | PV = "25.1.0" |
27 | 25 | ||
28 | UPSTREAM_CHECK_GITTAGREGEX = "mesa-(?P<pver>\d+(\.\d+)+)" | 26 | UPSTREAM_CHECK_GITTAGREGEX = "mesa-(?P<pver>\d+(\.\d+)+)" |
29 | 27 | ||
@@ -343,7 +341,7 @@ FILES:mesa-megadriver = "${libdir}/dri/* ${datadir}/drirc.d" | |||
343 | FILES:mesa-vulkan-drivers = "${libdir}/libvulkan_*.so ${libdir}/libpowervr_rogue.so ${datadir}/vulkan" | 341 | FILES:mesa-vulkan-drivers = "${libdir}/libvulkan_*.so ${libdir}/libpowervr_rogue.so ${datadir}/vulkan" |
344 | FILES:${PN}-vdpau-drivers = "${libdir}/vdpau/*.so.*" | 342 | FILES:${PN}-vdpau-drivers = "${libdir}/vdpau/*.so.*" |
345 | FILES:libegl-mesa = "${libdir}/libEGL*.so.* ${datadir}/glvnd/egl_vendor.d" | 343 | FILES:libegl-mesa = "${libdir}/libEGL*.so.* ${datadir}/glvnd/egl_vendor.d" |
346 | FILES:libgbm = "${libdir}/libgbm.so.* ${libdir}/gbm/*_gbm.so" | 344 | FILES:libgbm = "${libdir}/libgbm.so.* ${libdir}/gbm/*_gbm.so ${includedir}/gbm_backend_abi.h" |
347 | FILES:libgallium = "${libdir}/libgallium-*.so" | 345 | FILES:libgallium = "${libdir}/libgallium-*.so" |
348 | FILES:libgles1-mesa = "${libdir}/libGLESv1*.so.*" | 346 | FILES:libgles1-mesa = "${libdir}/libGLESv1*.so.*" |
349 | FILES:libgles2-mesa = "${libdir}/libGLESv2.so.*" | 347 | FILES:libgles2-mesa = "${libdir}/libGLESv2.so.*" |