From: "Zoltán Böszörményi" <zboszor@gmail.com>
To: openembedded-core@lists.openembedded.org
Cc: "Mathieu Dubois-Briand" <mathieu.dubois-briand@bootlin.com>,
"Zoltán Böszörményi" <zboszor@gmail.com>
Subject: [PATCH v2 3/3] mesa, mesa-tools-native: Use mesa-libclc
Date: Sun, 19 Jul 2026 10:01:08 +0200 [thread overview]
Message-ID: <20260719080108.1290998-3-zboszor@gmail.com> (raw)
In-Reply-To: <20260719080108.1290998-1-zboszor@gmail.com>
Backport two patches from
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/43020
to use mesa-libclc, which makes Rusticl's OpenCL C more correct.
Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
---
...-optional-for-configs-not-needing-it.patch | 123 ++++++++++++++++++
...lc-use-our-downstream-fork-of-libclc.patch | 43 ++++++
.../mesa/mesa-tools-native.bb | 2 +-
meta/recipes-graphics/mesa/mesa.inc | 6 +-
4 files changed, 171 insertions(+), 3 deletions(-)
create mode 100644 meta/recipes-graphics/mesa/files/0001-clc-make-libclc-optional-for-configs-not-needing-it.patch
create mode 100644 meta/recipes-graphics/mesa/files/0002-clc-use-our-downstream-fork-of-libclc.patch
diff --git a/meta/recipes-graphics/mesa/files/0001-clc-make-libclc-optional-for-configs-not-needing-it.patch b/meta/recipes-graphics/mesa/files/0001-clc-make-libclc-optional-for-configs-not-needing-it.patch
new file mode 100644
index 0000000000..a52931dbf5
--- /dev/null
+++ b/meta/recipes-graphics/mesa/files/0001-clc-make-libclc-optional-for-configs-not-needing-it.patch
@@ -0,0 +1,123 @@
+From 5df2fb59c32fd6e3ad53bdaf98afccfddbdd14fc Mon Sep 17 00:00:00 2001
+From: Karol Herbst <kherbst@redhat.com>
+Date: Fri, 17 Jul 2026 17:45:45 +0200
+Subject: [PATCH 1/2] clc: make libclc optional for configs not needing it
+
+Upstream-Status: Submitted [https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/43020]
+---
+ meson.build | 2 +-
+ src/compiler/clc/meson.build | 73 +++++++++++++++++++-----------------
+ 2 files changed, 39 insertions(+), 36 deletions(-)
+
+diff --git a/meson.build b/meson.build
+index 1eca91fc940..68bbb942b99 100644
+--- a/meson.build
++++ b/meson.build
+@@ -949,7 +949,7 @@ with_poly = [
+ ].contains(true)
+
+ dep_clc = null_dep
+-if with_clc
++if with_gallium_rusticl or with_microsoft_clc
+ dep_clc = dependency('libclc')
+ endif
+
+diff --git a/src/compiler/clc/meson.build b/src/compiler/clc/meson.build
+index 9ff61440f0d..249fd31f478 100644
+--- a/src/compiler/clc/meson.build
++++ b/src/compiler/clc/meson.build
+@@ -4,7 +4,6 @@
+ files_libmesaclc = files(
+ 'clc.c',
+ 'clc_helpers.cpp',
+- 'nir_load_libclc.c',
+ )
+
+ _libmesaclc_c_args = []
+@@ -41,45 +40,49 @@ if not _shared_llvm or \
+ _libmesaclc_cpp_args += ['-DUSE_STATIC_OPENCL_C_H=1']
+ endif
+
+-_basedir = dep_clc.get_variable(pkgconfig : 'libexecdir')
++if dep_clc.found()
++ files_libmesaclc += 'nir_load_libclc.c'
+
+-_static_libclc = get_option('static-libclc')
+-if _static_libclc.length() > 0
+- if _static_libclc.contains('all')
+- _static_libclc = ['spirv', 'spirv64']
+- endif
+- prog_zstd = find_program('zstd', required : false, native : true)
+- _zstd_static_libclc = dep_zstd.found() and prog_zstd.found()
+- if _zstd_static_libclc
+- _libmesaclc_c_args += '-DHAVE_STATIC_LIBCLC_ZSTD'
+- endif
+- foreach s : _static_libclc
+- _libmesaclc_c_args += '-DHAVE_STATIC_LIBCLC_@0@'.format(s.to_upper())
+- f = '@0@-mesa3d-.spv'.format(s)
+- _libclc_file = _basedir / f
++ _basedir = dep_clc.get_variable(pkgconfig : 'libexecdir')
++
++ _static_libclc = get_option('static-libclc')
++ if _static_libclc.length() > 0
++ if _static_libclc.contains('all')
++ _static_libclc = ['spirv', 'spirv64']
++ endif
++ prog_zstd = find_program('zstd', required : false, native : true)
++ _zstd_static_libclc = dep_zstd.found() and prog_zstd.found()
+ if _zstd_static_libclc
+- _libclc_file = custom_target(
+- '@0@.zstd'.format(f),
+- command : [prog_zstd, '-f', '@INPUT@', '-o', '@OUTPUT@'],
++ _libmesaclc_c_args += '-DHAVE_STATIC_LIBCLC_ZSTD'
++ endif
++ foreach s : _static_libclc
++ _libmesaclc_c_args += '-DHAVE_STATIC_LIBCLC_@0@'.format(s.to_upper())
++ f = '@0@-mesa3d-.spv'.format(s)
++ _libclc_file = _basedir / f
++ if _zstd_static_libclc
++ _libclc_file = custom_target(
++ '@0@.zstd'.format(f),
++ command : [prog_zstd, '-f', '@INPUT@', '-o', '@OUTPUT@'],
++ input : [_libclc_file],
++ output : '@0@.zstd'.format(f),
++ )
++ endif
++ files_libmesaclc += custom_target(
++ '@0@.h'.format(f),
++ command : [
++ prog_python, files_xxd, '-b', '@INPUT@', '@OUTPUT@',
++ '-n', 'libclc_@0@_mesa3d_spv'.format(s),
++ ],
+ input : [_libclc_file],
+- output : '@0@.zstd'.format(f),
++ output : '@0@.h'.format(f),
++ depend_files : files_xxd,
+ )
++ endforeach
++ else
++ _libmesaclc_c_args += ['-DDYNAMIC_LIBCLC_PATH="@0@/"'.format(_basedir)]
++ if not cc.has_function('mmap')
++ error('mmap required for dynamic libCLC loading')
+ endif
+- files_libmesaclc += custom_target(
+- '@0@.h'.format(f),
+- command : [
+- prog_python, files_xxd, '-b', '@INPUT@', '@OUTPUT@',
+- '-n', 'libclc_@0@_mesa3d_spv'.format(s),
+- ],
+- input : [_libclc_file],
+- output : '@0@.h'.format(f),
+- depend_files : files_xxd,
+- )
+- endforeach
+-else
+- _libmesaclc_c_args += ['-DDYNAMIC_LIBCLC_PATH="@0@/"'.format(_basedir)]
+- if not cc.has_function('mmap')
+- error('mmap required for dynamic libCLC loading')
+ endif
+ endif
+
+--
+2.55.0
+
diff --git a/meta/recipes-graphics/mesa/files/0002-clc-use-our-downstream-fork-of-libclc.patch b/meta/recipes-graphics/mesa/files/0002-clc-use-our-downstream-fork-of-libclc.patch
new file mode 100644
index 0000000000..39e120b036
--- /dev/null
+++ b/meta/recipes-graphics/mesa/files/0002-clc-use-our-downstream-fork-of-libclc.patch
@@ -0,0 +1,43 @@
+From 8bda7974958e5ba56b0eec25a7876c004b6b743b Mon Sep 17 00:00:00 2001
+From: Karol Herbst <kherbst@redhat.com>
+Date: Thu, 16 Jul 2026 21:20:52 +0200
+Subject: [PATCH 2/2] clc: use our downstream fork of libclc
+
+There are a couple of issues with the upstream versions and release
+schedules and overall experience makes it dificult for us to rely on
+users using a proper functional implementation.
+
+And we want to ship a conformant OpenCL implementation here and that's
+difficult if users run untested libclc versions or libclc with known bugs
+that aren't going to get fixed upstream because the release is already
+EoL.
+
+Backport-to: *
+Upstream-Status: Submitted [https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/43020]
+---
+ meson.build | 9 ++++++++-
+ 1 file changed, 8 insertions(+), 1 deletion(-)
+
+diff --git a/meson.build b/meson.build
+index 68bbb942b99..6e2590cc2c6 100644
+--- a/meson.build
++++ b/meson.build
+@@ -950,7 +950,14 @@ with_poly = [
+
+ dep_clc = null_dep
+ if with_gallium_rusticl or with_microsoft_clc
+- dep_clc = dependency('libclc')
++ dep_clc = dependency('mesa-libclc', required : false,
++ not_found_message :
++ 'mesa-libclc not found. Build will fall back to upstream libclc, however ' +
++ 'certain versions are known to contain bugs that make OpenCL builtins ' +
++ 'return incorrect results.')
++ if not dep_clc.found()
++ dep_clc = dependency('libclc')
++ endif
+ endif
+
+ gl_pkgconfig_c_flags = []
+--
+2.55.0
+
diff --git a/meta/recipes-graphics/mesa/mesa-tools-native.bb b/meta/recipes-graphics/mesa/mesa-tools-native.bb
index 20207450bf..c495d2e8a8 100644
--- a/meta/recipes-graphics/mesa/mesa-tools-native.bb
+++ b/meta/recipes-graphics/mesa/mesa-tools-native.bb
@@ -11,7 +11,7 @@ PACKAGECONFIG += "gallium-llvm"
# to PACKAGECONFIG like in mesa.inc
PACKAGECONFIG += "${@bb.utils.filter('DISTRO_FEATURES', 'x11 wayland', d)}"
-DEPENDS += "libclc-native spirv-tools-native spirv-llvm-translator-native"
+DEPENDS += "mesa-libclc-native spirv-tools-native spirv-llvm-translator-native"
EXTRA_OEMESON += " \
-Dmesa-clc=enabled -Dinstall-mesa-clc=true -Dmesa-clc-bundle-headers=enabled \
diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-graphics/mesa/mesa.inc
index 15d56c804d..dea7a8295f 100644
--- a/meta/recipes-graphics/mesa/mesa.inc
+++ b/meta/recipes-graphics/mesa/mesa.inc
@@ -21,6 +21,8 @@ SRC_URI = "https://archive.mesa3d.org/mesa-${PV}.tar.xz \
file://0001-src-intel-compiler-jay-jay_ir.h-do-not-used-typed-en.patch \
file://0001-src-intel-compiler-jay-fix-GCC-10-case-label-declara.patch \
file://0001-src-util-u_math.c-do-not-use-arm-fpu-instructions-if.patch \
+ file://0001-clc-make-libclc-optional-for-configs-not-needing-it.patch \
+ file://0002-clc-use-our-downstream-fork-of-libclc.patch \
"
SRC_URI[sha256sum] = "79e421c7ce18cd9e790b8375920325779f10798630bf30e0b22f1a21c8617122"
@@ -110,7 +112,7 @@ PACKAGECONFIG[opengl] = "-Dopengl=true, -Dopengl=false"
# "opencl" also requires libclc and gallium-llvm to be present in PACKAGECONFIG!
# Be sure to enable them both for the target and for the native build.
-PACKAGECONFIG[opencl] = "-Dgallium-rusticl=true -Dmesa-clc-bundle-headers=enabled, -Dgallium-rusticl=false, bindgen-cli-native clang libclc spirv-tools spirv-llvm-translator"
+PACKAGECONFIG[opencl] = "-Dgallium-rusticl=true -Dmesa-clc-bundle-headers=enabled, -Dgallium-rusticl=false, bindgen-cli-native clang mesa-libclc spirv-tools spirv-llvm-translator"
X11_DEPS = "xorgproto virtual/libx11 libxext libxxf86vm libxdamage libxfixes xrandr xorgproto libxshmfence"
# "x11" requires "opengl"
@@ -254,7 +256,7 @@ RPROVIDES:libopencl-mesa += "virtual-opencl-icd"
RPROVIDES:libgles2-mesa += "libgles3-mesa"
RPROVIDES:libgles2-mesa-dev += "libgles3-mesa-dev"
-RDEPENDS:libopencl-mesa += "${@bb.utils.contains('PACKAGECONFIG', 'opencl', 'libclc', '', d)}"
+RDEPENDS:libopencl-mesa += "${@bb.utils.contains('PACKAGECONFIG', 'opencl', 'mesa-libclc', '', d)}"
PACKAGES =+ "libegl-mesa libegl-mesa-dev \
libgallium \
--
2.55.0
prev parent reply other threads:[~2026-07-19 8:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-19 8:01 [PATCH v2 1/3] mesa: Upgrade to 26.1.5 Zoltán Böszörményi
2026-07-19 8:01 ` [PATCH v2 2/3] mesa-libclc: New recipe for forking libclc for Rusticl purposes in Mesa Zoltán Böszörményi
2026-07-20 14:43 ` [OE-core] " Quentin Schulz
2026-07-21 4:08 ` Böszörményi Zoltán
2026-07-21 9:01 ` Quentin Schulz
2026-07-19 8:01 ` Zoltán Böszörményi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260719080108.1290998-3-zboszor@gmail.com \
--to=zboszor@gmail.com \
--cc=mathieu.dubois-briand@bootlin.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.